www.mxdraw.com
|
动态施放绘制事件回调函数指针
[id(240) , helpstring("property ImpDynWorldDrawFun"), hidden, nonbrowsable]
IDispatch* ImpDynWorldDrawFun;
例如:JS 例子
// 调用地方 function DynInsert() { var sBlkName = "Tree"; var sBlkFile = mxOcx.GetOcxAppPath() + "\Blk\树.dwg"; mxOcx.InsertBlock(sBlkFile, "Tree"); var getPt = mxOcx.NewComObject("IMxDrawUiPrPoint"); getPt.message = "点取插入点"; var spDrawData1 = getPt.InitUserDraw("TestDynDraw1"); spDrawData1.SetString("BlkName","Tree"); if (getPt.go() != 1) { return; } var frstPt = getPt.value(); if (frstPt == null) { return; } var getSecondPt = mxOcx.NewComObject("IMxDrawUiPrPoint"); var spDrawData = getSecondPt.InitUserDraw("TestDynDraw"); getSecondPt.message = "点取旋转角度"; getSecondPt.basePoint = frstPt; getSecondPt.setUseBasePt(true); spDrawData.SetPoint("pt1", frstPt); spDrawData.SetString("BlkName", "Tree"); if (getSecondPt.go() != 1) { return; } var ret = spDrawData.Draw(); // 给属性块写文字. var blkRef = ret.AtObject(0); if (blkRef != null) { var param = mxOcx.NewResbuf(); blkRef.SetProp("createAttribute",param); } } // 设置回调函数 document.getElementById("MxDrawXCtrl").ImpDynWorldDrawFun = DoDynWorldDrawFun; // 函数实现代码 function DoDynWorldDrawFun(dX,dY,pWorldDraw,pData) { var sGuid = pData.Guid; mxOcx.SetEventRet(0); if(sGuid == "TestDynDraw") { // 动态插入图块。 var firstPt = pData.GetPoint("pt1"); if(firstPt == null) return; var sBlkName = pData.GetString("BlkName"); var secondPt = mxOcx.NewPoint(); secondPt.x = dX; secondPt.y = dY; var vec = firstPt.SumVector(secondPt); var dAng = vec.Angle(); pWorldDraw.DrawBlockReference(firstPt.x,firstPt.y,sBlkName,1.0,dAng * 180.0 / 3.14159265 + 90.0); mxOcx.SetEventRet(1); } else if (sGuid == "TestDynDraw1") { var sBlkName = pData.GetString("BlkName"); pWorldDraw.DrawBlockReference(dX, dY, sBlkName, 1.0, 0.0); } }