<?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 Stuck on a drawing border question in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222435#M47081</link>
    <description>I am trying to change the text in a drawing border but I am having a little trouble.&lt;BR /&gt;
&lt;BR /&gt;
I am trying to use and convert code from a text book example that I have.&lt;BR /&gt;
&lt;BR /&gt;
For Each elem In ThisDrawing.PaperSpace&lt;BR /&gt;
If elem.EntityName = "AcDbBlockReference" Then&lt;BR /&gt;
If elem.Name = "Part_Number" Then&lt;BR /&gt;
foundAttributes = True&lt;BR /&gt;
Array1 = elem.GetAttributes&lt;BR /&gt;
&lt;BR /&gt;
I have looked at sample drawing this code works on but I cannot link the name AcDbBlockReference" with anything - can anyone help me out.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Ian</description>
    <pubDate>Wed, 12 Jan 2005 19:25:02 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2005-01-12T19:25:02Z</dc:date>
    <item>
      <title>Stuck on a drawing border question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222435#M47081</link>
      <description>I am trying to change the text in a drawing border but I am having a little trouble.&lt;BR /&gt;
&lt;BR /&gt;
I am trying to use and convert code from a text book example that I have.&lt;BR /&gt;
&lt;BR /&gt;
For Each elem In ThisDrawing.PaperSpace&lt;BR /&gt;
If elem.EntityName = "AcDbBlockReference" Then&lt;BR /&gt;
If elem.Name = "Part_Number" Then&lt;BR /&gt;
foundAttributes = True&lt;BR /&gt;
Array1 = elem.GetAttributes&lt;BR /&gt;
&lt;BR /&gt;
I have looked at sample drawing this code works on but I cannot link the name AcDbBlockReference" with anything - can anyone help me out.&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;BR /&gt;
Ian</description>
      <pubDate>Wed, 12 Jan 2005 19:25:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222435#M47081</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-01-12T19:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on a drawing border question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222436#M47082</link>
      <description>First things first.

Are you trying to modify the actual text value of an attribute within a 
block?

If so, you need to find the block, first.  Once you have that, if I remember 
correctly, you have to go through the two arrays (tag name/value name) and 
find the attribute tag you are trying to change.

"montyzoomer" &lt;NOSPAM&gt; wrote in message 
news:15850515.1105557932938.JavaMail.jive@jiveforum2.autodesk.com...
&amp;gt;I am trying to change the text in a drawing border but I am having a little 
&amp;gt;trouble.
&amp;gt;
&amp;gt; I am trying to use and convert code from a text book example that I have.
&amp;gt;
&amp;gt; For Each elem In ThisDrawing.PaperSpace
&amp;gt; If elem.EntityName = "AcDbBlockReference" Then
&amp;gt; If elem.Name = "Part_Number" Then
&amp;gt; foundAttributes = True
&amp;gt; Array1 = elem.GetAttributes
&amp;gt;
&amp;gt; I have looked at sample drawing this code works on but I cannot link the 
&amp;gt; name AcDbBlockReference" with anything - can anyone help me out.
&amp;gt;
&amp;gt; Thanks
&amp;gt;
&amp;gt; Ian&lt;/NOSPAM&gt;</description>
      <pubDate>Wed, 12 Jan 2005 20:04:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222436#M47082</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-01-12T20:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on a drawing border question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222437#M47083</link>
      <description>Tom&lt;BR /&gt;
&lt;BR /&gt;
Yes I need to change the text value of the attribute within the block.&lt;BR /&gt;
&lt;BR /&gt;
If I look at the sample and list the info of the block, I cannot see the reference name listed in the code yet it seems to be using the reference to find the block.&lt;BR /&gt;
&lt;BR /&gt;
I'm confused</description>
      <pubDate>Wed, 12 Jan 2005 20:38:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222437#M47083</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-01-12T20:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on a drawing border question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222438#M47084</link>
      <description>&lt;SNIPPED&gt;
&amp;gt; I'm confused

I understand your confusion, believe me. ;)

Please be aware that I'm not a VBA whiz, and take note of any posts critical 
of anything in the code I post.  I can tell you that the snippets I'm 
posting work well, in our company's circumstances.  These were written 
specifically for use here and most likely would need some amount of 
modification for your use.

For finding the title block BLOCK, I use the following (note that this is a 
snippet from a routine that goes to each layout being plotted and retrieves 
information for storage in a database, no modifcation of the values was 
required.)

