明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 9401|回复: 19

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

  [复制链接]
发表于 2007-12-22 20:34:00 | 显示全部楼层 |阅读模式
怎样用VBA读取CASS软件内每个界址线段的扩展属性
发表于 2007-12-23 16:42:00 | 显示全部楼层

发图上来看看

 楼主| 发表于 2007-12-24 13:16:00 | 显示全部楼层

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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2007-12-24 13:47:00 | 显示全部楼层
本帖最后由 作者 于 2007-12-24 13:58:01 编辑

命令: xdlist
选择对象:
Enter application name <*>:


* Registered Application Name: qhdm
* Code 1000, ASCII string: 13

* Registered Application Name: YZDH
* Code 1000, ASCII string:

* Registered Application Name: YDJMJ
* Code 1040, Real number: 0.0000

* Registered Application Name: GLZDBH
* Code 1000, ASCII string:

* Registered Application Name: GLFS
* Code 1000, ASCII string:

* Registered Application Name: PCMJ
* Code 1040, Real number: 0.0000

* Registered Application Name: KZMJ
* Code 1040, Real number: 0.0000

* Registered Application Name: ZDMJ
* Code 1040, Real number: 7738.2240

* Registered Application Name: TDZL
* Code 1000, ASCII string: 济南市经济开发区高垣墙村

* Registered Application Name: SZTFH
* Code 1000, ASCII string: 4049.00-478.25

* Registered Application Name: YYTFH
* Code 1000, ASCII string:

* Registered Application Name: DJKBH
* Code 1000, ASCII string:

* Registered Application Name: QLRDM
* Code 1000, ASCII string: 中国网通有限责任公司济南分公司

* Registered Application Name: QLRZS
* Code 1070, 16-bit integer: 1

* Registered Application Name: QSXZ
* Code 1000, ASCII string: 100 国有土地

* Registered Application Name: TDSYZ
* Code 1000, ASCII string: 中国网通有限责任公司济南分公司

* Registered Application Name: SYQLX
* Code 1000, ASCII string: 2 出让

* Registered Application Name: WFLX
* Code 1000, ASCII string:

* Registered Application Name: GYSYQQK
* Code 1000, ASCII string:

* Registered Application Name: ZZRQ
* Code 1000, ASCII string:
-More-

* Registered Application Name: TDDJ
* Code 1000, ASCII string: 01 一级

* Registered Application Name: SBDJ
* Code 1040, Real number: 0.0000

* Registered Application Name: BDDJ
* Code 1040, Real number: 0.0000

* Registered Application Name: SYQX
* Code 1000, ASCII string:

* Registered Application Name: JZRJL
* Code 1040, Real number: 0.5500

* Registered Application Name: JZMD
* Code 1040, Real number: 0.2304

* Registered Application Name: JZWZDMJ
* Code 1040, Real number: 1783.2050

* Registered Application Name: SBJZWQS
* Code 1000, ASCII string:

* Registered Application Name: QSZMWJLX
* Code 1000, ASCII string:

* Registered Application Name: QSZMWJBH
* Code 1000, ASCII string:

* Registered Application Name: QSZMWJRQ
* Code 1000, ASCII string:

* Registered Application Name: QSLYZM
* Code 1000, ASCII string:

* Registered Application Name: ZDDZ
* Code 1000, ASCII string: 高垣墙村土地

* Registered Application Name: ZDNZ
* Code 1000, ASCII string: 高垣墙村土地

* Registered Application Name: ZDXZ
* Code 1000, ASCII string: 经十西路

* Registered Application Name: ZDBZ
* Code 1000, ASCII string: 巷道

* Registered Application Name: ZDT
* Code 1000, ASCII string:

* Registered Application Name: JXXZ
* Code 1000, ASCII string:

* Registered Application Name: YWZY
* Code 1000, ASCII string:

* Registered Application Name: DCBH
* Code 1000, ASCII string:
-More-

* Registered Application Name: ZJWTS
* Code 1000, ASCII string:

* Registered Application Name: YBDH
* Code 1000, ASCII string:

* Registered Application Name: SM
* Code 1000, ASCII string:

* Registered Application Name: ZJRQZ
* Code 1000, ASCII string:

* Registered Application Name: QSDCJS
* Code 1000, ASCII string:

* Registered Application Name: DCY
* Code 1000, ASCII string:

* Registered Application Name: DCRQ
* Code 1000, ASCII string:

* Registered Application Name: ZDCT
* Code 1000, ASCII string:

* Registered Application Name: DJKZJS
* Code 1000, ASCII string:

* Registered Application Name: KZY
* Code 1000, ASCII string:

* Registered Application Name: KZRQ
* Code 1000, ASCII string:

* Registered Application Name: DCSHYJ
* Code 1000, ASCII string:

* Registered Application Name: DCSHR
* Code 1000, ASCII string:

* Registered Application Name: DCSHRQ
* Code 1000, ASCII string:

* Registered Application Name: TDZH
* Code 1000, ASCII string:

* Registered Application Name: ZJBH
* Code 1000, ASCII string: 3701130010010018

* Registered Application Name: RKSJ
* Code 1000, ASCII string: 20070412

