明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1630|回复: 3

[提问] 有什么办法可以取得天正对象的坐标么?

[复制链接]
发表于 2014-8-22 15:26:28 | 显示全部楼层 |阅读模式
本帖最后由 lennie 于 2014-8-22 20:09 编辑

我想用VBA获取天正文字的坐标,用网站提供的函数GetDXFCodeValue
  1. Public Function GetDXFCodeValue(ent As Object, gCode As Integer) As Variant
  2.     Dim retval
  3.     Dim obj As New CL
  4.         retval = obj.EvalLispExpression("(cdr (assoc " & gCode & " (entget(handent " & Chr(34) & ent.Handle & Chr(34) & "))))")
  5.         GetDXFCodeValue = retval
  6.         Set obj = Nothing
  7. End Function
GetDXFCodeValue(ent,10) 时出错,请问有什么办法可以取得天正对象的坐标么?
发表于 2014-8-22 18:57:59 | 显示全部楼层
直接(cdr (assoc 10 (entget dx)))
 楼主| 发表于 2014-8-22 20:09:50 | 显示全部楼层
aihuyujian  怎么把这个点传递给VBA啊
 楼主| 发表于 2014-8-25 11:38:58 | 显示全部楼层
自己解决了
  1. '获取图元组码
  2. Public Function GetDXFCodeValue(Ent As Object, gCode As Integer) As Variant
  3.     Dim retval
  4.     Dim Obj As New CL
  5.         retval = Obj.EvalLispExpression("(cdr (assoc " & gCode & " (entget (handent " & Chr(34) & Ent.Handle & Chr(34) & "))))")
  6.         GetDXFCodeValue = retval
  7.         Set Obj = Nothing
  8. End Function

  9. '获取图元组码(点坐标)
  10. Function GetDxfPoint(Ent As Object, gCode As Integer) As Variant
  11.     Dim retval
  12.     Dim aPoint(2) As Double
  13.     Dim Obj As New CL
  14.         retval = Obj.EvalLispExpression("(car(cdr (assoc " & gCode & " (entget (handent " & Chr(34) & Ent.Handle & Chr(34) & ")))))")
  15.         aPoint(0) = retval
  16.         retval = Obj.EvalLispExpression("(car (cdr (cdr (assoc " & gCode & " (entget (handent " & Chr(34) & Ent.Handle & Chr(34) & "))))))")
  17.         aPoint(1) = retval
  18.         GetDxfPoint = aPoint
  19.         Set Obj = Nothing
  20. End Function
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 14:20 , Processed in 0.237987 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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