I'm afraid this will not work in .NET the way it worked in VBA, mainly
because in the managed API, you cannot access items in blocks using numeric
indexes.
If you are in a hurry to port, my advice would be to use the COM API from C#
or VB.NET to do the same thing you were doing in VBA.
You can do the other part in managed code by getting the managed wrapper for
the AcadBlockReference COM object using the DBObject.FromAcadObject() static
method .
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010
http://www.acadxtabs.com
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
wrote in message news:6299383@discussion.autodesk.com...
current session. The block all ready exists somewhere in the system path.
I found these examples in VBA which I currently use but do to the lack of a
VBA interface in 2010 I am trying to quickly move my VBA apps over to C#
Function lastenthandle() As String
Dim entity As AcadObject
Dim count As Variant
' set count to all items in modelspace collection
count = ThisDrawing.ModelSpace.count
Set entity = ThisDrawing.ModelSpace.Item(count - 1)
' check if entity is a block if not count down until it is
While count > 0
If StrComp(entity.EntityName, "AcDbBlockReference", 1) = 0 Then
If entity.HasAttributes Then
lastenthandle = entity.handle
Exit Function
End If
End If
count = count - 1
Set entity = ThisDrawing.ModelSpace.Item(count)
Wend
End Function
Function enttagnam(ByVal Enthandle As String) As String
Dim ourblock As AcadObject
' Get the attributes for the block reference
Dim varAttributes As Variant
Set ourblock = ThisDrawing.HandleToObject(Enthandle)
varAttributes = ourblock.GetAttributes
' Move the attribute tags and values into a string to be displayed in a
Msgbox
Dim strAttributes As String
Dim i As Integer
For i = LBound(varAttributes) To UBound(varAttributes)
If varAttributes(i).TagString = "TAG" Or varAttributes(i).TagString
= "TAG1" Then
enttagnam = varAttributes(i).TextString
'MsgBox "The TAG attribute for blockReference " & ourblock.Name
& " are: " & enttagnam, , "GetAttributes Example"
End If
Next
End Function
Thanks
J.
AutoCAD 2010 64bit