主要用到函數說明:
IMxDrawEntity::Rotate
旋轉一個對象。詳細說明如下:
| 參數 | 說明 |
|---|---|
| [in] IMxDrawPoint* basePoint |
旋轉基點 |
| [in] DOUBLE dRotationAngle |
旋轉角度 |
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);
}
}
