


{"id":366839,"date":"2024-05-14T23:11:49","date_gmt":"2024-05-14T23:11:49","guid":{"rendered":"\/forum\/forums\/topic\/select-all-objects-in-layer\/"},"modified":"2024-05-16T21:46:42","modified_gmt":"2024-05-16T21:46:42","slug":"select-all-objects-in-layer","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/","title":{"rendered":"Select all objects in Layer"},"content":{"rendered":"<p>Hello, I&#8217;d like to enumerate through all layers, select all objects on a layer, then perform a custom function on the selected objects. I&#8217;m not able to identify if the objects i have selected are part of the active layer. i would expect it to work similar to this:<\/p>\n<div>def selectObjinLayer():<\/div>\n<div>&nbsp; &nbsp; doc = Window.ActiveWindow.Document<\/div>\n<div>&nbsp;<\/div>\n<div>&nbsp; &nbsp; for layer in Layers.GetAllLayers():<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; #print(layer.GetName())<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; Layers.Activate(layer.GetName())<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; selection = Selection.Clear()<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; selection = Selection.Create(Layers.GetActive())<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; secondarySelection = Selection.Empty()<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; #this is the point where the script fails<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; # the GetAllBodies returns empty, so no iteration occurs<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; for design_body in doc.MainPart.GetAllBodies():<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&#8220;check if &#8220;, design_body,&#8221; is in layer &#8220;, layer)<\/div>\n<div style=\"padding-left: 40px\">#this is a nonsense getter and comparison:<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if design_body.Layer == layer:<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selection.AddToActive()<\/div>\n<div>&nbsp; &nbsp; &nbsp; &nbsp; return selection<\/div>\n<div>&nbsp;<\/div>\n<div>selectedOBJS = selectObjinLayer()<\/div>\n<div>customFunction(selectedOBJS)<\/div>\n<div>&nbsp;<\/div>\n<div>the customFunction fills all objects, then renames the associated Surfaces based on the layer name.<\/div>\n","protected":false},"template":"","class_list":["post-366839","topic","type-topic","status-closed","hentry","topic-tag-macros-scripting-2","topic-tag-python","topic-tag-spaceclaim"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"Hello, I&#039;d like to enumerate through all layers, select all objects on a layer, then perform a custom function on the selected objects. I&#039;m not able to identify if the objects i have selected are part of the active layer. i would expect it to work similar to this:def selectObjinLayer(): doc = Window.ActiveWindow.Document\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Ansys Learning Forum | Ansys Innovation Space\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Select all objects in Layer | Ansys Learning Forum\" \/>\n\t\t<meta property=\"og:description\" content=\"Hello, I&#039;d like to enumerate through all layers, select all objects on a layer, then perform a custom function on the selected objects. I&#039;m not able to identify if the objects i have selected are part of the active layer. i would expect it to work similar to this:def selectObjinLayer(): doc = Window.ActiveWindow.Document\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2024-05-14T23:11:49+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2024-05-16T21:46:42+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Select all objects in Layer | Ansys Learning Forum\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Hello, I&#039;d like to enumerate through all layers, select all objects on a layer, then perform a custom function on the selected objects. I&#039;m not able to identify if the objects i have selected are part of the active layer. i would expect it to work similar to this:def selectObjinLayer(): doc = Window.ActiveWindow.Document\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/select-all-objects-in-layer\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/spaceclaim\\\/#listItem\",\"name\":\"spaceclaim\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/spaceclaim\\\/#listItem\",\"position\":3,\"name\":\"spaceclaim\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/spaceclaim\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/select-all-objects-in-layer\\\/#listItem\",\"name\":\"Select all objects in Layer\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/select-all-objects-in-layer\\\/#listItem\",\"position\":4,\"name\":\"Select all objects in Layer\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic-tag\\\/spaceclaim\\\/#listItem\",\"name\":\"spaceclaim\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#organization\",\"name\":\"Ansys Learning Forum\",\"description\":\"Ansys Innovation Space\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/select-all-objects-in-layer\\\/#webpage\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/select-all-objects-in-layer\\\/\",\"name\":\"Select all objects in Layer | Ansys Learning Forum\",\"description\":\"Hello, I'd like to enumerate through all layers, select all objects on a layer, then perform a custom function on the selected objects. I'm not able to identify if the objects i have selected are part of the active layer. i would expect it to work similar to this:def selectObjinLayer(): doc = Window.ActiveWindow.Document\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/select-all-objects-in-layer\\\/#breadcrumblist\"},\"datePublished\":\"2024-05-14T23:11:49+00:00\",\"dateModified\":\"2024-05-16T21:46:42+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/\",\"name\":\"Ansys Learning Forum\",\"description\":\"Ansys Innovation Space\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Select all objects in Layer | Ansys Learning Forum","description":"Hello, I'd like to enumerate through all layers, select all objects on a layer, then perform a custom function on the selected objects. I'm not able to identify if the objects i have selected are part of the active layer. i would expect it to work similar to this:def selectObjinLayer(): doc = Window.ActiveWindow.Document","canonical_url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","position":1,"name":"Home","item":"https:\/\/innovationspace.ansys.com\/forum","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","position":2,"name":"Topics","item":"https:\/\/innovationspace.ansys.com\/forum\/topics\/","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/spaceclaim\/#listItem","name":"spaceclaim"},"previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/spaceclaim\/#listItem","position":3,"name":"spaceclaim","item":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/spaceclaim\/","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/#listItem","name":"Select all objects in Layer"},"previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/#listItem","position":4,"name":"Select all objects in Layer","previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/spaceclaim\/#listItem","name":"spaceclaim"}}]},{"@type":"Organization","@id":"https:\/\/innovationspace.ansys.com\/forum\/#organization","name":"Ansys Learning Forum","description":"Ansys Innovation Space","url":"https:\/\/innovationspace.ansys.com\/forum\/"},{"@type":"WebPage","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/#webpage","url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/","name":"Select all objects in Layer | Ansys Learning Forum","description":"Hello, I'd like to enumerate through all layers, select all objects on a layer, then perform a custom function on the selected objects. I'm not able to identify if the objects i have selected are part of the active layer. i would expect it to work similar to this:def selectObjinLayer(): doc = Window.ActiveWindow.Document","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#website"},"breadcrumb":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/#breadcrumblist"},"datePublished":"2024-05-14T23:11:49+00:00","dateModified":"2024-05-16T21:46:42+00:00"},{"@type":"WebSite","@id":"https:\/\/innovationspace.ansys.com\/forum\/#website","url":"https:\/\/innovationspace.ansys.com\/forum\/","name":"Ansys Learning Forum","description":"Ansys Innovation Space","inLanguage":"en-US","publisher":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#organization"}}]},"og:locale":"en_US","og:site_name":"Ansys Learning Forum | Ansys Innovation Space","og:type":"article","og:title":"Select all objects in Layer | Ansys Learning Forum","og:description":"Hello, I'd like to enumerate through all layers, select all objects on a layer, then perform a custom function on the selected objects. I'm not able to identify if the objects i have selected are part of the active layer. i would expect it to work similar to this:def selectObjinLayer(): doc = Window.ActiveWindow.Document","og:url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/","article:published_time":"2024-05-14T23:11:49+00:00","article:modified_time":"2024-05-16T21:46:42+00:00","twitter:card":"summary_large_image","twitter:title":"Select all objects in Layer | Ansys Learning Forum","twitter:description":"Hello, I'd like to enumerate through all layers, select all objects on a layer, then perform a custom function on the selected objects. I'm not able to identify if the objects i have selected are part of the active layer. i would expect it to work similar to this:def selectObjinLayer(): doc = Window.ActiveWindow.Document"},"aioseo_meta_data":{"post_id":"366839","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"content","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":true,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2024-10-28 16:42:26","updated":"2024-10-28 16:42:26","ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\/topics\/\" title=\"Topics\">Topics<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/spaceclaim\/\" title=\"spaceclaim\">spaceclaim<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tSelect all objects in Layer\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/innovationspace.ansys.com\/forum"},{"label":"Topics","link":"https:\/\/innovationspace.ansys.com\/forum\/topics\/"},{"label":"spaceclaim","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic-tag\/spaceclaim\/"},{"label":"Select all objects in Layer","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/select-all-objects-in-layer\/"}],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["129476","2328"],"_bbp_author_ip":["23.218.93.190"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["557"],"_bbp_topic_status":["answered"],"_bbp_topic_id":["366839"],"_bbp_forum_id":["27789"],"_bbp_engagement":["2328","129476"],"_bbp_voice_count":["2"],"_bbp_last_reply_id":["367239"],"_bbp_last_active_id":["367239"],"_bbp_last_active_time":["2024-05-16 21:46:28"]},"test":"dave-hillskeysight-com"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/366839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/366839\/revisions"}],"predecessor-version":[{"id":367240,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/366839\/revisions\/367240"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=366839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}