- 积分
- 2650
- 明经币
- 个
- 注册时间
- 2007-9-23
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|

楼主 |
发表于 2019-1-12 10:03:12
|
显示全部楼层
已经在VBA中搞定,VBA代码如下
'获得图元的组码,返回值为指定类型的数组
Public Function GetEntDXF(ByVal ent As Object) As Variant
Dim sym As Object, list As Object
Dim Count As Integer, Count1 As Integer, i As Integer, j As Integer
Dim elements() As Variant, elements1() As Variant
Dim objTemp As Object, objTemp1 As Object
Set sym = VLFS.Item("read").funcall("(entget (handent" & Chr(34) & ent.Handle & Chr(34) & "))")
Set list = VLFS.Item("eval").funcall(sym)
Count = VLFS.Item("length").funcall(list)
ReDim elements(0 To Count - 1)
For i = 0 To Count - 1
Set objTemp = VLFS.Item("nth").funcall(i, list)
Count1 = VLFS.Item("vl-list-length").funcall(objTemp)
If Count1 = 0 Then '如果返回值为0说明是点对
ReDim elements1(0 To 1)
elements1(0) = VLFS.Item("car").funcall(objTemp) '获得点对的第一个组码
If TypeName(VLFS.Item("cdr").funcall(objTemp)) = "DVlObject" Then '如果点对的第二个元素是对象的话,说明是图元名,否则是数据
Set objTemp1 = VLFS.Item("cdr").funcall(objTemp)
If objTemp1.Type = "lentity" Then
Set elements1(1) = VLFS.Item("cdr").funcall(objTemp)
End If
Else '点对数据
elements1(1) = VLFS.Item("cdr").funcall(objTemp)
End If
Else '否则说明是表
ReDim elements1(0 To Count1 - 1)
For j = 0 To Count1 - 1
elements1(j) = VLFS.Item("nth").funcall(j, objTemp)
Next j
End If
elements(i) = elements1
Next
GetEntDXF = elements
End Function |
|