CAD网页交互绘直线
放入一个绘直线按钮:<input type="button" value="绘制直线" onclick="myclick()">function myclick()
{
//下面的DoCommand(1)调用程序将跳到DoCommandEventFunc(iCmd)执行
document.getElementById("MxDrawXCtrl").DoCommand(1);
}
定义一个控件命令执行函数:
function DoCommandEventFunc(iCmd)
{
if (iCmd == 1)
{
// 绘直线代码
var mxOcx = document.all.item("MxDrawXCtrl");
mxOcx.focus();
// 与用户交互,在图上点取一个点
var point1 = mxOcx.GetPoint(false,0,0,"\n 点取开始点:");
if(point1 == null)
{
return;
}
// 与用户交互,在图上点取第二点
var point2 = mxOcx.GetPoint(true,point1.x,point1.y,"\n 点取结束点:");
if(point1 == null)
{
return;
}
// 开始画直线的,返回id
var lineId = mxOcx.DrawLine(point1.x,point1.y,point2.x,point2.y);
}
}设置命令执行函数到控件属性如下:
document.getElementById("MxDrawXCtrl").ImplementCommandEventFun =
DoCommandEventFunc;
谢谢楼主分享 谢谢楼主分享!
页:
[1]