[求助]用VBA读实体的组码
<p>怎样用VBA读实体的组码?如下面的数据内读出“图元名: 43f47cc0”</p><p>((-1 . <图元名: 43fd1a58>) (0 . "INSERT") (5 . "33A8B") (102 . "{ACAD_REACTORS") (330 . <图元名: 43fd1a30>) (102 . }") (330 . <图元名: 43f47cc0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "ZBTZ") (6 . "Continuous") (100 . "AcDbBlockReference") (2 . "gc429") (10 517405.0 4.08063e+006 0.0) (41 . 3.0) (42 . 3.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0))</p> 求助<br/>怎么用VBA读取CAD实体的DXF组码?如编组的组码<br/>((-1 . <图元名: 43fd1a48>) (0 . "INSERT") (5 . "33A89") (102 . "{ACAD_REACTORS") (330 . <图元名: 43fd1a30>) (102 . "}") (330 . <图元名: 43f47cc0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "ZBTZ") (6 . "Continuous") (100 . "AcDbBlockReference") (2 . "gc429") (10 517285.0 4.08063e+006 0.0) (41 . 3.0) (42 . 3.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0)) <br/>上面的数据内怎么读出(330 . <图元名: 43f47cc0>) <br/> 明月,我也发帖了,没有人回啊 <p>如果cad对象参考中没有这个函数,那么估计是没有直接的办法了。</p><p>像我在另外一贴回的那样,可以试试:</p><p></p><p>没有试过读取组码。</p><p>而且感觉组码这个东西比较复杂,不同地方含义有不相同。</p><p>实体的祖码我不会,不过我觉得可以自己在帮助中查到实体组码,然后与其对应</p><p>的entitytype列表,vba查询到实体的entitytype,对应找到组码</p> <p>可能有两个方法:<br/>1.使用VLAX类。<br/>2.将图转成DXF,以处理文本的方法来处理。</p> <p>请问使用VLAX 怎么使用?VLAX类代码如下:</p><p>Private VL As Object<br/>Private VLF As Object<br/>Private Sub Class_Initialize()<br/> If Left(ThisDrawing.Application.Version, 2) = "15" Then<br/> Set VL = GetInterfaceObject("VL.Application.1")<br/> ElseIf Left(ThisDrawing.Application.Version, 2) = "16" Then<br/> Set VL = GetInterfaceObject("VL.Application.16")<br/> ElseIf Left(ThisDrawing.Application.Version, 2) = "17" Then<br/> Set VL = GetInterfaceObject("VL.Application.16")<br/> End If<br/> Set VLF = VL.ActiveDocument.Functions<br/>End Sub<br/>Private Sub Class_Terminate()<br/> Set VLF = Nothing<br/> Set VL = Nothing<br/>End Sub<br/>Public Function EvalLispExpression(ByVal lispStatement As String)<br/> Dim sym As Object, RET As Object, RetVal<br/> <br/> Set sym = VLF.Item("read").Funcall(lispStatement)<br/> On Error Resume Next<br/> RetVal = VLF.Item("eval").Funcall(sym)<br/> If Err Then<br/> EvalLispExpression = ""<br/> Else<br/> EvalLispExpression = RetVal<br/> End If<br/>End Function<br/>Public Sub SetLispSymbol(ByVal symbolName As String, ByVal Value)<br/> Dim sym As Object, RET, symvalue<br/> <br/> symvalue = Value<br/> Set sym = VLF.Item("read").Funcall(symbolName)<br/> RET = VLF.Item("set").Funcall(sym, symvalue)<br/> EvalLispExpression "(defun translate-variant (data) (cond ((= (type data) 'list) (mapcar 'translate-variant data)) ((= (type data) 'variant) (translate-variant (vlax-variant-value data))) ((= (type data) 'safearray) (mapcar 'translate-variant (vlax-safearray->list data))) (t data)))"<br/> EvalLispExpression "(setq " & symbolName & "(translate-variant " & symbolName & "))"<br/> EvalLispExpression "(setq translate-variant nil)"<br/>End Sub<br/>Public Function GetLispSymbol(ByVal symbolName As String)<br/> Dim sym As Object, RET, symvalue<br/> <br/> symvalue = Value<br/> Set sym = VLF.Item("read").Funcall(symbolName)<br/> GetLispSymbol = VLF.Item("eval").Funcall(sym)<br/>End Function<br/>Public Function GetLispList(ByVal symbolName As String) As Variant<br/> Dim sym As Object, list As Object<br/> Dim Count, elements(), i As Long<br/> <br/> Set sym = VLF.Item("Read").Funcall(symbolName)<br/> Set list = VLF.Item("Eval").Funcall(sym)<br/> <br/> Count = VLF.Item("length").Funcall(list)<br/> <br/> ReDim elements(0 To Count - 1) As Variant<br/> <br/> For i = 0 To Count - 1<br/> elements(i) = VLF.Item("nth").Funcall(i, list)<br/> Next<br/> <br/> GetLispList = elements<br/> <br/>End Function<br/>Public Sub NullifySymbol(ParamArray symbolName())<br/> Dim i As Integer<br/> <br/> For i = LBound(symbolName) To UBound(symbolName)<br/> EvalLispExpression "(setq " & CStr(symbolName(i)) & " nil)"<br/> Next<br/>End Sub</p> <p>麻烦您指教 使用VLAX类怎样读取,是上面的VLAX类吗?怎样调用</p><p>十分感谢</p> 请版主回答啊 帮帮忙吧 <p> (assoc 331 (car (entsel)))</p><p>用此命令可得到 “ (330 . <图元名: 43fd1a30>) ”,但有时得到前面330 有的实体得到后面的,是怎么搞的?</p>
页:
[1]
2