


{"id":37371,"date":"2019-08-28T12:46:47","date_gmt":"2019-08-28T12:46:47","guid":{"rendered":"\/forum\/forums\/topic\/act-script-assign-items-to-a-named-selection\/"},"modified":"2023-09-28T07:40:24","modified_gmt":"2023-09-28T07:40:24","slug":"act-script-assign-items-to-a-named-selection","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/act-script-assign-items-to-a-named-selection\/","title":{"rendered":"ACT Script: Assign items to a named selection"},"content":{"rendered":"<p>What is the best way to assign items to a named selection in ACT?<\/p>\n<p>I know how to browse through items (parts, bodies, etc.) in the structure tree. But it seems to me that it is not possible to assign an item, for example a body directly to a named selection. An intermediate step seems to be to gather items in a selection and then assign the contents of the selection to a named selection.<\/p>\n<p>However, I do not manage to add the items to a selection programmatically. The methods NewSelection as well as AddSelection need an input argument of type ISelectionInfo but I do not know how to obtain this from the Items I am browsing. <\/p>\n<p>Below is an example where I have tried to assign each part to a named selection.<\/p>\n<hr class=\"bbcode_rule\" \/>\n<br \/>#Model<br \/>model = ExtAPI.DataModel.Project.Model <\/p>\n<p># Get parts<br \/>Parts = model.Geometry.GetChildren(DataModelObjectCategory.Part,True)<\/p>\n<p># The procedure will be included in a loop later. Just using first part in test.<br \/>MyPart = Parts[0]<\/p>\n<p># Selection<br \/>SlMn = ExtAPI.SelectionManager<br \/>SlMn.ClearSelection()<\/p>\n<p>#<\/p>\n<hr class=\"bbcode_rule\" \/>\n&gt;&gt;&gt; Missing part: Adding &#8220;MyPart&#8221; to current selection &lt;&lt;&lt;<\/p>\n<hr class=\"bbcode_rule\" \/>\n<br \/># SlMn.NewSelection()<\/p>\n<p># Create named selection<br \/>NSn = model.NamedSelections<br \/>MyNS = NSn.AddNamedSelection()<br \/>MyNS.Name = &#8220;Part0&#8221;<br \/>MyNS.Location = SlMn.CurrentSelection<\/p>\n","protected":false},"template":"","class_list":["post-37371","topic","type-topic","status-closed","hentry"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_old_topic_id":["9548"],"_bbp_old_topic_author_name_id":["Anonymous"],"_bbp_old_is_topic_anonymous_id":["false"],"_bbp_old_closed_status_id":["publish"],"_bbp_author_ip":[null],"_bbp_old_sticky_status_id":["normal"],"_bbp_likes_count":["1"],"_btv_view_count":["5400"],"_bbp_subscription":["25225","294457","58821"],"_bbp_status":["publish"],"_bbp_topic_status":["unanswered"],"_bbp_topic_id":["37371"],"_bbp_forum_id":["27791"],"_bbp_engagement":["199","25225","58821","167723"],"_bbp_voice_count":["4"],"_bbp_reply_count":["4"],"_bbp_last_reply_id":["309214"],"_bbp_last_active_id":["309214"],"_bbp_last_active_time":["2023-09-28 07:40:11"]},"test":"mike3000"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/37371","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":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/37371\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=37371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}