lihengmin 发表于 2007-12-22 20:34:00

[求助]怎样用VBA读取CASS软件内每个界址线段的扩展属性

怎样用VBA读取CASS软件内每个界址线段的扩展属性

雪山飞狐_lzh 发表于 2007-12-23 16:42:00

<p>发图上来看看</p>

lihengmin 发表于 2007-12-24 13:16:00

<p></p><p></p><p>此界址线整个有扩展属性,但每条线段上也有扩展属性,请您看看</p>

雪山飞狐_lzh 发表于 2007-12-24 13:47:00

本帖最后由 作者 于 2007-12-24 13:58:01 编辑 <br /><br /> <p>命令: xdlist<br/>选择对象:<br/>Enter application name &lt;*&gt;:</p><p><br/>* Registered Application Name: qhdm<br/>* Code 1000, ASCII string: 13</p><p>* Registered Application Name: YZDH<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: YDJMJ<br/>* Code 1040, Real number: 0.0000</p><p>* Registered Application Name: GLZDBH<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: GLFS<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: PCMJ<br/>* Code 1040, Real number: 0.0000</p><p>* Registered Application Name: KZMJ<br/>* Code 1040, Real number: 0.0000</p><p>* Registered Application Name: ZDMJ<br/>* Code 1040, Real number: 7738.2240</p><p>* Registered Application Name: TDZL<br/>* Code 1000, ASCII string: 济南市经济开发区高垣墙村</p><p>* Registered Application Name: SZTFH<br/>* Code 1000, ASCII string: 4049.00-478.25</p><p>* Registered Application Name: YYTFH<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: DJKBH<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: QLRDM<br/>* Code 1000, ASCII string: 中国网通有限责任公司济南分公司</p><p>* Registered Application Name: QLRZS<br/>* Code 1070, 16-bit integer: 1</p><p>* Registered Application Name: QSXZ<br/>* Code 1000, ASCII string: 100 国有土地</p><p>* Registered Application Name: TDSYZ<br/>* Code 1000, ASCII string: 中国网通有限责任公司济南分公司</p><p>* Registered Application Name: SYQLX<br/>* Code 1000, ASCII string: 2 出让</p><p>* Registered Application Name: WFLX<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: GYSYQQK<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: ZZRQ<br/>* Code 1000, ASCII string:<br/>-More-</p><p>* Registered Application Name: TDDJ<br/>* Code 1000, ASCII string: 01 一级</p><p>* Registered Application Name: SBDJ<br/>* Code 1040, Real number: 0.0000</p><p>* Registered Application Name: BDDJ<br/>* Code 1040, Real number: 0.0000</p><p>* Registered Application Name: SYQX<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: JZRJL<br/>* Code 1040, Real number: 0.5500</p><p>* Registered Application Name: JZMD<br/>* Code 1040, Real number: 0.2304</p><p>* Registered Application Name: JZWZDMJ<br/>* Code 1040, Real number: 1783.2050</p><p>* Registered Application Name: SBJZWQS<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: QSZMWJLX<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: QSZMWJBH<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: QSZMWJRQ<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: QSLYZM<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: ZDDZ<br/>* Code 1000, ASCII string: 高垣墙村土地</p><p>* Registered Application Name: ZDNZ<br/>* Code 1000, ASCII string: 高垣墙村土地</p><p>* Registered Application Name: ZDXZ<br/>* Code 1000, ASCII string: 经十西路</p><p>* Registered Application Name: ZDBZ<br/>* Code 1000, ASCII string: 巷道</p><p>* Registered Application Name: ZDT<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: JXXZ<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: YWZY<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: DCBH<br/>* Code 1000, ASCII string:<br/>-More-</p><p>* Registered Application Name: ZJWTS<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: YBDH<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: SM<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: ZJRQZ<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: QSDCJS<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: DCY<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: DCRQ<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: ZDCT<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: DJKZJS<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: KZY<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: KZRQ<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: DCSHYJ<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: DCSHR<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: DCSHRQ<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: TDZH<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: ZJBH<br/>* Code 1000, ASCII string: 3701130010010018</p><p>* Registered Application Name: RKSJ<br/>* Code 1000, ASCII string: 20070412</p><p>* Registered Application Name: RKRYDM<br/>* Code 1000, ASCII string: L-06</p><p>* Registered Application Name: XGSJ<br/>* Code 1000, ASCII string:</p><p>* Registered Application Name: XGRYDM<br/>* Code 1000, ASCII string:<br/>-More-</p><p>* Registered Application Name: SOUTH<br/>* Code 1000, ASCII string: 300000<br/>* Code 1000, ASCII string: 0010010018000<br/>* Code 1000, ASCII string: 中国网通有限责任公司济南分公司<br/>* Code 1000, ASCII string: 085</p><p>* Registered Application Name: TDYT<br/>* Code 1000, ASCII string: 085 文体娱乐用地</p><p>Object has 15612 bytes of Xdata space available.</p>

