网上不一定有能人啊呀!
我有一个问题,就是"在AUTOCAD中用VBA或Visual LISP中写一个程式,能在AUTOCAD中选中一个封闭的多义线(在封闭的多义线中有直线,倒圆角,圆弧,角度)按逆时针找出每一个2D坐标,写在一个文本文件里!我在网上坛子里问了三个月了,十几个人说来说去,都没搞定. 不知以下程序是否可用:
Sub oef()
Dim pnt As Variant
Dim ent1 As AcadLWPolyline
Dim ent2 As AcadLWPolyline
Dim ents As Variant
Dim pnts As Variant
Dim cnt As Integer
Dim cor() As Double
Dim i As Integer
Dim txt As String
ThisDrawing.Utility.GetEntity ent1, pnt
pnts = ent1.Coordinates
cnt = (UBound(pnts) + 1) / 2
Debug.Print cnt
ReDim cor(1, cnt) As Double
For i = 0 To UBound(pnts) Step 2
cor(0, i / 2) = ent1.Coordinates(i)
cor(1, i / 2) = ent1.Coordinates(i + 1)
Next
ents = ent1.Offset(10)
Set ent2 = ents(0)
If ent2.Area > ent1.Area Then
txt = "逆时针方向,其逆时针坐标如下:"
For i = 0 To UBound(cor, 2) - 1
txt = txt & vbCr & cor(0, i) & "," & cor(1, i)
Next
Else
txt = "线为顺时针方向,已经转换为逆时针的坐标如下:"
For i = UBound(cor, 2) - 1 To 0 Step -1
txt = txt & vbCr & cor(0, i) & "," & cor(1, i)
Next
End If
For i = 0 To UBound(ents)
ents(i).Delete
Next
MsgBox txt
End Sub
好像你只能找到一条直线的两个点,不能找多个点,比如下图的所有直线,倒圆角,圆弧,角度的点,就没有办法!
运行你那代码出错:
Run-time error ‘-2147418113(8000ffff):
Method ‘offset’ of object ‘iacadlwpolyline’failed
经调试出错代码为;
ents = ent1.Offset(10)
怎么办????? 惨了 注意你的条件是:
选中一个封闭的多义线(在封闭的多义线中有直线,倒圆角,圆弧,角度)
所以程序也只考虑到你所说的多义线的情况。 我那是封闭的多义线啊!只是画好了,用PE命令连接成一条啊! 我按照你所说的方法画线,圆角,再PE成多段线,但没有你所说的问题:
请问你用的AUTOCAD是什么版本? 可以了,谢谢!
但是能不能在直线,圆角,倒角的坐标前,作一个标识,来标识是线或是圆呢?
页:
[1]
2