CAD交互绘制圆形云线标注(网页版)

Posted lihao2014

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CAD交互绘制圆形云线标注(网页版)相关的知识,希望对你有一定的参考价值。


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, pWorldDraw, 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交互绘制圆形标注(网页版)

CAD绘制固定圆形标注(网页版)

CAD编辑器中怎么修订云线

CAD绘制单行文字(网页版)

CAD参数绘制椭圆(网页版)

CAD参数绘制圆(网页版)