{"id":1585,"date":"2016-12-14T17:36:50","date_gmt":"2016-12-14T17:36:50","guid":{"rendered":"http:\/\/elbsolutions.com\/projects\/?p=1585"},"modified":"2022-02-03T11:24:32","modified_gmt":"2022-02-03T17:24:32","slug":"autocad-selection-sets-useless-command-line-vba-groups-thats-new","status":"publish","type":"post","link":"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/","title":{"rendered":"AutoCAD &#8211; Selection Sets are useless for command line from VBA but groups&#8230; that&#8217;s new &#8230;"},"content":{"rendered":"<p>First, did you know you can type VBA from the command line?\u00a0Use the vbstmt command.\u00a0<a href=\"https:\/\/knowledge.autodesk.com\/support\/autocad\/troubleshooting\/caas\/sfdcarticles\/sfdcarticles\/Deleting-all-groups-in-drawing.html\">Here is how to clear all groups<\/a>. But getting back to the topic at hand. So named Selection Sets &#8211; you can&#8217;t use them. For example &#8211; using the CHSPACE command initiated by VBA (SendCommand) asks for a selection &#8211; well you cannot use the selection set name &#8211; you CAN group that selection set and name it with an UPPER CASE (did I say UPPERCASE?) name and when you are prompted for a selection &#8211; then give it the GROUP name. Then delete your group and you have what you need. You can even see the grips! Here is how I figured it out &#8211; <a href=\"http:\/\/forums.augi.com\/showthread.php?137943-Making-a-SelectionSet-active-in-GUI\">these guys helped a lot<\/a>.<\/p>\n<p><!--more-->There was a little bickering on that blog &#8211; but making a group and selecting it, then passing back that group as the functions&#8217; result allows a lot of flexibility.<\/p>\n<p>Here is the calling code &#8230;<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n\r\nDim mSS As ACadSelectionSet\r\nDim chSpaceCommand As String\r\n' fill mSS with something ...\r\n\r\nDim tGroup As AcadGroup\r\n\r\nSet tGroup = vpo.aco.GroupItemsInSS(mSS, True, False) ' should select\/highlight the items\r\n\r\n' Do something here, for example CHSPACE\r\n\tchSpaceCommand = &quot;CHSPACE Group &quot; &amp; tGroup.name &amp; &quot;\u00a0 &quot;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Debug.Print chSpaceCommand\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0thisDrawing.SendCommand (chSpaceCommand) ' &amp; VBA.Chr(13))\r\n\r\ntGroup.Delete\r\n\r\n<\/pre>\n<p>Here is the GroupItemInSS<\/p>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n\r\nFunction GroupItemsInSS(SS As AcadSelectionSet, selectOnScreen As Boolean, ungroup As Boolean) As AcadGroup\r\n\r\nDim ans As Long\r\n\r\n' Basically we make a group\r\nDim i As Long\r\n\r\nDim bob() As AcadEntity\r\nReDim bob(SS.count - 1)\r\nReDim bob(SS.count - 1) As AcadEntity\r\nFor i = 0 To SS.count - 1\r\nSet bob(i) = SS.item(i)\r\nNext\r\n\r\nDim grpTemp As AcadGroup\r\n\r\nDim vvar As Variant\r\nDim oEnt As AcadEntity\r\n\r\nDim grpName As String\r\ngrpName = VBA.UCase(&quot;grp&quot; &amp; SS.name)\r\n\r\nFor Each vvar In thisDrawing.Groups\r\nSet grpTemp = vvar\r\nDebug.Print grpName\r\nIf grpTemp.name = grpName Then\r\n\r\ngrpTemp.Delete\r\n'Exit For\r\nEnd If\r\nNext\r\nIf Not ungroup Then\r\nSet grpTemp = thisDrawing.Groups.Add(grpName)\r\ngrpTemp.AppendItems bob\r\nans = grpTemp.count\r\n\r\ngrpTemp.highlight True\r\ngrpTemp.Update\r\n\r\nSS.Application.ActiveDocument.Regen acAllViewports\r\nIf (selectOnScreen) Then\r\nSS.Application.ActiveDocument.SendCommand (&quot;SELECT G &quot; &amp; grpName &amp; &quot; &quot; &amp; VBA.Chr(13))\r\nEnd If\r\n\r\nEnd If\r\nSet GroupItemsInSS = grpTemp\r\nEnd Function\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>First, did you know you can type VBA from the command line?\u00a0Use the vbstmt command.\u00a0Here is how to clear all groups. But getting back to the topic at hand. So named Selection Sets &#8211; you can&#8217;t use them. For example &#8211; using the CHSPACE command initiated by VBA (SendCommand) asks for a selection &#8211; well [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1585","post","type-post","status-publish","format-standard","hentry","category-general"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>AutoCAD - Selection Sets are useless for command line from VBA but groups... that&#039;s new ... - ELB Solutions.com Inc.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AutoCAD - Selection Sets are useless for command line from VBA but groups... that&#039;s new ... - ELB Solutions.com Inc.\" \/>\n<meta property=\"og:description\" content=\"First, did you know you can type VBA from the command line?\u00a0Use the vbstmt command.\u00a0Here is how to clear all groups. But getting back to the topic at hand. So named Selection Sets &#8211; you can&#8217;t use them. For example &#8211; using the CHSPACE command initiated by VBA (SendCommand) asks for a selection &#8211; well [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/\" \/>\n<meta property=\"og:site_name\" content=\"ELB Solutions.com Inc.\" \/>\n<meta property=\"article:published_time\" content=\"2016-12-14T17:36:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-03T17:24:32+00:00\" \/>\n<meta name=\"author\" content=\"Etienne Bley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etienne Bley\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\\\/\"},\"author\":{\"name\":\"Etienne Bley\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"headline\":\"AutoCAD &#8211; Selection Sets are useless for command line from VBA but groups&#8230; that&#8217;s new &#8230;\",\"datePublished\":\"2016-12-14T17:36:50+00:00\",\"dateModified\":\"2022-02-03T17:24:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\\\/\"},\"wordCount\":402,\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\\\/\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\\\/\",\"name\":\"AutoCAD - Selection Sets are useless for command line from VBA but groups... that's new ... - ELB Solutions.com Inc.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\"},\"datePublished\":\"2016-12-14T17:36:50+00:00\",\"dateModified\":\"2022-02-03T17:24:32+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AutoCAD &#8211; Selection Sets are useless for command line from VBA but groups&#8230; that&#8217;s new &#8230;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\",\"name\":\"ELB Solutions.com Inc.\",\"description\":\"Bringing all your IT Pieces together\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\",\"name\":\"Etienne Bley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"caption\":\"Etienne Bley\"},\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/author\\\/etienne-bley\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AutoCAD - Selection Sets are useless for command line from VBA but groups... that's new ... - ELB Solutions.com Inc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/","og_locale":"en_US","og_type":"article","og_title":"AutoCAD - Selection Sets are useless for command line from VBA but groups... that's new ... - ELB Solutions.com Inc.","og_description":"First, did you know you can type VBA from the command line?\u00a0Use the vbstmt command.\u00a0Here is how to clear all groups. But getting back to the topic at hand. So named Selection Sets &#8211; you can&#8217;t use them. For example &#8211; using the CHSPACE command initiated by VBA (SendCommand) asks for a selection &#8211; well [&hellip;]","og_url":"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/","og_site_name":"ELB Solutions.com Inc.","article_published_time":"2016-12-14T17:36:50+00:00","article_modified_time":"2022-02-03T17:24:32+00:00","author":"Etienne Bley","twitter_misc":{"Written by":"Etienne Bley","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/#article","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/"},"author":{"name":"Etienne Bley","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"headline":"AutoCAD &#8211; Selection Sets are useless for command line from VBA but groups&#8230; that&#8217;s new &#8230;","datePublished":"2016-12-14T17:36:50+00:00","dateModified":"2022-02-03T17:24:32+00:00","mainEntityOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/"},"wordCount":402,"articleSection":["General"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/","url":"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/","name":"AutoCAD - Selection Sets are useless for command line from VBA but groups... that's new ... - ELB Solutions.com Inc.","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/#website"},"datePublished":"2016-12-14T17:36:50+00:00","dateModified":"2022-02-03T17:24:32+00:00","author":{"@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"breadcrumb":{"@id":"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elbsolutions.com\/projects\/autocad-selection-sets-useless-command-line-vba-groups-thats-new\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elbsolutions.com\/projects\/"},{"@type":"ListItem","position":2,"name":"AutoCAD &#8211; Selection Sets are useless for command line from VBA but groups&#8230; that&#8217;s new &#8230;"}]},{"@type":"WebSite","@id":"https:\/\/elbsolutions.com\/projects\/#website","url":"https:\/\/elbsolutions.com\/projects\/","name":"ELB Solutions.com Inc.","description":"Bringing all your IT Pieces together","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elbsolutions.com\/projects\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39","name":"Etienne Bley","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","caption":"Etienne Bley"},"url":"https:\/\/elbsolutions.com\/projects\/author\/etienne-bley\/"}]}},"_links":{"self":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/comments?post=1585"}],"version-history":[{"count":3,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1585\/revisions"}],"predecessor-version":[{"id":1588,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1585\/revisions\/1588"}],"wp:attachment":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/media?parent=1585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/categories?post=1585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/tags?post=1585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}