Name of Type of entity..

Name of Type of entity..

Anonymous
Not applicable
971 Views
3 Replies
Message 1 of 4

Name of Type of entity..

Anonymous
Not applicable
Hi

I know .ObjectName returns AcDbLine

but is there a way, other than string manipulation to return just Line,
Circle etc.?

Cheers
Dave F.
0 Likes
972 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Depending on what you want to do.

If you want to determine an AcadObject/AcadEntity is a line or a circle or
other...,

use

If TypeOf MyEntity Is AcadLine Then
...
End If

might be better than

If myEntity.ObjectName="AcDbLine" then
...
End If


Because TypeOf ...Is... you get intellisence prompt list, so at least you
have less chance of typing error.


That is
"Dave F." wrote in message
news:5741751@discussion.autodesk.com...
Hi

I know .ObjectName returns AcDbLine

but is there a way, other than string manipulation to return just Line,
Circle etc.?

Cheers
Dave F.
0 Likes
Message 3 of 4

Anonymous
Not applicable
Following is completely based on code that was
written by Bryco, SomeCallMeDave and others


Option Explicit

Private VL

Function GetVl() As Object
Dim AcadVer As Integer
Dim VLisp As Object
AcadVer = CInt(Left$(ThisDrawing.GetVariable("ACADVER"), 2))
Select Case AcadVer
Case Is < 16
Set VLisp = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
Case 16
Set VLisp = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
Case Else
Set VLisp = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
End Select

Set GetVl = VLisp

End Function



'SomeCallMeDave
'http://www.vbdesign.net/expresso/showthread.php?postid=83887#post83887
'Changed pAcadObj As AcadObject to pAcadObj As Object to access imagedef as well
'Modified by Jeff Mishler, March 2006, to get the Block table object, not Block_Record table object
Public Function vbAssoc(pAcadObj, pDXFCode As Integer) As Variant

Dim VLisp As Object
Dim VLispFunc As Object
Dim varRetVal As Variant

Dim obj1 As Object
Dim obj2 As Object

Dim strHnd As String
Dim strVer As String

Dim lngCount As Long
Dim i As Long
Dim j As Long

On Error GoTo vbAssocError

Set VLisp = GetVl


Set VLispFunc = VLisp.ActiveDocument.Functions

If Not TypeOf pAcadObj Is AcadBlock Then
strHnd = pAcadObj.Handle
Else
Dim lispStr As String
lispStr = "(cdr (assoc 5 (entget (tblobjname " & Chr(34) & "Block" & Chr(34) & Chr(34) & pAcadObj.Name & Chr(34) & "))))"
Set obj1 = VLispFunc.Item("read").Funcall(lispStr)
strHnd = VLispFunc.Item("eval").Funcall(obj1)
End If
Set obj1 = VLispFunc.Item("read").Funcall("pDXF")
varRetVal = VLispFunc.Item("set").Funcall(obj1, pDXFCode)
Set obj1 = VLispFunc.Item("read").Funcall("pHandle")
varRetVal = VLispFunc.Item("set").Funcall(obj1, strHnd)
Set obj1 = VLispFunc.Item("read").Funcall("(vl-princ-to-string (cdr (assoc pDXF (entget (handent pHandle)))))")
varRetVal = VLispFunc.Item("eval").Funcall(obj1)

vbAssoc = varRetVal

'clean up the newly created LISP symbols
Set obj1 = VLispFunc.Item("read").Funcall("(setq pDXF nil)")
varRetVal = VLispFunc.Item("eval").Funcall(obj1)
Set obj1 = VLispFunc.Item("read").Funcall("(setq pHandle nil)")
varRetVal = VLispFunc.Item("eval").Funcall(obj1)

'release the objects or Autocad gets squirrely (no offense RR)
Set obj2 = Nothing
Set obj1 = Nothing
Set VLispFunc = Nothing
Set VLisp = Nothing

Exit Function

vbAssocError:
Set obj2 = Nothing
Set obj1 = Nothing
Set VLispFunc = Nothing
Set VLisp = Nothing
MsgBox "Error occurred " & Err.Description

End Function


Sub GetEntType()

Dim varPt As Variant
Dim oEnt As AcadEntity

ThisDrawing.Utility.GetEntity oEnt, varPt

If Not oEnt Is Nothing Then
MsgBox vbAssoc(oEnt, 0)
End If

End Sub

~'J'~
0 Likes
Message 4 of 4

Anonymous
Not applicable
no.

"Dave F." wrote in message
news:5741751@discussion.autodesk.com...
Hi

I know .ObjectName returns AcDbLine

but is there a way, other than string manipulation to return just Line,
Circle etc.?

Cheers
Dave F.
0 Likes