本帖最后由 lennie 于 2015-4-29 14:32 编辑
程序精简了一下:- Public Function WipeOutFrame() As Boolean '返回wipout边界是否打开的状态,打开返回True
- Dim obj As Object
- For Each obj In ThisDrawing.Dictionaries
- If obj.ObjectName = "AcDbWipeoutVariables" Then
- WipeOutFrame = CBool(GetDXFCodeValue(obj, 70))
- End If
- Next
- End Function
这里用到一个修改后的函数 GetDXFCodeValue:- 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
另外,用SendCommand的方法命令窗口会跳出一堆文字,毕竟不美观。以下是我来获取天正对象坐标(组码10)的函数:- Function GetDxfPoint(Ent As Object, gCode As Integer) As Variant
- Select Case TypeName(Ent)
- Case "IComSymbElev", "IComLineText", "IComSpace"
- 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
- retval = obj.EvalLispExpression("(car (cdr (cdr (cdr (assoc " & gCode & " (entget (handent " & Chr(34) & Ent.Handle & Chr(34) & ")))))))")
- aPoint(2) = retval
- GetDxfPoint = aPoint
- Set obj = Nothing
- Case "IAcadText", "IAcadMText"
- GetDxfPoint = Ent.InsertionPoint
- End Select
- End Function
|