<?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: Additem Q in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/additem-q/m-p/8805476#M5525</link>
    <description>&lt;P&gt;sorry , next time will use&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;button "&amp;lt;/&amp;gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am first&amp;nbsp; time on customasation vba&amp;nbsp; forum&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You was right it was the only reason the array.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;now it works , Thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;VBA is the way i used to...so that why.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 21 May 2019 17:57:00 GMT</pubDate>
    <dc:creator>brian_adams</dc:creator>
    <dc:date>2019-05-21T17:57:00Z</dc:date>
    <item>
      <title>Additem Q</title>
      <link>https://forums.autodesk.com/t5/vba-forum/additem-q/m-p/8803134#M5522</link>
      <description>&lt;P&gt;&amp;nbsp;I know that I missed something.&lt;/P&gt;
&lt;P&gt;but I can't understand what exactly....&lt;/P&gt;
&lt;P&gt;I need to add only one Aecwall to selection set&lt;/P&gt;
&lt;P&gt;I do selectAll and then filter it with&amp;nbsp; " if ... then" statment&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I checked , the macro do finde the object I needed, but it can't add i to selection set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;first method i did&lt;/P&gt;
&lt;P&gt;Set ssobjs(I) = ThisDrawing.ObjectIdToObject(ObjectID1)&lt;/P&gt;
&lt;P&gt;second method i did&lt;/P&gt;
&lt;P&gt;Set ssobjs(I) = ThisDrawing.ModelSpace.Item(I)&lt;/P&gt;
&lt;P&gt;both don't works&lt;/P&gt;
&lt;P&gt;what is wrong??&amp;nbsp; will be appreciate for help&lt;/P&gt;
&lt;P&gt;________________________________________________&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sub test select()&lt;BR /&gt;Dim ent As AcadEntity&lt;BR /&gt;Dim ssetObj As AcadSelectionSet&lt;BR /&gt;Dim I As Integer&lt;BR /&gt;Dim G As Integer&lt;/P&gt;
&lt;P&gt;For Each ent In ThisDrawing.ModelSpace&lt;BR /&gt;&lt;BR /&gt;Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_SELECTIONSET1715")&lt;BR /&gt;G = 0&lt;BR /&gt;ssetObj.Select acSelectionSetAll&lt;BR /&gt;G = ssetObj.Count&lt;BR /&gt;ObjectID1 = ent.ObjectID&lt;BR /&gt;'MsgBox ObjectID1&lt;BR /&gt;ReDim ssobjs(0 To G - 1) As AcadEntity&lt;BR /&gt;For I = 1 To G - 1&lt;BR /&gt;If ssetObj.Item(I).ObjectID = ObjectID1 And ssetObj.Item(I).ObjectName = "AecDbWall" Then&lt;BR /&gt;Set ssobjs(I) = ThisDrawing.ModelSpace.Item(I)&lt;BR /&gt;MsgBox "ok"&lt;BR /&gt;&lt;BR /&gt;'MsgBox X&lt;BR /&gt;Else&lt;BR /&gt;'MsgBox ssetObj.Item(I).ObjectName &amp;amp; " " &amp;amp; ssetObj.Item(I).ObjectID&lt;BR /&gt;End If&lt;BR /&gt;Next I&lt;BR /&gt;'MsgBox ssobjs(0).ObjectID &amp;amp; " "&lt;BR /&gt;ssetObj.Clear&lt;BR /&gt;ssetObj.AddItems ssobjs&lt;BR /&gt;&lt;BR /&gt;ThisDrawing.SendCommand "Select p " &amp;amp; vbCrLf&lt;BR /&gt;ThisDrawing.SendCommand "Materiallist" &amp;amp; vbCr &amp;amp; vbCr&lt;BR /&gt;MsgBox ssetObj.Count&lt;BR /&gt;&lt;BR /&gt;ThisDrawing.SelectionSets("TEST_SELECTIONSET1715").Delete&lt;BR /&gt;Next&lt;BR /&gt;ssetObj.Clear&lt;BR /&gt;End Sub&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 21:44:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/additem-q/m-p/8803134#M5522</guid>
      <dc:creator>brian_adams</dc:creator>
      <dc:date>2019-05-20T21:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Additem Q</title>
      <link>https://forums.autodesk.com/t5/vba-forum/additem-q/m-p/8803145#M5523</link>
      <description>&lt;P&gt;that is problem part but why?&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 21:47:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/additem-q/m-p/8803145#M5523</guid>
      <dc:creator>brian_adams</dc:creator>
      <dc:date>2019-05-20T21:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Additem Q</title>
      <link>https://forums.autodesk.com/t5/vba-forum/additem-q/m-p/8805031#M5524</link>
      <description>&lt;P&gt;Firstly, please post your code using the toolbar button "&amp;lt;/&amp;gt;" so that the code would be displayed in read-able format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, as for the error you get from code &lt;STRONG&gt;&lt;EM&gt;ssetObj.AddItems ssobjs&lt;/EM&gt;&lt;/STRONG&gt;, I think the problem is due to how you fill up the element in the AcadEntity array (&lt;EM&gt;ssobjs&lt;/EM&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code snippet of inner loop where you fill up the AcadEntity array:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ReDim ssobjs(0 To G - 1) As AcadEntity
For I = 1 To G - 1
  If ssetObj.Item(I).ObjectID = ObjectID1 And ssetObj.Item(I).ObjectName = "AecDbWall" Then
    Set ssobjs(I) = ThisDrawing.ModelSpace.Item(I)
    MsgBox "ok"
  Else
    'MsgBox ssetObj.Item(I).ObjectName &amp;amp; " " &amp;amp; ssetObj.Item(I).ObjectID
  End If
Next I&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, you declared the array ssobjs with given element count (the count of all select-able items in a drawing, assume,it is 100). Then in the "For... Next I" loop, you ONLY fill up the array partially because of the "If...Then..." statement. That is, you have an array with 100 element declared, but only fill up 1 element due to the "If...Then..." statement (the rest 99 element are left empty)! After the "For ... Next I" loop, your code tries to add this partially filled array to the selectionset, THUS, the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My understanding is that you need a selectionset with one item in it, so that you can pass the selection set to SendCommand().&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code can be modified/simplified this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Sub test select()

    Dim ent As AcadEntity
    Dim ssetObj As AcadSelectionSet
    Dim ssObjs() As AcadEntity
    Dim I As Integer
    Dim G As Integer

    For Each ent In ThisDrawing.ModelSpace
        '' You only need to to work for each "AecDbWall"
	If UCase(ent.ObjectName)="AECDBWALL" THEN

            ReDim ssObjs(0)
            Set ssobjs(0)=ent
            
            '' Create a selection set and select all, then clear it
            '' So that AutoCAD remembers "Previous" selection set
            Set ssetObj = ThisDrawing.SelectionSets.Add("TEST_SELECTIONSET1715") 
            ssetObj.Select acSelectionSetAll
            ssetobj.Clear

            ssetObj.AddItems ssobjs
&lt;BR /&gt;            '' These following SendCommand() calls would be problematic&lt;BR /&gt;            '' If they work, it would be lucky :-(
            ThisDrawing.SendCommand "Select p " &amp;amp; vbCrLf
	    ThisDrawing.SendCommand "Materiallist" &amp;amp; vbCr &amp;amp; vbCr

            ThisDrawing.SelectionSets("TEST_SELECTIONSET1715").Delete

  	End If
    Next

End Sub&lt;/PRE&gt;
&lt;P&gt;HOWEVER, while this code I showed here would solve the issue with AcadSelectionSet.AddItems(), the entire process would likely not work because of calling SendCommand(0 in the "For..." loop: AutoCAD would/might execute the command called by SendCommand() asynchly, you may only get the last AecDbWall entity's information displayed, or no AecDbWall entity information displayed at all (because when the command "MaterialList" is sent to AutoCAD, the selection set ccreated by your code might have been deleted already.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume you are using AutoCAD Architecture. You should really use Archtecture's COM API to retrieve AecDbWall entity's information, instead of trying to get it from command line based on built-in command (well, I do not use AutoCAD Architecture, thus have no idea if there are COM APIs available that can be used in AutoCAD VBA. But I'd be very surprised if there is no COM API available, and if so, I'd not waste time in VBA at all).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 15:18:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/additem-q/m-p/8805031#M5524</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2019-05-21T15:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Additem Q</title>
      <link>https://forums.autodesk.com/t5/vba-forum/additem-q/m-p/8805476#M5525</link>
      <description>&lt;P&gt;sorry , next time will use&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;button "&amp;lt;/&amp;gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am first&amp;nbsp; time on customasation vba&amp;nbsp; forum&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You was right it was the only reason the array.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;now it works , Thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;VBA is the way i used to...so that why.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2019 17:57:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/additem-q/m-p/8805476#M5525</guid>
      <dc:creator>brian_adams</dc:creator>
      <dc:date>2019-05-21T17:57:00Z</dc:date>
    </item>
  </channel>
</rss>

