You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

105 lines
3.0 KiB

function MxCADDrawLineWorldDraw(pt1)
{
var _pt1 = pt1;
this.worldDraw = function(currentPoint)
{
this.drawLine(currentPoint,_pt1);
}
this.setPoint1 = function(pt)
{
_pt1 = pt;
}
};
mxModule.regist(()=>{
MxFun.addCommand("Mx_Line",()=>{
var getPoint = new MrxDbgUiPrPoint();
getPoint.setMessage("\n指定第一点:");
getPoint.go((status)=>{
if(status != 0)
{
return;
}
MxCADDrawLineWorldDraw.prototype = new McEdGetPointWorldDraw();
var pt1 = getPoint.value();
var worldDrawComment = new MxCADDrawLineWorldDraw(pt1);
getPoint.setUserDraw(worldDrawComment);
getPoint.setMessage("\n指定下一点:");
var iCount = 0;
var lastPt = pt1;
getPoint.goWhile((status)=>{
if(status == 0)
{
var pt2 = getPoint.value();
var param =
{
x1:lastPt.x,
y1:lastPt.y,
x2:pt2.x,
y2:pt2.y,
};
//getPoint.drawReserve();
MxFun.call('mxcad_drawLine', param, function (ret) {
//console.log(ret);
});
lastPt = pt2;
worldDrawComment.setPoint1(pt2);
iCount++;
if(iCount >= 2 )
{
getPoint.setMessage("\n指定下一点:");
getPoint.setKeyWords("[闭合(C)/放弃(U)]");
}
else if(iCount > 0)
{
getPoint.setMessage("\n指定下一点:");
getPoint.setKeyWords("[放弃(U)]");
}
else
{
getPoint.setMessage("\n指定第一点:");
getPoint.setKeyWords("");
}
}
else if(status == 1)
{
// 输入关键字.
if(getPoint.isKeyWordPicked("C") )
{
// 闭合
var param =
{
x1:pt1.x,
y1:pt1.y,
x2:lastPt.x,
y2:lastPt.y,
};
MxFun.call('mxcad_drawLine', param, function (ret) {
//console.log(ret);
});
return {exit:true};
}
else if(getPoint.isKeyWordPicked("U") )
{
// 回退
console.log("mxcad_drawLine undo....");
}
}
});
});
});
})