<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: last block instered example in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/last-block-instered-example/m-p/2598488#M67997</link>
    <description>I think you need to be more specific.&lt;BR /&gt;
&lt;BR /&gt;
The 'last block inserted' when?  In the current session, or&lt;BR /&gt;
in a previous session?&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD&lt;BR /&gt;
Supporting AutoCAD 2000 through 2010&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
&lt;JEFFATICS&gt; wrote in message news:6299037@discussion.autodesk.com...&lt;BR /&gt;
Is there any examples that show how to get the last block inserted and &lt;BR /&gt;
update its attributes using Csharp?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Jeff&lt;/JEFFATICS&gt;</description>
    <pubDate>Fri, 04 Dec 2009 09:17:19 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-12-04T09:17:19Z</dc:date>
    <item>
      <title>last block instered example</title>
      <link>https://forums.autodesk.com/t5/net-forum/last-block-instered-example/m-p/2598487#M67996</link>
      <description>Is there any examples that show how to get the last block inserted and update its attributes using Csharp?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Jeff</description>
      <pubDate>Thu, 03 Dec 2009 20:55:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/last-block-instered-example/m-p/2598487#M67996</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-03T20:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: last block instered example</title>
      <link>https://forums.autodesk.com/t5/net-forum/last-block-instered-example/m-p/2598488#M67997</link>
      <description>I think you need to be more specific.&lt;BR /&gt;
&lt;BR /&gt;
The 'last block inserted' when?  In the current session, or&lt;BR /&gt;
in a previous session?&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD&lt;BR /&gt;
Supporting AutoCAD 2000 through 2010&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
&lt;JEFFATICS&gt; wrote in message news:6299037@discussion.autodesk.com...&lt;BR /&gt;
Is there any examples that show how to get the last block inserted and &lt;BR /&gt;
update its attributes using Csharp?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Jeff&lt;/JEFFATICS&gt;</description>
      <pubDate>Fri, 04 Dec 2009 09:17:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/last-block-instered-example/m-p/2598488#M67997</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-04T09:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: last block instered example</title>
      <link>https://forums.autodesk.com/t5/net-forum/last-block-instered-example/m-p/2598489#M67998</link>
      <description>current session. The block all ready exists somewhere in the system path. &lt;BR /&gt;
&lt;BR /&gt;
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#&lt;BR /&gt;
&lt;BR /&gt;
Function lastenthandle() As String&lt;BR /&gt;
    Dim entity As AcadObject&lt;BR /&gt;
    Dim count As Variant&lt;BR /&gt;
    ' set count to all items in modelspace collection&lt;BR /&gt;
    count = ThisDrawing.ModelSpace.count&lt;BR /&gt;
    Set entity = ThisDrawing.ModelSpace.Item(count - 1)&lt;BR /&gt;
    ' check if entity is a block if not count down until it is&lt;BR /&gt;
    While count &amp;gt; 0&lt;BR /&gt;
    If StrComp(entity.EntityName, "AcDbBlockReference", 1) = 0 Then&lt;BR /&gt;
        If entity.HasAttributes Then&lt;BR /&gt;
            lastenthandle = entity.handle&lt;BR /&gt;
            Exit Function&lt;BR /&gt;
        End If&lt;BR /&gt;
    End If&lt;BR /&gt;
        count = count - 1&lt;BR /&gt;
        Set entity = ThisDrawing.ModelSpace.Item(count)&lt;BR /&gt;
    Wend&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function enttagnam(ByVal Enthandle As String) As String&lt;BR /&gt;
    Dim ourblock As AcadObject&lt;BR /&gt;
   ' Get the attributes for the block reference&lt;BR /&gt;
    Dim varAttributes As Variant&lt;BR /&gt;
    Set ourblock = ThisDrawing.HandleToObject(Enthandle)&lt;BR /&gt;
    varAttributes = ourblock.GetAttributes&lt;BR /&gt;
    ' Move the attribute tags and values into a string to be displayed in a Msgbox&lt;BR /&gt;
    Dim strAttributes As String&lt;BR /&gt;
    Dim i As Integer&lt;BR /&gt;
    For i = LBound(varAttributes) To UBound(varAttributes)&lt;BR /&gt;
        If varAttributes(i).TagString = "TAG" Or varAttributes(i).TagString = "TAG1" Then&lt;BR /&gt;
            enttagnam = varAttributes(i).TextString&lt;BR /&gt;
            'MsgBox "The TAG attribute for blockReference " &amp;amp; ourblock.Name &amp;amp; " are: " &amp;amp; enttagnam, , "GetAttributes Example"&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
