CAD制作简单动画

主要用到函数说明:


IMxDrawEntity::Rotate


旋转一个对象。详细说明如下:


参数 说明

[in] IMxDrawPoint* basePoint

旋转基点

[in] DOUBLE dRotationAngle

旋转角度


扫描二维码关注公众号,回复: 6317284 查看本文章

IMxDrawAnimation::GetAnimationEntity2


得到动画临时对象.如果对象没有被初始成动画状态,返回为 NULL。详细说明如下:


参数 说明

[in] BSTR pszHandle

动画对象句柄


js中实现代码说明:


     function InitDraw() {
        draw = document.getElementById("MxDrawXCtrl");
  draw.ImplementCommandEventFun = function DoCommandEventFunc(iCmd) {
        if (iCmd == 1) {
             // 启动时打开文件
             draw.OpenDwgFile(draw.GetOcxAppPath() + "\\Blk\\animation.dwg");
             var animation = draw.NewComObject("IMxDrawAnimation");
                 //把对象初始化成动画状态
                 animation.InitAnimationEntity2("211");
      animation.InitAnimationEntity2("212");
      animation.InitAnimationEntity2("213");
                 // 启动一个控件时钟事件,用于实现动画。
      draw.CallLongParam1("Mx_StartUserTimer", 30);
             }
         };
         draw.ImplementCustomEvent = function CustomEvent(sEventName) {
if (sEventName == "Mx_UserTimer")
    {
       var animation = draw.NewComObject("IMxDrawAnimation");
       //开始一个动画绘制过程
                 animation.StartDraw();
                 // 211 212  213是需要旋转实体的句柄.
                 RotateEnt("211", animation);
                 RotateEnt("212", animation);
                 RotateEnt("213", animation);
                 //结束动画绘制过程
                 animation.EndDraw();
                 // 注意需要显示释放递代器.,不然会引起错误
       animation = null; 
       CollectGarbage();
   }
         };   
     }


function  RotateEnt( handls,  animation)
      {
          //得到动画临时对象.如果对象没有被初始成动画状态,返回为 NULL
          var ent = animation.GetAnimationEntity2(handls);
          if (ent != null && (ent.ObjectName == "McDbBlockReference"))
          {
              var blkRef = ent;
              //旋转一个对象,参数一为旋转基点,参数二为旋转角度
              blkRef.Rotate(blkRef.Position, -30 * 3.14159265 / 180.0);
              //绘制动画对象.该函数只能在StartDraw,EndDraw之前调用
              animation.Draw2(handls);
          }
      }

猜你喜欢

转载自www.cnblogs.com/yzy0224/p/10955359.html