翔羽 发表于 2005-4-16 11:19:00

当平移直线后,怎样通过VBA得到平移的距离?

求救:当在AUTOCAD中选择一条直线后,运行move命令后,怎样通过VBA立即获取它移动的距离,移动后起点,端点坐标?

ljpnb 发表于 2005-4-16 15:44:00

本帖最后由 作者 于 2005-4-17 6:11:26 编辑 <br /><br /> 我对VBA不太熟悉,所以试着写了一个,请大家指正


Sub move_line()<BR>Dim lineobj As AcadLine<BR>Dim lineobj1 As AcadLine<BR>Dim point_1 As Variant<BR>Dim point_2 As Variant<BR>Dim length As Double<BR>Dim aa As String, bb As String


ThisDrawing.Utility.GetEntity lineobj, pt, "选择要移动的直线:"<BR>point_1 = ThisDrawing.Utility.GetPoint(, "输入基准点:")<BR>point_2 = ThisDrawing.Utility.GetPoint(, "输入第二点:")<BR>lineobj.Move point_1, point_2<BR>aa = Str(lineobj.StartPoint(0)) + "," + Str(lineobj.StartPoint(1)) + "," + Str(lineobj.StartPoint(2))<BR>bb = Str(lineobj.EndPoint(0)) + "," + Str(lineobj.EndPoint(1)) + "," + Str(lineobj.EndPoint(2))<BR>ThisDrawing.Regen acAllViewports<BR>Set lineobj1 = ThisDrawing.ModelSpace.AddLine(point_1, point_2)<BR>length = lineobj.length<BR>lineobj1.Delete<BR>MsgBox "移动长度为: " &amp; length &amp; vbCrLf &amp; "起点坐标为:" &amp; aa &amp; vbCrLf &amp; "终点坐标为:" &amp; bb


End Sub


<BR>

翔羽 发表于 2005-4-17 09:43:00

谢谢~~

caizhiming 发表于 2005-4-21 15:37:00

请教版主:


怎样用VBA选择多线段,并显示多线段的面积?


谢谢!!

bolow 发表于 2005-4-21 15:43:00

怎样用VBA选择多线段,并显示多线段的面积?


选择就是选择一个entity       然后重新赋值给polyline


面积就是area属性
页: [1]
查看完整版本: 当平移直线后,怎样通过VBA得到平移的距离?