Function GetTitleBlockInfo() As Variant
'========================================================================
Dim sTitle1 As String, sTitle2 As String, sTitle3 As String
Dim sDwgNum As String
Dim vRet(3) As Variant
Dim oLayout As AcadLayout, oLayBlock As AcadBlock
Dim oEnt As AcadEntity
Dim oBlkRef As AcadBlockReference
  Set oLayout = ThisDrawing.ActiveLayout
  Set oLayBlock = oLayout.Block

  For Each oEnt In oLayBlock
    If oEnt.ObjectName = "AcDbBlockReference" Then
      Set oBlkRef = oEnt
      Select Case oBlkRef.Name
        Case "cectb30x42sd", "cectb24x36sd"
          sTitle1 = GetAttTxtStr("TITLE_LINE_1", oBlkRef)
          sTitle2 = GetAttTxtStr("TITLE_LINE_2", oBlkRef)
          sTitle3 = GetAttTxtStr("TITLE_LINE_3", oBlkRef)
          sDwgNum = GetAttTxtStr("PROJ_NO", oBlkRef) &amp;amp; "-" &amp;amp; _
                    GetAttTxtStr("DWG_NO", oBlkRef)
          GoTo ValuesObtained
        Case "30x42 Title", "30-42 Title Block", "24x36 Title Block", _
             "Cec Title Block", "30-42_TITLE"
          sTitle1 = GetAttTxtStr("TITLE_1", oBlkRef)
          sTitle2 = GetAttTxtStr("TITLE_2", oBlkRef)
          sTitle3 = GetAttTxtStr("TITLE_3", oBlkRef)
          sDwgNum = GetAttTxtStr("DWG_NO", oBlkRef)
          GoTo ValuesObtained
        Case Else
          sTitle1 = "": sTitle2 = "": sTitle3 = ""
          sDwgNum = "000000"
      End Select
    End If
  Next oEnt
ValuesObtained:
  Set oBlkRef = Nothing
  Set oLayBlock = Nothing
  Set oLayout = Nothing
  vRet(0) = sTitle1: vRet(1) = sTitle2: vRet(2) = sTitle3
  vRet(3) = sDwgNum
  GetTitleBlockInfo = vRet
End Function

The GetAttTxtStr function used in the above code is as follows:

Function GetAttTxtStr(sTagString As String, oBlkRef As AcadBlockReference) 
As String
Dim vAttArr As Variant
Dim iAttCnt As Integer
Dim sRet As String
  sRet = ""
  If Not oBlkRef.HasAttributes Then GetAttTxtStr = sRet: Exit Function
  vAttArr = oBlkRef.GetAttributes
  For iAttCnt = 0 To UBound(vAttArr)
    If vAttArr(iAttCnt).TagString = sTagString Then
      GetAttTxtStr = vAttArr(iAttCnt).TextString
      Exit Function
    End If
  Next
  GetAttTxtStr = sRet
End Function

Again, a side note:  The GetAttTxtStr could certainly use some tweaks, but 
it works for here, so I didn't take it any further.  It DOES have some 
potential problems, though.

Hope that helps as opposed to hindering your grasp of the topic.&lt;/SNIPPED&gt;</description>
      <pubDate>Wed, 12 Jan 2005 20:59:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222438#M47084</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-01-12T20:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on a drawing border question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222439#M47085</link>
      <description>Hi Ian

Rather than looping thru all entities you would be better of creating a 
selection set and filtering for blocks called "Part_Number" in paperspace.
You can then loop thru the selection set and access the attributes

Something like this...

Sub SelectBlocks()
'===========================================
    Dim ss As AcadSelectionSet
    Dim gpCode(1) As Integer
    Dim dataValue(1) As Variant
    Dim groupCode As Variant
    Dim dataCode As Variant
    Dim Blk As AcadBlockReference
    Dim Atts As Variant
    Dim i As Integer

    'filter for blocks where name = "PART_NAME"
    gpCode(0) = 2:    dataValue(0) = "PART_NAME"
    'filter for entities in paperspace
    gpCode(1) = 67:   dataValue(1) = 1

    'assign filters to variant datatypes
    groupCode = gpCode
    dataCode = dataValue

    'add selectionset to selectionsets collection
    Set ss = ThisDrawing.SelectionSets.Add("SS_SelectBlocks")

    'select all entities and apply filter
    ss.Select acSelectionSetAll, , , groupCode, dataCode

    'loop thru selection set
    For Each Blk In ss
        'check if block has attributes
        If Blk.HasAttributes Then
            'assign attributes to variant datatype
            Atts = Blk.GetAttributes
            'loop thru attributes
            For i = 0 To UBound(Atts)
                Debug.Print Atts(i).TagString &amp;amp; ": " &amp;amp; Atts(i).TextString
            Next i
        End If
    Next Blk

    'delete selectionset from selectionsets collection
    ss.Delete

