<?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: Insert several blocks with vba in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9491442#M4672</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much it seems to be working ok is it ok to accept this as a solution&lt;/P&gt;</description>
    <pubDate>Mon, 04 May 2020 22:03:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-05-04T22:03:39Z</dc:date>
    <item>
      <title>Insert several blocks with vba</title>
      <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9490374#M4668</link>
      <description>&lt;P&gt;Hi I have this code working ok, but I want to insert several more blocks can anyone help&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim blockObj As AcadBlock&lt;BR /&gt;Dim insertionPnt(0 To 2) As Double&lt;BR /&gt;Dim blockRefObj As AcadBlockReference&lt;BR /&gt;&lt;BR /&gt;' Insert the block&lt;BR /&gt;insertionPnt(0) = Val(TextBox21.Text): insertionPnt(1) = Val(TextBox28.Text): insertionPnt(2) = 0&lt;BR /&gt;Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "T2", 1#, 1#, 1#, 0)&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 15:41:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9490374#M4668</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-04T15:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Insert several blocks with vba</title>
      <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9491006#M4669</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;the question could be stupid but all the same block name and all in the same position ?.&lt;/P&gt;&lt;P&gt;Could be simple to create a loop count with total amount of blocks to insert and repeat insertion command, or if you want to shift you can insert in the loop a coordinate constant shift.&lt;/P&gt;&lt;P&gt;May be so simply ? I guess no.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;insertionPnt(0) = Val(TextBox21.Text): insertionPnt(1) = Val(TextBox28.Text): insertionPnt(2) = 0
For X= 1 to 3 'you can insert a new textbox with amount of blocks
'if you want to shift by X
N=0
insertionPnt(0)=insertionPnt(0)+ N ' shift value
Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "T2", 1#, 1#, 1#, 0)
N=N+5 'VALUE to INCREASE for X coordinate shifting

Next&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 04 May 2020 19:29:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9491006#M4669</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-05-04T19:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Insert several blocks with vba</title>
      <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9491141#M4670</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Apologies for not enough detail, The textboxes are in the userform&amp;nbsp; x and y&amp;nbsp;&lt;/P&gt;&lt;P&gt;The block I am inserting is T2 its the same for each of the insertions but in different positions&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is what I have but not working?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim blockObj As AcadBlock&lt;/P&gt;&lt;P&gt;Dim insertionPnt(0 To &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; As Double&lt;/P&gt;&lt;P&gt;Dim blockRefObj As AcadBlockReference&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;' Insert the blocks&lt;/P&gt;&lt;P&gt;insertionPnt(0) = Val(TextBox20.Text): insertionPnt(1) = Val(TextBox28.Text): insertionPnt(2) = 0&lt;/P&gt;&lt;P&gt;insertionPnt(3) = Val(TextBox21.Text): insertionPnt(4) = Val(TextBox29.Text): insertionPnt(5) = 0&lt;/P&gt;&lt;P&gt;insertionPnt(6) = Val(TextBox22.Text): insertionPnt(7) = Val(TextBox30.Text): insertionPnt(8) =&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "T2", 1#, 1#, 1#, 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help Chris&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 20:16:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9491141#M4670</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-04T20:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Insert several blocks with vba</title>
      <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9491167#M4671</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I guess that the issue is inside the coordinates array because insertblock is expecting an array with 3 points X, Y, and Z, not 7 or eight.&lt;/P&gt;&lt;P&gt;I'll investigate more, however you can put in an array the value of first couple of textbox and third value to 0 if Z coord is 0, insert block, put the second couple and insert block with new coords array name coming from other text box, and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim insertionPnt(0 To 2)&amp;nbsp;As Double
Dim insertionPnt1(0 To 2)&amp;nbsp;As Double
Dim insertionPnt2(0 To 2)&amp;nbsp;As Double
insertionPnt(0) = Val(TextBox20.Text): insertionPnt(1) = Val(TextBox28.Text): insertionPnt(2) = 0

insertionPnt1(0) = Val(TextBox21.Text): insertionPnt1(1) = Val(TextBox29.Text): insertionPnt1(2) = 0

insertionPnt2(0) = Val(TextBox22.Text): insertionPnt2(1) = Val(TextBox30.Text): insertionPnt2(2)=0

Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "T2", 1#, 1#, 1#, 0)

Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt1, "T2", 1#, 1#, 1#, 0)

Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt2, "T2", 1#, 1#, 1#, 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try and let me know&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 20:44:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9491167#M4671</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-05-04T20:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Insert several blocks with vba</title>
      <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9491442#M4672</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much it seems to be working ok is it ok to accept this as a solution&lt;/P&gt;</description>
      <pubDate>Mon, 04 May 2020 22:03:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9491442#M4672</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-04T22:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Insert several blocks with vba</title>
      <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9496734#M4673</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;One thing I have noticed, if there is no entry into text boxes the object T2 is placed in drawing at 0,0&lt;/P&gt;&lt;P&gt;have you any idea how that can happen.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 16:23:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9496734#M4673</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-06T16:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Insert several blocks with vba</title>
      <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9496790#M4674</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;I just show you the method, of course, the insertion point it's 0,0,0 because coming from a numeric conversion of an empty box text value, the array will be 0,0,0 and block will be inserted in that coordinate 0,0,0.&lt;/P&gt;&lt;P&gt;I suggest to insert a command button side each group of coordinates text boxes in the form and insert in own event Sub the insertion block code, checking, &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;BEFORE INSERTING BLOCK,&lt;/STRONG&gt;&lt;/FONT&gt; if coordinates of X and Y are &amp;gt; than 0.&lt;/P&gt;&lt;P&gt;Let me know&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 17:00:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9496790#M4674</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-05-06T17:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Insert several blocks with vba</title>
      <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9496834#M4675</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One thing I have noticed, if there is no entry into text boxes the object T2 is placed in drawing at 0,0&lt;/P&gt;
&lt;P&gt;have you any idea how that can happen.&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What do you expect to happen? Do you want to prevent users from clicking insert when the text box is empty? Give the text box a default value.&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 17:00:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9496834#M4675</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2020-05-06T17:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Insert several blocks with vba</title>
      <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9496901#M4676</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here an example of what I'm saying, you can replicate the code on command button for 2nd block and so on&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Private Sub CommandButton1_Click()
Dim insertionPnt(2) As Double ' this part should be moved inside formload event and declared as Global in order to avoid a ridimension, or use ReDim command.
If UserForm1.TextBox1.Value &amp;lt;&amp;gt; "" Then
    insertionPnt(0) = Val(TextBox1.Text): insertionPnt(1) = Val(TextBox2.Text): insertionPnt(2) = 0
    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "T2", 1#, 1#, 1#, 0)
ElseIf UserForm1.TextBox1.Value = "" Then
    MsgBox "Insert the coordinates Value in TextBox"
End If
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="grobnik_0-1588786273886.png" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/766396i817D973088799CDF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="grobnik_0-1588786273886.png" alt="grobnik_0-1588786273886.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 17:42:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9496901#M4676</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-05-06T17:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: Insert several blocks with vba</title>
      <link>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9496934#M4677</link>
      <description>&lt;P&gt;Hi Thank you very much you have solved the issue for me&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Wed, 06 May 2020 17:49:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/insert-several-blocks-with-vba/m-p/9496934#M4677</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-06T17:49:31Z</dc:date>
    </item>
  </channel>
</rss>

