lennie 发表于 2014-8-22 15:25:45

有什么办法可以取得天正对象的坐标么

本帖最后由 lennie 于 2014-8-22 20:14 编辑

我想用VBA获取天正文字的坐标,用网站提供的函数GetDXFCodeValuePublic Function GetDXFCodeValue(ent As Object, gCode As Integer) As Variant
    Dim retval
    Dim obj As New CL
      retval = obj.EvalLispExpression("(cdr (assoc " & gCode & " (entget(handent " & Chr(34) & ent.Handle & Chr(34) & "))))")
      GetDXFCodeValue = retval
      Set obj = Nothing
End FunctionGetDXFCodeValue(ent,10) 时出错,请问有什么办法可以取得天正对象的坐标么?

lennie 发表于 2014-8-25 11:40:18

自己解决了'获取图元组码
Public Function GetDXFCodeValue(Ent As Object, gCode As Integer) As Variant
    Dim retval
    Dim Obj As New CL
      retval = Obj.EvalLispExpression("(cdr (assoc " & gCode & " (entget (handent " & Chr(34) & Ent.Handle & Chr(34) & "))))")
      GetDXFCodeValue = retval
      Set Obj = Nothing
End Function

'获取图元组码(点坐标)
Function GetDxfPoint(Ent As Object, gCode As Integer) As Variant
    Dim retval
    Dim aPoint(2) As Double
    Dim Obj As New CL
      retval = Obj.EvalLispExpression("(car(cdr (assoc " & gCode & " (entget (handent " & Chr(34) & Ent.Handle & Chr(34) & ")))))")
      aPoint(0) = retval
      retval = Obj.EvalLispExpression("(car (cdr (cdr (assoc " & gCode & " (entget (handent " & Chr(34) & Ent.Handle & Chr(34) & "))))))")
      aPoint(1) = retval
      GetDxfPoint = aPoint
      Set Obj = Nothing
End Function

zzyong00 发表于 2014-8-25 13:18:49

自己的问题自己解决啊!

yzg_208 发表于 2014-9-4 14:44:13

Dim Obj As New CL
CL是VL类吧?在VB中如何加载VL类?
页: [1]
查看完整版本: 有什么办法可以取得天正对象的坐标么