J.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
AutoCAD 2010 64bit</description>
      <pubDate>Fri, 04 Dec 2009 12:33:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/last-block-instered-example/m-p/2598489#M67998</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-04T12:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: last block instered example</title>
      <link>https://forums.autodesk.com/t5/net-forum/last-block-instered-example/m-p/2598490#M67999</link>
      <description>I'm afraid this will not work in .NET the way it worked in VBA, mainly &lt;BR /&gt;
because in the managed API, you cannot access items in blocks using numeric &lt;BR /&gt;
indexes.&lt;BR /&gt;
&lt;BR /&gt;
If you are in a hurry to port, my advice would be to use the COM API from C# &lt;BR /&gt;
or VB.NET to do the same thing you were doing in VBA.&lt;BR /&gt;
&lt;BR /&gt;
You can do the other part in managed code by getting the managed wrapper for &lt;BR /&gt;
the AcadBlockReference COM object using the DBObject.FromAcadObject() static &lt;BR /&gt;
method .&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD&lt;BR /&gt;
Supporting AutoCAD 2000 through 2010&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
&lt;JEFFATICS&gt; wrote in message news:6299383@discussion.autodesk.com...&lt;BR /&gt;
current session. The block all ready exists somewhere in the system path.&lt;BR /&gt;
&lt;BR /&gt;
I found these examples in VBA which I currently use but do to the lack of a &lt;BR /&gt;
VBA interface in 2010 I am trying to quickly move my VBA apps over to C#&lt;BR /&gt;
&lt;BR /&gt;
Function lastenthandle() As String&lt;BR /&gt;
    Dim entity As AcadObject&lt;BR /&gt;
    Dim count As Variant&lt;BR /&gt;
    ' set count to all items in modelspace collection&lt;BR /&gt;
    count = ThisDrawing.ModelSpace.count&lt;BR /&gt;
    Set entity = ThisDrawing.ModelSpace.Item(count - 1)&lt;BR /&gt;
    ' check if entity is a block if not count down until it is&lt;BR /&gt;
    While count &amp;gt; 0&lt;BR /&gt;
    If StrComp(entity.EntityName, "AcDbBlockReference", 1) = 0 Then&lt;BR /&gt;
        If entity.HasAttributes Then&lt;BR /&gt;
            lastenthandle = entity.handle&lt;BR /&gt;
            Exit Function&lt;BR /&gt;
        End If&lt;BR /&gt;
    End If&lt;BR /&gt;
        count = count - 1&lt;BR /&gt;
        Set entity = ThisDrawing.ModelSpace.Item(count)&lt;BR /&gt;
    Wend&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function enttagnam(ByVal Enthandle As String) As String&lt;BR /&gt;
    Dim ourblock As AcadObject&lt;BR /&gt;
   ' Get the attributes for the block reference&lt;BR /&gt;
    Dim varAttributes As Variant&lt;BR /&gt;
    Set ourblock = ThisDrawing.HandleToObject(Enthandle)&lt;BR /&gt;
    varAttributes = ourblock.GetAttributes&lt;BR /&gt;
    ' Move the attribute tags and values into a string to be displayed in a &lt;BR /&gt;
Msgbox&lt;BR /&gt;
    Dim strAttributes As String&lt;BR /&gt;
    Dim i As Integer&lt;BR /&gt;
    For i = LBound(varAttributes) To UBound(varAttributes)&lt;BR /&gt;
        If varAttributes(i).TagString = "TAG" Or varAttributes(i).TagString &lt;BR /&gt;
= "TAG1" Then&lt;BR /&gt;
            enttagnam = varAttributes(i).TextString&lt;BR /&gt;
            'MsgBox "The TAG attribute for blockReference " &amp;amp; ourblock.Name &lt;BR /&gt;
&amp;amp; " are: " &amp;amp; enttagnam, , "GetAttributes Example"&lt;BR /&gt;
        End If&lt;BR /&gt;
    Next&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
J.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
AutoCAD 2010 64bit&lt;/JEFFATICS&gt;</description>
      <pubDate>Fri, 04 Dec 2009 17:24:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/last-block-instered-example/m-p/2598490#M67999</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-12-04T17:24:05Z</dc:date>
    </item>
  </channel>
</rss>

