<?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: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9774047#M4076</link>
    <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I suggest to scan the cell in the Table, before writing LAYER NAME value inside, and check if the cella value (layer name) exist, If it already exist increase the count of existing object's layer, if not, write a new row with layer name and count for next object inspection in the selection.&lt;/P&gt;&lt;P&gt;The amount of row could be determinate by count of not duplicated object's layer.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 10:01:30 GMT</pubDate>
    <dc:creator>grobnik</dc:creator>
    <dc:date>2020-09-29T10:01:30Z</dc:date>
    <item>
      <title>How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9773975#M4075</link>
      <description>&lt;P&gt;Good Day, I have codes that computes a total length and tabulates it in table, however I keep getting duplicate layer names. How do I filter/remove the duplicates.&lt;/P&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="output.jpg" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/824974i1A04FD337899D05B/image-size/large?v=v2&amp;amp;px=999" role="button" title="output.jpg" alt="output.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Private Sub COMPUTE_Click()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim ASelSet As AcadSelectionSet&lt;BR /&gt;Dim FilterType(1) As Integer&lt;BR /&gt;Dim FilterData(1) As Variant&lt;BR /&gt;&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;Set ASelSet = ThisDrawing.SelectionSets.Add("SS")&lt;BR /&gt;FilterType(0) = 0&lt;BR /&gt;FilterData(0) = "LINE"&lt;BR /&gt;FilterType(1) = 8&lt;BR /&gt;FilterData(1) = "Yellow,Red,Cyan,Green,Blue,ORANGE"&lt;BR /&gt;If Err.Number &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;Set ASelSet = ThisDrawing.SelectionSets.Item("SS")&lt;BR /&gt;FilterType(0) = 0&lt;BR /&gt;FilterData(0) = "LINE"&lt;BR /&gt;FilterType(1) = 8&lt;BR /&gt;FilterData(1) = "Yellow,Red,Cyan,Green,Blue,ORANGE"&lt;BR /&gt;End If&lt;BR /&gt;ASelSet.Clear&lt;BR /&gt;ASelSet.SelectOnScreen FilterType, FilterData&lt;BR /&gt;&lt;BR /&gt;Dim SelInsPoint As Variant&lt;BR /&gt;SelInsPoint = ThisDrawing.Utility.GetPoint(, "Select Insertion Point of Table: ")&lt;/P&gt;&lt;P&gt;Dim LayName() As Variant&lt;BR /&gt;Dim LayersX As AcadLayers&lt;BR /&gt;Dim LayerX As AcadLayer&lt;BR /&gt;Dim LayCount As Integer&lt;BR /&gt;&lt;BR /&gt;Set LayersX = ThisDrawing.LAYERS&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; '----&amp;gt; these part gives my table many blanks, it count the total layers&lt;BR /&gt;LayCount = LayersX.count&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'----&amp;gt; how do I count the layer of my selection objects only?&lt;BR /&gt;&lt;BR /&gt;Dim MyModelSpace As AcadModelSpace&lt;BR /&gt;Set MyModelSpace = ThisDrawing.ModelSpace&lt;/P&gt;&lt;P&gt;Dim MyTableLinear As AcadTable&lt;BR /&gt;Set MyTableLinear = MyModelSpace.AddTable(SelInsPoint, LayCount, 2, 500, 8000)&lt;/P&gt;&lt;P&gt;MyTableLinear.SetCellValue 0, 0, "LINEAR"&lt;BR /&gt;MyTableLinear.SetCellValue 1, 0, "LAYERS"&lt;BR /&gt;MyTableLinear.SetCellValue 1, 1, "LENGTH"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim OBJECT As AcadObject&lt;BR /&gt;Dim Row As Integer&lt;BR /&gt;Row = 2&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For Each OBJECT In ASelSet&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; '----&amp;gt; these parts gives me the duplicate layer names&lt;BR /&gt;MyTableLinear.SetCellValue Row, 0, OBJECT.Layer&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'----&amp;gt; when I select all the items/objects/entity that&lt;BR /&gt;Row = Row + 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;'----&amp;gt; I want to compute, each object layer populate in Table&lt;BR /&gt;Next&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; '----&amp;gt;I want to remove the duplicates&lt;BR /&gt;&lt;BR /&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:24:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9773975#M4075</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-29T09:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9774047#M4076</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I suggest to scan the cell in the Table, before writing LAYER NAME value inside, and check if the cella value (layer name) exist, If it already exist increase the count of existing object's layer, if not, write a new row with layer name and count for next object inspection in the selection.&lt;/P&gt;&lt;P&gt;The amount of row could be determinate by count of not duplicated object's layer.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:01:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9774047#M4076</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-09-29T10:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9774061#M4077</link>
      <description>&lt;P&gt;@&amp;nbsp;&lt;SPAN class="UserName lia-user-name lia-user-rank-Advocate lia-component-message-view-widget-author-username"&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/472256" target="_self"&gt;&lt;SPAN class=""&gt;grobnik&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks for feedback sir, but do you mind giving me sample of codes for scanning/checking. I'm still new to vba autocad. Thanks again&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:12:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9774061#M4077</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-29T10:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9775015#M4078</link>
      <description>&lt;P&gt;here attached the code and sample drawing with lines on different layers, and different lengths, just to test the total lengths.&lt;/P&gt;&lt;P&gt;I added also the object count per each layer, not shown in the table.&lt;/P&gt;&lt;P&gt;Table will have fixed number of rows and columns (I didn't any modification on this part) but it's easy to do.&lt;/P&gt;&lt;P&gt;See the code and let us know&lt;/P&gt;&lt;P&gt;If you want to add more layers, duplicate the variable declaration and code structure.&lt;/P&gt;&lt;P&gt;Several time ago I already sent you a procedure like this.... I'll check.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dim OBJECT As AcadObject
Dim CountObJYell As Integer
Dim CountObJRed As Integer
Dim CountObJCyan As Integer
Dim CountObJGreen As Integer
Dim CountObJBlue As Integer
Dim CountObJORANGE As Integer
 CountObJYell = 0
 CountObJRed = 0
 CountObJCyan = 0
 CountObJGreen = 0
 CountObJBlue = 0
 CountObJORANGE = 0
Dim ToTLengthObjYell As Long
Dim ToTLengthObjRed As Long
Dim ToTLengthObjCyan As Long
Dim ToTLengthObjGreen As Long
Dim ToTLengthObjBlue As Long
Dim ToTLengthObjORANGE As Long


'Dim Row As Integer
'Row = 2

'Yellow,Red,Cyan,Green,Blue,ORANGE
For Each OBJECT In ASelSet                                                  '----&amp;gt; these parts gives me the duplicate layer names
Select Case OBJECT.Layer

Case "Yellow"
    CountObJYell = CountObJYell + 1
    MyTableLinear.SetCellValue 2, 0, OBJECT.Layer
    ToTLengthObjYell = ToTLengthObjYell + OBJECT.Length
    MyTableLinear.SetCellValue 2, 1, ToTLengthObjYell

Case "Red"
    CountObJRed = CountObJRed + 1
    MyTableLinear.SetCellValue 3, 0, OBJECT.Layer
    ToTLengthObjRed = ToTLengthObjRed + OBJECT.Length
    MyTableLinear.SetCellValue 3, 1, ToTLengthObjRed

Case "Cyan"
    CountObJCyan = CountObJCyan + 1
    MyTableLinear.SetCellValue 4, 0, OBJECT.Layer
    ToTLengthObjCyan = ToTLengthObjCyan + OBJECT.Length
    MyTableLinear.SetCellValue 4, 1, ToTLengthObjCyan

Case "Green"
    CountObJGreen = CountObJGreen + 1
    MyTableLinear.SetCellValue 5, 0, OBJECT.Layer
    ToTLengthObjGreen = ToTLengthObjGreen + OBJECT.Length
    MyTableLinear.SetCellValue 5, 1, ToTLengthObjGreen

Case "Blue"
    CountObJBlue = CountObJBlue + 1
    MyTableLinear.SetCellValue 6, 0, OBJECT.Layer
    ToTLengthObjBlue = ToTLengthObjBlue + OBJECT.Length
    MyTableLinear.SetCellValue 6, 1, ToTLengthObjBlue

Case "ORANGE"
    CountObJORANGE = CountObJORANGE + 1
    MyTableLinear.SetCellValue 7, 0, OBJECT.Layer
    ToTLengthObjORANGE = ToTLengthObjORANGE + OBJECT.Length
    MyTableLinear.SetCellValue 7, 1, ToTLengthObjORANGE

End Select

Next         '----&amp;gt;I want to remove the duplicates

End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bye&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:49:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9775015#M4078</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-09-29T17:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9775792#M4079</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/472256"&gt;@grobnik&lt;/a&gt;&amp;nbsp; thanks, here's what I got sir :&amp;nbsp;&lt;/P&gt;&lt;P&gt;1st table gives me blanks if I only pick what I need to compute (I still don't know how to remove all the blanks till bottom)&lt;/P&gt;&lt;P&gt;2nd table doesn't compute the&amp;nbsp;other shapes (circle.circumference , arc.ArcLength)&lt;/P&gt;&lt;P&gt;my other concerns is: I have too many lines/shapes with different layer names each (mostly around 100 layers)&lt;/P&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="Untitled1.jpg" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/825349i7B3495E242E4785E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled1.jpg" alt="Untitled1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the codes you gave me from my other post are very handful. I was able to learn and apply most of it. However, I really need to use SELECTIONSET and just tabulate the needed layer names per groupings of calculations.&lt;/P&gt;&lt;P&gt;Thanks again sir.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:43:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9775792#M4079</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-30T04:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9775827#M4080</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not understand, now you are showing and talking about &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;2&lt;/STRONG&gt; &lt;/FONT&gt;tables &lt;U&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;instead 1 of previous message.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;The last code I gave you yesterday it's working, for empty space in the table you have to define the number of row before inserting it. Of course the objects which I drawn are Line, because you indicated LINE in your selection set filter. If you need something else you have refine your selection set adding with AND or OR logic function all other objects you need to select.&lt;/P&gt;&lt;P&gt;You already know the amount of layer which do you want to select by selection set, so you can fix before inserting the table object in the drawing the row, and the columns.&lt;/P&gt;&lt;P&gt;For the separate table, with amount of object per each layer, and empty rows, I guess the objects are not only LINE because I tried with increasing the first table with a 3rd column including the amount of objects per layer and it's working (see image below).&lt;/P&gt;&lt;P&gt;I used this code with placing a comment on your one (I just replaced the LayCount with a fixed number):&lt;/P&gt;&lt;LI-CODE lang="general"&gt;'Set MyTableLinear = MyModelSpace.AddTable(SelInsPoint, LayCount, 2, 500, 8000)
Set MyTableLinear = MyModelSpace.AddTable(SelInsPoint, 7, 3, 500, 8000)&lt;/LI-CODE&gt;&lt;P&gt;As you can see, I created a Table of only 7 rows, and 3 columns (3rd column for total amount of objects per each layer)&lt;/P&gt;&lt;P&gt;I didn't use the LayCount variable, because it's contains all drawing layers, instead only ones you selected in Filterdata for SelectionSet.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;&amp;nbsp;FilterData(1) = "Yellow,Red,Cyan,Green,Blue,ORANGE"&lt;/LI-CODE&gt;&lt;P&gt;So the main issue, for amount count will be that objects your are counting are not only LINE, so due to has been assigned one fixed row per each layer, means that you are counting something else. See below picture, attached dwg and code here attached again.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="grobnik_0-1601444014853.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/825360i17CF9150AEF48ABF/image-size/large?v=v2&amp;amp;px=999" role="button" title="grobnik_0-1601444014853.png" alt="grobnik_0-1601444014853.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'll try to create a second Table only for Objects Count.&lt;/P&gt;&lt;P&gt;Bye&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:46:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9775827#M4080</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-09-30T05:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9775986#M4081</link>
      <description>&lt;DIV class="lia-message-author-with-avatar"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Advocate lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/472256"&gt;@grobnik&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-message-author-with-avatar"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Advocate lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;thanks, I got the arc/circumference by adding&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-message-author-with-avatar"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Advocate lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;FilterData(0) = "LINE,POLYLINE,LWPOLYLINE,ARC,CIRCLE,ELLIPSE,SPLINE"&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-message-author-with-avatar"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-message-author-with-avatar"&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Advocate lia-component-message-view-widget-author-username"&gt;&lt;SPAN class=""&gt;ToTLengthObjCyan = ToTLengthObjCyan + OBJECT.ArcLength&lt;BR /&gt;ToTLengthObjCyan = ToTLengthObjCyan + OBJECT.Circumference&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled3.jpg" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/825402iC1891A80CA2BD8CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled3.jpg" alt="Untitled3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;the second table gives me no blanks if all my layers in my filters are selected.&lt;/P&gt;&lt;P&gt;the first table gives me blanks because I didn't include the others in my selectionset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if these are my filter layers and set row cell each:&lt;/P&gt;&lt;P&gt;FilterData(1) = "Yellow,Red,Cyan,Green,Blue,ORANGE,8 mm RSB by 6 m,10 mm RSB by 6 m,12 mm RSB by 6 m,16 mm RSB by 6 m,20 mm RSB by 6 m,25 mm RSB by 6 m,28 mm RSB by 6 m,32 mm RSB by 6 m,8 mm RSB by 7.5 m,10 mm RSB by 7.5 m,12 mm RSB by 7.5 m,16 mm RSB by 7.5 m,20 mm RSB by 7.5 m,25 mm RSB by 7.5 m,28 mm RSB by 7.5 m,32 mm RSB by 7.5 m,8 mm RSB by 9 m,10 mm RSB by 9 m,12 mm RSB by 9 m,16 mm RSB by 9 m,20 mm RSB by 9 m,25 mm RSB by 9 m,28 mm RSB by 9 m,32 mm RSB by 9 m,8 mm RSB by 10.5 m,10 mm RSB by 10.5 m,12 mm RSB by 10.5 m,16 mm RSB by 10.5 m,20 mm RSB by 10.5 m,25 mm RSB by 10.5 m,28 mm RSB by 10.5 m,32 mm RSB by 10.5 m,8 mm RSB by 12 m,10 mm RSB by 12 m,12 mm RSB by 12 m,16 mm RSB by 12 m,20 mm RSB by 12 m,25 mm RSB by 12 m,28 mm RSB by 12 m,32 mm RSB by 12 m"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I only want to compute some Red and some 32 mm RSB by 12 m, it will give me a table with full of blanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled4.jpg" style="width: 512px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/825401iE47CD213518DF1F5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled4.jpg" alt="Untitled4.jpg" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for helping sir&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 08:01:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9775986#M4081</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-09-30T08:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9778745#M4082</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I' m working on, the trick will be to add rows to the table, data type, only after the effective count of layers of selected objects, and not determinate an amount of row before knowing the amount of layers relative to selected objects, as your code is doing now.&lt;/P&gt;&lt;P&gt;Whenever the procedure, as sample, will be tested I'll share with you.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 13:22:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9778745#M4082</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-10-01T13:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9779122#M4083</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;here attached the project reviewed.&lt;/P&gt;&lt;P&gt;Here below the main code details, your selection set will be still used, but as I explained before the Table Rows will be added only if there are objects on such layer.&lt;/P&gt;&lt;P&gt;Table will be composed by 3 columns, LAYER, LENGHT, COUNT OBJECTS x LAYER. If you need to separate the TABLES you can modify the code following the same structure.&lt;/P&gt;&lt;P&gt;Of course the procedure could be optimized if you have a lot layers.&lt;/P&gt;&lt;P&gt;For your better understand the previous section where the value will be entered in the table cells, has been commented by "&amp;nbsp; '&amp;nbsp; ".&lt;/P&gt;&lt;P&gt;Let us know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EXTRACTED CODE:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;'....
For Each OBJECT In ASelSet
Select Case OBJECT.Layer

Case "Yellow"
    CountObJYell = CountObJYell + 1
    'MyTableLinear.SetCellValue 2, 2, CountObJYell
    'MyTableLinear.SetCellValue 2, 0, OBJECT.Layer
    ToTLengthObjYell = ToTLengthObjYell + OBJECT.Length
    'MyTableLinear.SetCellValue 2, 1, ToTLengthObjYell
    LabLY_Yellow = "Yellow"
Case "Red"
    CountObJRed = CountObJRed + 1
    'MyTableLinear.SetCellValue 3, 2, CountObJRed
   ' MyTableLinear.SetCellValue 3, 0, OBJECT.Layer
    ToTLengthObjRed = ToTLengthObjRed + OBJECT.Length
   ' MyTableLinear.SetCellValue 3, 1, ToTLengthObjRed
    LabLY_Red = "Red"

Case "Cyan"
    CountObJCyan = CountObJCyan + 1
    'MyTableLinear.SetCellValue 4, 2, CountObJCyan
    'MyTableLinear.SetCellValue 4, 0, OBJECT.Layer
    ToTLengthObjCyan = ToTLengthObjCyan + OBJECT.Length
    'MyTableLinear.SetCellValue 4, 1, ToTLengthObjCyan
    LabLY_Cyan = "Cyan"

Case "Green"
    CountObJGreen = CountObJGreen + 1
    'MyTableLinear.SetCellValue 5, 2, CountObJGreen
    'MyTableLinear.SetCellValue 5, 0, OBJECT.Layer
    ToTLengthObjGreen = ToTLengthObjGreen + OBJECT.Length
    'MyTableLinear.SetCellValue 5, 1, ToTLengthObjGreen
    LabLY_Green = "Green"

Case "Blue"
    CountObJBlue = CountObJBlue + 1
    'MyTableLinear.SetCellValue 6, 2, CountObJBlue
    'MyTableLinear.SetCellValue 6, 0, OBJECT.Layer
    ToTLengthObjBlue = ToTLengthObjBlue + OBJECT.Length
    'MyTableLinear.SetCellValue 6, 1, ToTLengthObjBlue
    LabLY_Blue = "Blue"

Case "ORANGE"
    CountObJORANGE = CountObJORANGE + 1
    'MyTableLinear.SetCellValue 7, 2, CountObJORANGE
    'MyTableLinear.SetCellValue 7, 0, OBJECT.Layer
    ToTLengthObjORANGE = ToTLengthObjORANGE + OBJECT.Length
    'MyTableLinear.SetCellValue 7, 1, ToTLengthObjORANGE
    LabLY_ORANGE = "ORANGE"
End Select

Next
ThisDrawing.Regen acAllViewports

Dim SelInsPoint As Variant
SelInsPoint = ThisDrawing.Utility.GetPoint(, "Select Insertion Point of Table: ")

Dim MyModelSpace As AcadModelSpace
Set MyModelSpace = ThisDrawing.ModelSpace

Dim MyTableLinear As AcadTable
'Set MyTableLinear = MyModelSpace.AddTable(SelInsPoint, LayCount, 2, 500, 8000)
Set MyTableLinear = MyModelSpace.AddTable(SelInsPoint, 2, 3, 500, 8000)

MyTableLinear.SetCellValue 0, 0, "LINEAR"
MyTableLinear.SetCellValue 1, 0, "LAYERS"
MyTableLinear.SetCellValue 1, 1, "LENGTH"
MyTableLinear.SetCellValue 1, 2, "OBJ COUNT"

Dim Row As Integer
Row = 2
If LabLY_Yellow = "Yellow" Then
    MyTableLinear.InsertRows Row, 500, 1
    MyTableLinear.SetCellValue Row, 0, LabLY_Yellow
    MyTableLinear.SetCellValue Row, 1, ToTLengthObjYell
    MyTableLinear.SetCellValue Row, 2, CountObJYell
    Row = Row + 1
End If

If LabLY_Red = "Red" Then
    MyTableLinear.InsertRows Row, 500, 1
    MyTableLinear.SetCellValue Row, 0, LabLY_Red
    MyTableLinear.SetCellValue Row, 1, ToTLengthObjRed
    MyTableLinear.SetCellValue Row, 2, CountObJRed
    Row = Row + 1
End If

If LabLY_Cyan = "Cyan" Then
    MyTableLinear.InsertRows Row, 500, 1
    MyTableLinear.SetCellValue Row, 0, LabLY_Cyan
    MyTableLinear.SetCellValue Row, 1, ToTLengthObjCyan
    MyTableLinear.SetCellValue Row, 2, CountObJCyan
    Row = Row + 1
End If

If LabLY_Green = "Green" Then
    MyTableLinear.InsertRows Row, 500, 1
    MyTableLinear.SetCellValue Row, 0, LabLY_Green
    MyTableLinear.SetCellValue Row, 1, ToTLengthObjGreen
    MyTableLinear.SetCellValue Row, 2, CountObJGreen
    Row = Row + 1
End If

If LabLY_Blue = "Blue" Then
    MyTableLinear.InsertRows Row, 500, 1
    MyTableLinear.SetCellValue Row, 0, LabLY_Blue
    MyTableLinear.SetCellValue Row, 1, ToTLengthObjBlue
    MyTableLinear.SetCellValue Row, 2, CountObJBlue
    Row = Row + 1
End If

If LabLY_ORANGE = "ORANGE" Then
    MyTableLinear.InsertRows Row, 500, 1
    MyTableLinear.SetCellValue Row, 0, LabLY_ORANGE
    MyTableLinear.SetCellValue Row, 1, ToTLengthObjORANGE
    MyTableLinear.SetCellValue Row, 2, CountObJORANGE
    Row = Row + 1
End If

For X = 0 To MyTableLinear.Rows
    For Y = 0 To MyTableLinear.Columns
        MyTableLinear.SetCellAlignment X, Y, acMiddleCenter
    Next Y
Next X

End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 15:27:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9779122#M4083</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-10-01T15:27:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9779341#M4084</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;Optimized version:&lt;/P&gt;&lt;P&gt;Routine modification with adding a function in order to optimize the code for writing on table.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;'Variable to be declared outside the module
Global MyTableLinear As AcadTable
Global Row As Integer&lt;/LI-CODE&gt;&lt;P&gt;Row and MyTableLinear variables declaration commented due to declared both as Global.&lt;/P&gt;&lt;P&gt;Declaring a variable with "Global" means the can be used everywhere inside the project instead only inside the single routine.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;'Dim Row As Integer
Row = 2
If LabLY_Yellow = "Yellow" Then
    Call AddRow(Row, "Yellow", ToTLengthObjYell, CountObJYell)
End If

If LabLY_Red = "Red" Then
    Call AddRow(Row, "Red", ToTLengthObjRed, CountObJRed)
End If

If LabLY_Cyan = "Cyan" Then
    Call AddRow(Row, "Cyan", ToTLengthObjCyan, CountObJCyan)
End If

If LabLY_Green = "Green" Then
    Call AddRow(Row, "Green", ToTLengthObjGreen, CountObJGreen)
End If

If LabLY_Blue = "Blue" Then
    Call AddRow(Row, "Blue", ToTLengthObjBlue, CountObJBlue)
End If

If LabLY_ORANGE = "ORANGE" Then
    Call AddRow(Row, "ORANGE", ToTLengthObjORANGE, CountObJORANGE)
End If&lt;/LI-CODE&gt;&lt;P&gt;Using the function you can avoid to write the same code several time, useful if you have a lot of layers and related variable.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Function AddRow(ByVal Row As Integer, ByVal LabLY As String, ByVal ToTLength As Double, ByVal CountObj As Integer)
    MyTableLinear.InsertRows Row, 500, 1
    MyTableLinear.SetCellValue Row, 0, LabLY
    MyTableLinear.SetCellValue Row, 1, ToTLength
    MyTableLinear.SetCellValue Row, 2, CountObj
    Row = Row + 1
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 17:08:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9779341#M4084</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-10-01T17:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9779479#M4085</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/472256"&gt;@grobnik&lt;/a&gt;&amp;nbsp;big thank you sir, the file code is working, i'll try to give feedback when I use it with my many layer and lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding on optimize codes, i'm not sure if i'm doing it right &amp;gt;..&amp;lt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First Code: I put it under option_explicit?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second Code: I replace this part from file code with that new codes?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'TO BE REPLACE&lt;/P&gt;&lt;P&gt;Dim Row As Integer&lt;BR /&gt;Row = 2&lt;BR /&gt;If LabLY_Yellow = "Yellow" Then&lt;BR /&gt;MyTableLinear.InsertRows Row, 500, 1&lt;BR /&gt;MyTableLinear.SetCellValue Row, 0, LabLY_Yellow&lt;BR /&gt;MyTableLinear.SetCellValue Row, 1, ToTLengthObjYell&lt;BR /&gt;MyTableLinear.SetCellValue Row, 2, CountObJYell&lt;BR /&gt;Row = Row + 1&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If LabLY_Red = "Red" Then&lt;BR /&gt;MyTableLinear.InsertRows Row, 500, 1&lt;BR /&gt;MyTableLinear.SetCellValue Row, 0, LabLY_Red&lt;BR /&gt;MyTableLinear.SetCellValue Row, 1, ToTLengthObjRed&lt;BR /&gt;MyTableLinear.SetCellValue Row, 2, CountObJRed&lt;BR /&gt;Row = Row + 1&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If LabLY_Cyan = "Cyan" Then&lt;BR /&gt;MyTableLinear.InsertRows Row, 500, 1&lt;BR /&gt;MyTableLinear.SetCellValue Row, 0, LabLY_Cyan&lt;BR /&gt;MyTableLinear.SetCellValue Row, 1, ToTLengthObjCyan&lt;BR /&gt;MyTableLinear.SetCellValue Row, 2, CountObJCyan&lt;BR /&gt;Row = Row + 1&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If LabLY_Green = "Green" Then&lt;BR /&gt;MyTableLinear.InsertRows Row, 500, 1&lt;BR /&gt;MyTableLinear.SetCellValue Row, 0, LabLY_Green&lt;BR /&gt;MyTableLinear.SetCellValue Row, 1, ToTLengthObjGreen&lt;BR /&gt;MyTableLinear.SetCellValue Row, 2, CountObJGreen&lt;BR /&gt;Row = Row + 1&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If LabLY_Blue = "Blue" Then&lt;BR /&gt;MyTableLinear.InsertRows Row, 500, 1&lt;BR /&gt;MyTableLinear.SetCellValue Row, 0, LabLY_Blue&lt;BR /&gt;MyTableLinear.SetCellValue Row, 1, ToTLengthObjBlue&lt;BR /&gt;MyTableLinear.SetCellValue Row, 2, CountObJBlue&lt;BR /&gt;Row = Row + 1&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;If LabLY_ORANGE = "ORANGE" Then&lt;BR /&gt;MyTableLinear.InsertRows Row, 500, 1&lt;BR /&gt;MyTableLinear.SetCellValue Row, 0, LabLY_ORANGE&lt;BR /&gt;MyTableLinear.SetCellValue Row, 1, ToTLengthObjORANGE&lt;BR /&gt;MyTableLinear.SetCellValue Row, 2, CountObJORANGE&lt;BR /&gt;Row = Row + 1&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For x = 0 To MyTableLinear.Rows&lt;BR /&gt;For Y = 0 To MyTableLinear.Columns&lt;BR /&gt;MyTableLinear.SetCellAlignment x, Y, acMiddleCenter&lt;BR /&gt;Next Y&lt;BR /&gt;Next x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the Third Code: I just put it under&amp;nbsp; the macro&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Private Sub COMPUTE_Click()&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Function AddRow(ByVal Row As Integer, ByVal LabLY As String, ByVal ToTLength As Double, ByVal CountObj As Integer)&lt;BR /&gt;MyTableLinear.InsertRows Row, 500, 1&lt;BR /&gt;MyTableLinear.SetCellValue Row, 0, LabLY&lt;BR /&gt;MyTableLinear.SetCellValue Row, 1, ToTLength&lt;BR /&gt;MyTableLinear.SetCellValue Row, 2, CountObj&lt;BR /&gt;Row = Row + 1&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nothing shows up except the title of table only..&lt;/P&gt;&lt;P&gt;no layers, lines,cells in tables&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sorry didn't understand it well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, I appreciate your help sir.&amp;nbsp;&lt;/P&gt;&lt;P&gt;super thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 18:16:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9779479#M4085</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-01T18:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9779581#M4086</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are right, too much version, excuse me, here attached the project reviewed "optimized" with function as per last code.&lt;/P&gt;&lt;P&gt;I suggest to &lt;U&gt;&lt;STRONG&gt;do not use&lt;/STRONG&gt; &lt;/U&gt;Option Explicit, the option force you to declare each variable, and there is any software improvement or best performance, it's only a way to become the code more clear for an external review.&lt;/P&gt;&lt;P&gt;However all variables used in modified code has been declared on my side (I guess).&lt;/P&gt;&lt;P&gt;In any case you have to replace or better remove the section where each layer will be written on the Table, which has been substituted by Function, see the entire project difference from that on post, just for your better understand.&lt;/P&gt;&lt;P&gt;If you open the entire project there are also the parts of code, where it's required Table insertion point, the main columns headers&amp;nbsp; and main table title header, these part of code has been moved down after the object selected layer checks.&lt;/P&gt;&lt;P&gt;As per your first code there was no modification on this part (just moved little bit down, and added count column), as there was any kind of modification to selection set, everything as per your first code posted. What I have modified it's only related to table writing data and count of length and count of objects (LINE as per you selection set).&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Do not copy and paste only the part that you are seeing on the post, use the entire project attached &lt;/STRONG&gt;&lt;FONT color="#808080"&gt;&lt;STRONG&gt;(file with dvb extension, and dwg used as test drawing with layers you indicated on your post). &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;&lt;FONT&gt;The project name it's always the same, I guess you are able to open a project, goto on MANAGE Autocad Menu, Load application and open file dvb previously extracted&amp;nbsp;from zip file attached and stored in a your project directory.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;&lt;FONT&gt;The code works more or less like the previous one the "core" it's the same, so starting from selection set results, check the layer for each object, made calculation of length and set a sort of "flag" indicating that there are objects on such layer, this allows you later to insert the row related to that layer with related count, and total of length.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333333"&gt;&lt;FONT&gt;At the beginning the table will be created just with header string, no more, then added rows.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Oct 2020 19:01:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9779581#M4086</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-10-01T19:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9781205#M4087</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/472256"&gt;@grobnik&lt;/a&gt;&amp;nbsp; thanks again sir, it's working properly, however&amp;nbsp; the adding of codes every new created layer is kinda hard, it's confusing and time consuming. I have to re-edit the codes every cad file with different layer names &amp;gt;..&amp;lt;&lt;/P&gt;&lt;P&gt;anyway, thank you again for this sir.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this code that you gave me from the beginning or from my other post, I've been trying to troubleshoot it, seems the main problem is getting the:&lt;/P&gt;&lt;P&gt;LayersX (list of layer in selectionset with no repeated Layers)&lt;/P&gt;&lt;P&gt;then&lt;/P&gt;&lt;P&gt;LayCount will only be LayCount=LayersX .Count&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you could still help me figure it out, since it doesn't require me to edit the codes every adding of LAYERS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code (I tried to revised):&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sub TOTAL_LINEAR()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim ASelSet As AcadSelectionSet&lt;BR /&gt;Dim FilterType(1) As Integer&lt;BR /&gt;Dim FilterData(1) As Variant&lt;/P&gt;&lt;P&gt;On Error Resume Next&lt;BR /&gt;Set ASelSet = ThisDrawing.SelectionSets.Add("SS")&lt;BR /&gt;FilterType(0) = 0&lt;BR /&gt;FilterData(0) = "LINE,POLYLINE,LWPOLYLINE,ARC,CIRCLE,ELLIPSE,SPLINE"&lt;BR /&gt;FilterType(1) = 8&lt;BR /&gt;FilterData(1) = "Yellow,Red,Cyan,Green,Blue,ORANGE,REINFORCEMENTS,8mm RSB by 6m,10mm RSB by 6m,12mm RSB by 6m,16mm RSB by 6m,20mm RSB by 6m,25mm RSB by 6m,28mm RSB by 6m,32mm RSB by 6m,8mm RSB by 7.5m,10mm RSB by 7.5m,12mm RSB by 7.5m,16mm RSB by 7.5m,20mm RSB by 7.5m,25mm RSB by 7.5m,28mm RSB by 7.5m,32mm RSB by 7.5m,8mm RSB by 9m,10mm RSB by 9m,12mm RSB by 9m,16mm RSB by 9m,20mm RSB by 9m,25mm RSB by 9m,28mm RSB by 9m,32mm RSB by 9m,8mm RSB by 10.5m,10mm RSB by 10.5m,12mm RSB by 10.5m,16mm RSB by 10.5m,20mm RSB by 10.5m,25mm RSB by 10.5m,28mm RSB by 10.5m,32mm RSB by 10.5m,8mm RSB by 12m,10mm RSB by 12m,12mm RSB by 12m,16mm RSB by 12m,20mm RSB by 12m,25mm RSB by 12m,28mm RSB by 12m,32mm RSB by 12m"&lt;/P&gt;&lt;P&gt;If Err.Number &amp;lt;&amp;gt; 0 Then&lt;BR /&gt;Set ASelSet = ThisDrawing.SelectionSets.Item("SS")&lt;BR /&gt;FilterType(0) = 0&lt;BR /&gt;FilterData(0) = "LINE,POLYLINE,LWPOLYLINE,ARC,CIRCLE,ELLIPSE,SPLINE"&lt;BR /&gt;FilterType(1) = 8&lt;BR /&gt;FilterData(1) = "Yellow,Red,Cyan,Green,Blue,ORANGE,REINFORCEMENTS,8mm RSB by 6m,10mm RSB by 6m,12mm RSB by 6m,16mm RSB by 6m,20mm RSB by 6m,25mm RSB by 6m,28mm RSB by 6m,32mm RSB by 6m,8mm RSB by 7.5m,10mm RSB by 7.5m,12mm RSB by 7.5m,16mm RSB by 7.5m,20mm RSB by 7.5m,25mm RSB by 7.5m,28mm RSB by 7.5m,32mm RSB by 7.5m,8mm RSB by 9m,10mm RSB by 9m,12mm RSB by 9m,16mm RSB by 9m,20mm RSB by 9m,25mm RSB by 9m,28mm RSB by 9m,32mm RSB by 9m,8mm RSB by 10.5m,10mm RSB by 10.5m,12mm RSB by 10.5m,16mm RSB by 10.5m,20mm RSB by 10.5m,25mm RSB by 10.5m,28mm RSB by 10.5m,32mm RSB by 10.5m,8mm RSB by 12m,10mm RSB by 12m,12mm RSB by 12m,16mm RSB by 12m,20mm RSB by 12m,25mm RSB by 12m,28mm RSB by 12m,32mm RSB by 12m"&lt;BR /&gt;End If&lt;BR /&gt;ASelSet.Clear&lt;BR /&gt;ASelSet.SelectOnScreen FilterType, FilterData&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim LayerX As AcadLayer&lt;/P&gt;&lt;P&gt;Dim LayersX As AcadLayers&lt;BR /&gt;Set LayersX = ThisDrawing.Layers 'ASelSet.Layers&lt;/P&gt;&lt;P&gt;Dim LayCount As Integer&lt;BR /&gt;LayCount = ASelSet.count 'LayersX.count&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;ThisDrawing.Regen acAllViewports&lt;BR /&gt;On Error Resume Next&lt;BR /&gt;ThisDrawing.ActiveLayer = ThisDrawing.Layers.Add("TABLE")&lt;/P&gt;&lt;P&gt;Dim SelInsPoint As Variant&lt;BR /&gt;SelInsPoint = ThisDrawing.Utility.GetPoint(, "Select Insertion Point of Table: ")&lt;BR /&gt;Dim MyModelSpace As AcadModelSpace&lt;BR /&gt;Set MyModelSpace = ThisDrawing.ModelSpace&lt;BR /&gt;Set MyTableLinear = MyModelSpace.AddTable(SelInsPoint, LayCount, 2, 500, 5000)&lt;/P&gt;&lt;P&gt;MyTableLinear.SetCellValue 0, 0, "Total Linear (m)"&lt;BR /&gt;MyTableLinear.SetCellValue 1, 0, "Description"&lt;BR /&gt;MyTableLinear.SetCellValue 1, 1, "Quantity"&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim Row As Integer&lt;BR /&gt;Row = 2&lt;BR /&gt;For Each LayerX In LayersX 'ASelSet.Layers '&lt;BR /&gt;If LayerX.Name &amp;lt;&amp;gt; "0" And LayerX.Name &amp;lt;&amp;gt; "Defpoints" And LayerX.Name &amp;lt;&amp;gt; "AM_CL" Then&lt;BR /&gt;MyTableLinear.SetCellValue Row, 0, LayerX.Name&lt;BR /&gt;Row = Row + 1&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim ObjectsName() As Variant&lt;BR /&gt;Dim OBJECT As AcadObject&lt;BR /&gt;Dim LayName() As Variant&lt;BR /&gt;Dim count As Integer&lt;BR /&gt;Dim count1 As Integer&lt;BR /&gt;Dim TotalLength As Long&lt;/P&gt;&lt;P&gt;' count = 0&lt;BR /&gt;' count1 = 0&lt;/P&gt;&lt;P&gt;For Each LayerX In LayersX&lt;BR /&gt;' If LayerX.Name &amp;lt;&amp;gt; "0" And LayerX.Name &amp;lt;&amp;gt; "Defpoints" And LayerX.Name &amp;lt;&amp;gt; "AM_CL" Then&lt;BR /&gt;' ReDim Preserve LayName(count)&lt;BR /&gt;' LayName(count) = LayerX.Name&lt;BR /&gt;' count = count + 1&lt;/P&gt;&lt;P&gt;For Each OBJECT In ASelSet&lt;BR /&gt;If OBJECT.Layer = LayerX.Name Then&lt;BR /&gt;ReDim Preserve ObjectsName(count1)&lt;BR /&gt;ObjectsName(count1) = OBJECT.ObjectName&lt;/P&gt;&lt;P&gt;Select Case ObjectsName(count1)&lt;BR /&gt;Case "AcDbPolyline"&lt;BR /&gt;TotalLength = TotalLength + OBJECT.Length&lt;BR /&gt;Case "AcDbLine"&lt;BR /&gt;TotalLength = TotalLength + OBJECT.Length&lt;BR /&gt;Case "AcDbCircle"&lt;BR /&gt;TotalLength = TotalLength + OBJECT.Circumference&lt;BR /&gt;Case "AcDbArc"&lt;BR /&gt;TotalLength = TotalLength + OBJECT.ArcLength&lt;BR /&gt;End Select&lt;/P&gt;&lt;P&gt;End If&lt;BR /&gt;Next&lt;BR /&gt;' End If&lt;BR /&gt;'&lt;/P&gt;&lt;P&gt;For Row = 2 To LayCount&lt;BR /&gt;If MyTableLinear.GetCellValue(Row, 0) = LayerX.Name Then&lt;BR /&gt;MyTableLinear.SetCellValue Row, 1, FormatNumber(TotalLength / 1000, 2)&lt;BR /&gt;End If&lt;BR /&gt;Next Row&lt;/P&gt;&lt;P&gt;' LayName(count).Clear&lt;BR /&gt;' LayName(count) = 0&lt;BR /&gt;' count1 = 0&lt;BR /&gt;' Row = 2&lt;BR /&gt;TotalLength = 0&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;End Sub&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;Again and again, thank you sir, I'm learning at the same time.&lt;/P&gt;&lt;P&gt;God Bless&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>Fri, 02 Oct 2020 15:22:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9781205#M4087</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-02T15:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to I get Layer Names (Remove/No Duplicates)  in my SelectionSet of Objects</title>
      <link>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9781390#M4088</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/P&gt;&lt;P&gt;I cannot test your code if I have not the complete drawing with all listed layers and related objects.&lt;/P&gt;&lt;P&gt;So I cannot help you if I have not raw materials for working on it.&lt;/P&gt;&lt;P&gt;Send me in pvt msg the drawing, I never share it.&lt;/P&gt;&lt;P&gt;In anycase, seems you are counting again all drawing layers and not the layers related only to selected objcets, that from what I understand until now could be not the same, but only some of these.&lt;/P&gt;&lt;P&gt;You code below indicated could not works as you wish, you are collecting all layers in the drawing&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Dim LayerX As AcadLayer
Dim LayersX As AcadLayers

Set LayersX = ThisDrawing.Layers 'ASelSet.Layers -&amp;gt; NOT TRUE this is the collection of all layers in the drawing, not only those related to selected objects.

Dim LayCount As Integer
LayCount = ASelSet.count 'LayersX.count -&amp;gt; NOT TRUE You can have more than one object on the same layer (Pls confirm). So this count will be not equal to total amount of layers of selected objects, this could be higher or lower.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Oct 2020 16:58:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/how-to-i-get-layer-names-remove-no-duplicates-in-my-selectionset/m-p/9781390#M4088</guid>
      <dc:creator>grobnik</dc:creator>
      <dc:date>2020-10-02T16:58:32Z</dc:date>
    </item>
  </channel>
</rss>

