Js中实现代码说明:
动态拖放时的绘制事件:
function DoDynWorldDrawFun(dX,dY,pWorldDraw,pData) { //自定义实体的GUID标识符 var sGuID = pData.GuID; //设置自定义事件的返回值 mxOcx.SetEventRet(0); var curPt = mxOcx.NewPoint(); curPt.x = dX; curPt.y = dY; if (sGuID == "DrawCircle") { var pt1 = pData.GetPoint("pt1"); var dR = curPt.distanceto(pt1) * 0.5; var vec = curPt.SumVector(pt1); vec.Mult(0.5); pt1.Add(vec); pWorldDraw.DrawCircle(pt1.x,pt1.y,dR);}}
动态拖放时的绘制事件:
function DynWorldDrawCloudComment(pCustomEntity,curPt) { // 得到绘制参数. var sText = pCustomEntity.GetString("Text"); var dTextHeight = pCustomEntity.GetDouble("TextHeight"); var IEdgeNumber = pCustomEntity.GetLong("EdgeNumber"); var dShapRadius = pCustomEntity.GetDouble("ShapRadius"); var basePoint = pCustomEntity.GetPoint("BasePoint"); var frstPt = pCustomEntity.GetPoint("frstPt"); // 创建一个批注对象. var comment = mxOcx.NewEntity("IMxDrawComment"); comment.Text = sText; comment.TextHeight = dTextHeight; comment.EdgeNumber = IEdgeNumber; comment.ShapRadius = dShapRadius; comment.basePoint = basePoint; comment.position = curPt; comment.BoundingBoxType = 5; comment.ArrowType = 2; comment.ShapRadius = 40; var points = mxOcx.NewComObject("IMxDrawPoints"); //向点数组中增加一个点坐标 points.Add2(frstPt); points.Add2(basePoint); //标注框坐标数据 comment.Bounding = points; var tmpp = mxOcx.NewResbuf(); tmpp.AddLong(1); comment.SetProp("isAlwaysShowlineWeight",tmpp); //线重 comment.lineweight = 25; //实体的CAD颜色索引值属性 comment.colorIndex = 1; // 设置文字样式。 pWorldDraw.TextStyle = "MyCommentFont"; // 动态绘制. pWorldDraw.DrawEntity(comment);}
动态绘制文字:
function DoCloudCircleComment() { var getPt = mxOcx.NewComObject("IMxDrawUiPrPoint"); getPt.message = "点取第一点"; if (getPt.go() != 1) { return; } var frstPt = getPt.value(); if (frstPt == null) return; var getPt2 = mxOcx.NewComObject("IMxDrawUiPrPoint"); getPt2.message = "指定第二个点"; var spDrawData = getPt2.InitUserDraw("DrawCircle"); spDrawData.SetPoint("pt1",frstPt); if (getPt2.go() != 1) { return; } var secondPt = getPt2.value(); if (secondPt == null) return; var param = mxOcx.NewResbuf(); param.AddString(""); param.AddDouble(100); var ret = mxOcx.CallEx("Mx_ShowMTextDialog",param); if (ret.AtString(0) != "Ok") { return; } var txt = ret.AtString(1); var txtH = ret.AtDouble(2); var txtcolorIndex = ret.AtLong(3); // 加入换行 *** 作符\P //txt = txt + "\PTEST"; // 创建一个文字样式,用于批注文字字体. mxOcx.AddTextStyle2("MyCommentFont","黑体",0.7); // 创建一个与用户交互取点的对象。 var getSecondPt = mxOcx.NewComObject("IMxDrawUiPrPoint"); getSecondPt.message = "输入标注位置点"; getSecondPt.basePoint = secondPt; getSecondPt.setUseBasePt(false); spDrawData = getSecondPt.InitUserDraw("DrawCloudComment"); // 设置动态绘制参数. spDrawData.SetPoint("frstPt",frstPt); spDrawData.SetPoint("BasePoint",secondPt); spDrawData.SetString("Text",txt); spDrawData.SetDouble("TextHeight",txtH); spDrawData.SetLong("EdgeNumber",2); spDrawData.SetDouble("ShapRadius",1); // 开始取第二个点。 if (getSecondPt.go() != 1) return; var ret = spDrawData.Draw(); // 设置绘制的批注文字样式。 var ent = ret.AtObject(0); ent.colorIndex = 1;}总结
以上是内存溢出为你收集整理的CAD交互绘制圆形云线批注(网页版)全部内容,希望文章能够帮你解决CAD交互绘制圆形云线批注(网页版)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)