* Registered Application Name: RKRYDM
* Code 1000, ASCII string: L-06

* Registered Application Name: XGSJ
* Code 1000, ASCII string:

* Registered Application Name: XGRYDM
* Code 1000, ASCII string:
-More-

* Registered Application Name: SOUTH
* Code 1000, ASCII string: 300000
* Code 1000, ASCII string: 0010010018000
* Code 1000, ASCII string: 中国网通有限责任公司济南分公司
* Code 1000, ASCII string: 085

* Registered Application Name: TDYT
* Code 1000, ASCII string: 085 文体娱乐用地

Object has 15612 bytes of Xdata space available.

 楼主| 发表于 2007-12-24 22:01:00 | 显示全部楼层

谢谢您,这些俺也能读,还有,每个线段上也有相应的扩展属性,1点~2点的属性如下,我是想用程序怎样连续读出

1001,YZDJH
1000,
1001,JZBC
1040,0
1001,JZXLB
1000,2 墙壁
1001,JZXWZ
1000,3 外
1001,JZXLX
1000,1 地面界址线
1001,JXXZ
1000,30 未定界
1001,ZZDZJR
1000,
1001,BZDZJRQ
1000,
1001,YZDZJR
1000,
1001,LZDZJRQ
1000,
1001,ZZZJWTS
1000,
1001,YZZJWTS
1000,
1001,WYTZS
1000,
1001,JZXFHDM
1000,
1001,RKSJ
1000,
1001,RKRYDM
1000,
1001,XGSJ
1000,
1001,XGRYDM
1000,

发表于 2007-12-25 11:52:00 | 显示全部楼层
CASS把Xdata放在Vertex对象了,而VBA的对象模型没有提供该对象
可以将多段线的handle依次循环加一,再调用HandleToObject获得该对象
如你的例图的Handle为464
用Set oVertex1 = ThisDrawing.HandleToObject("466")获得第二个Vertex对象,再调用GetXData
测试代码
  1. Sub tt()
  2.     Dim oVertex1 As AcadObject
  3.     Dim i
  4.     Dim xt, xd
  5.     Dim s As String
  6.    
  7.     Set oVertex1 = ThisDrawing.HandleToObject("466")
  8.    
  9.     oVertex1.GetXData "", xt, xd
  10.     For i = 0 To UBound(xd)
  11.         s = s & vbCrLf & xd(i)
  12.     Next i
  13.    
  14.     MsgBox s
  15. End Sub

 楼主| 发表于 2007-12-25 13:10:00 | 显示全部楼层

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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2007-12-25 13:29:00 | 显示全部楼层
那就用Vlax类吧
发表于 2007-12-25 15:36:00 | 显示全部楼层
VBA代码
  1. Function GetVertexs(Ent As AcadEntity) As Variant
  2.     Dim n As Integer
  3.     Dim oVertexs() As AcadObject
  4.     Dim sName As String
  5.     sName = UCase(Ent.ObjectName)
  6.    
  7.     If sName = "ACDB2DPOLYLINE" Or sName = "ACDB3DPOLYLINE" Then
  8.         n = (UBound(Ent.Coordinates) + 1) / 3
  9.     End If
  10.    
  11.     If n = 0 Then Exit Function
  12.    
  13.     ReDim oVertexs(n - 1)
  14.    
  15.     Dim oVlax As New VLAX
  16.     lst = oVlax.GetLispList("(GetVers """ & Ent.Handle & """)")
  17.    
  18.     For i = 1 To n
  19.         Set oVertexs(i - 1) = ThisDrawing.HandleToObject(lst(n - i))
  20.     Next i
  21.    
  22.     GetVertexs = oVertexs
  23.    
  24. End Function
  25. Sub test4()
  26.     On Error Resume Next
  27.    
  28.     Dim obj As AcadEntity, pnt, oVers
  29.     Dim xt, xd
  30.    
  31.     ThisDrawing.Utility.GetEntity obj, pnt
  32.    
  33.     oVers = GetVertexs(obj)
  34.     If oVers <> vbEmpty Then
  35.         For i = 0 To UBound(oVers)
  36.             s = ""
  37.             oVers(i).GetXData "", xt, xd
  38.             
  39.             For j = 0 To UBound(xd)
  40.                 s = s & vbCrLf & xd(j)
  41.             Next j
  42.             If Err Then
  43.                 Err.Clear
  44.                 MsgBox "空值"
  45.             Else
  46.                 MsgBox s
  47.             End If
  48.         Next i
  49.     Else
  50.         MsgBox "错误选择"
  51.     End If
  52. End Sub
Lisp代码
  1. (defun getvers(handle / lst ver)
  2. (setq ver (handent handle))
  3. (while (and (setq ver (entnext ver)) (= "VERTEX" (cdr (assoc 0 (entget ver)))))(setq lst (cons (cdr (assoc 5 (entget ver))) lst)))
  4. lst
  5. )
 楼主| 发表于 2007-12-25 21:49:00 | 显示全部楼层

我安装的是CAD2004,当执行GetVertexs过程时出现错误“用户定义类型未定义” 原因是下面的语句

Dim oVlax As New VLAX

麻烦您指点

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 12:23 , Processed in 0.164649 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表