怎么从CAD中提取多段线坐标
1个回答
展开全部
两种办法
第一种手工用鼠标选择多段线,然后输入list命令,弹出一个窗口,然后复制那些坐标,粘到excel里面,在exel里面根据空格来分列,最后得到X,Y的数值
第二种就麻烦一些了,建立一个选择集,用lisp或者vba来写一个提取多段线的代码。我这里有网上的一个vba代码,如果你不会vba的话,最好不要用。
Option Explicit
Public Sub GetLWPOLYLINECoordinates()
Dim ss_dim As AcadSelectionSet, ent As AcadLWPolyline
Dim dxf_code() As Integer, dxf_value() As Variant
'Dim i As Long,
Dim j As Long
Dim dbCor As Variant, x As Double, y As Double, z As Double
Set ss_dim = ThisDrawing.SelectionSets.Add("ssLine1")
ReDim dxf_code(0), dxf_value(0)
dxf_code(0) = 0: dxf_value(0) = "LWPOLYLINE"
'ss_dim.Select acSelectionSetAll, , , dxf_code, dxf_value
ss_dim.SelectOnScreen dxf_code, dxf_value
Open "d:\aaaaa.txt" For Append As #1
For Each ent In ss_dim
For j = 0 To UBound(ent.Coordinates) \ 2
x = ent.Coordinates(j * 2)
y = ent.Coordinates(j * 2 + 1)
Print #1, (j); ",," & x & "," & y
Next
Next
Stop
Close #1
ss_dim.Clear
ss_dim.Delete
End Sub
来源于网络,不是本人写的,谢谢提供这段代码的人
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询