End Sub
'================================================

-- 
Regards
Tom Roberts
__________________________
MechWest Design &amp;amp; Drafting
Perth, Western Australia


"montyzoomer" &lt;NOSPAM&gt; wrote in message 
news:15850515.1105557932938.JavaMail.jive@jiveforum2.autodesk.com...
&amp;gt;I am trying to change the text in a drawing border but I am having a little 
&amp;gt;trouble.
&amp;gt;
&amp;gt; I am trying to use and convert code from a text book example that I have.
&amp;gt;
&amp;gt; For Each elem In ThisDrawing.PaperSpace
&amp;gt; If elem.EntityName = "AcDbBlockReference" Then
&amp;gt; If elem.Name = "Part_Number" Then
&amp;gt; foundAttributes = True
&amp;gt; Array1 = elem.GetAttributes
&amp;gt;
&amp;gt; I have looked at sample drawing this code works on but I cannot link the 
&amp;gt; name AcDbBlockReference" with anything - can anyone help me out.
&amp;gt;
&amp;gt; Thanks
&amp;gt;
&amp;gt; Ian&lt;/NOSPAM&gt;</description>
      <pubDate>Thu, 13 Jan 2005 01:31:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222439#M47085</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-01-13T01:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on a drawing border question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222440#M47086</link>
      <description>Thanks for that I will work through it to solve my code problem. &lt;BR /&gt;
&lt;BR /&gt;
I am very impressed how helpful people are on the forum.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
Ian</description>
      <pubDate>Thu, 13 Jan 2005 08:11:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222440#M47086</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-01-13T08:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on a drawing border question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222441#M47087</link>
      <description>Actually, if most of the entities reside in model space, then it may be
faster to iterate just the entities on the layout.  And it makes for much
nicer code to boot.
-- 
Bobby C. Jones

"Tom Roberts" &lt;NOSPAM&gt; wrote in message
news:41e5cf76$1_3@newsprd01...
&amp;gt; Hi Ian
&amp;gt;
&amp;gt; Rather than looping thru all entities you would be better of creating a
&amp;gt; selection set and filtering for blocks called "Part_Number" in paperspace.
&amp;gt; You can then loop thru the selection set and access the attributes&lt;/NOSPAM&gt;</description>
      <pubDate>Thu, 13 Jan 2005 15:16:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222441#M47087</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-01-13T15:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on a drawing border question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222442#M47088</link>
      <description>Tom&lt;BR /&gt;
&lt;BR /&gt;
Any chance you could drop me a mail, I'd like to send you a border example that needs to be changed for your comments.&lt;BR /&gt;
&lt;BR /&gt;
My address is&lt;BR /&gt;
&lt;BR /&gt;
ian@bie.co.uk&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 13 Jan 2005 20:23:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222442#M47088</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-01-13T20:23:10Z</dc:date>
    </item>
    <item>
      <title>Re: Stuck on a drawing border question</title>
      <link>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222443#M47089</link>
      <description>TomD&lt;BR /&gt;
&lt;BR /&gt;
Me Again !!!&lt;BR /&gt;
&lt;BR /&gt;
You code seems to make sense until I reach Case "cectb30x42sd", "cectb24x36sd"&lt;BR /&gt;
&lt;BR /&gt;
What does  this represent, I would appreciate it if you could drop me a mail at&lt;BR /&gt;
&lt;BR /&gt;
ian@bie.co.uk&lt;BR /&gt;
&lt;BR /&gt;
I would like to ask a couple more questions if you don't mind. &lt;BR /&gt;
&lt;BR /&gt;
I feel like I am starting to get some where at last&lt;BR /&gt;
&lt;BR /&gt;
Regards&lt;BR /&gt;
&lt;BR /&gt;
Ian</description>
      <pubDate>Thu, 13 Jan 2005 20:44:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/stuck-on-a-drawing-border-question/m-p/1222443#M47089</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-01-13T20:44:27Z</dc:date>
    </item>
  </channel>
</rss>