lihengmin 发表于 2007-12-24 22:01:00

<p>谢谢您,这些俺也能读,还有,每个线段上也有相应的扩展属性,1点~2点的属性如下,我是想用程序怎样连续读出</p><p>1001,YZDJH<br/>1000,<br/>1001,JZBC<br/>1040,0<br/>1001,JZXLB<br/>1000,2 墙壁<br/>1001,JZXWZ<br/>1000,3 外<br/>1001,JZXLX<br/>1000,1 地面界址线<br/>1001,JXXZ<br/>1000,30 未定界<br/>1001,ZZDZJR<br/>1000,<br/>1001,BZDZJRQ<br/>1000,<br/>1001,YZDZJR<br/>1000,<br/>1001,LZDZJRQ<br/>1000,<br/>1001,ZZZJWTS<br/>1000,<br/>1001,YZZJWTS<br/>1000,<br/>1001,WYTZS<br/>1000,<br/>1001,JZXFHDM<br/>1000,<br/>1001,RKSJ<br/>1000,<br/>1001,RKRYDM<br/>1000,<br/>1001,XGSJ<br/>1000,<br/>1001,XGRYDM<br/>1000,</p>

雪山飞狐_lzh 发表于 2007-12-25 11:52:00

CASS把Xdata放在Vertex对象了,而VBA的对象模型没有提供该对象
可以将多段线的handle依次循环加一,再调用HandleToObject获得该对象
如你的例图的Handle为464
用Set oVertex1 = ThisDrawing.HandleToObject("466")获得第二个Vertex对象,再调用GetXData
测试代码
Sub tt()
    Dim oVertex1 As AcadObject
    Dim i
    Dim xt, xd
    Dim s As String
   
    Set oVertex1 = ThisDrawing.HandleToObject("466")
   
    oVertex1.GetXData "", xt, xd
    For i = 0 To UBound(xd)
      s = s & vbCrLf & xd(i)
    Next i
   
    MsgBox s
End Sub

lihengmin 发表于 2007-12-25 13:10:00

<p></p><p>谢谢您,但界址线如进行了加点后,它的句柄就变了,如上图,有上面好的办法没有?</p>

雪山飞狐_lzh 发表于 2007-12-25 13:29:00

那就用Vlax类吧

雪山飞狐_lzh 发表于 2007-12-25 15:36:00

VBA代码
Function GetVertexs(Ent As AcadEntity) As Variant
    Dim n As Integer
    Dim oVertexs() As AcadObject
    Dim sName As String
    sName = UCase(Ent.ObjectName)
   
    If sName = "ACDB2DPOLYLINE" Or sName = "ACDB3DPOLYLINE" Then
      n = (UBound(Ent.Coordinates) + 1) / 3
    End If
   
    If n = 0 Then Exit Function
   
    ReDim oVertexs(n - 1)
   
    Dim oVlax As New VLAX
    lst = oVlax.GetLispList("(GetVers """ & Ent.Handle & """)")
   
    For i = 1 To n
      Set oVertexs(i - 1) = ThisDrawing.HandleToObject(lst(n - i))
    Next i
   
    GetVertexs = oVertexs
   
End Function
Sub test4()
    On Error Resume Next
   
    Dim obj As AcadEntity, pnt, oVers
    Dim xt, xd
   
    ThisDrawing.Utility.GetEntity obj, pnt
   
    oVers = GetVertexs(obj)
    If oVers <> vbEmpty Then
      For i = 0 To UBound(oVers)
            s = ""
            oVers(i).GetXData "", xt, xd
            
            For j = 0 To UBound(xd)
                s = s & vbCrLf & xd(j)
            Next j
            If Err Then
                Err.Clear
                MsgBox "空值"
            Else
                MsgBox s
            End If
      Next i
    Else
      MsgBox "错误选择"
    End If
End SubLisp代码
(defun getvers(handle / lst ver)
(setq ver (handent handle))
(while (and (setq ver (entnext ver)) (= "VERTEX" (cdr (assoc 0 (entget ver)))))(setq lst (cons (cdr (assoc 5 (entget ver))) lst)))
lst
)

lihengmin 发表于 2007-12-25 21:49:00

<p>我安装的是CAD2004,当执行GetVertexs过程时出现错误“用户定义类型未定义” 原因是下面的语句</p><p>Dim oVlax As New VLAX</p><p>麻烦您指点</p>
页: [1] 2
查看完整版本: [求助]怎样用VBA读取CASS软件内每个界址线段的扩展属性