{"id":164999,"date":"2023-03-17T08:59:10","date_gmt":"2023-03-17T08:59:10","guid":{"rendered":"\/knowledge\/forums\/topic\/using-python-scripting-how-can-i-get-the-part-id-and-select-the-part-based-on-the-part-name\/"},"modified":"2023-07-31T12:26:42","modified_gmt":"2023-07-31T12:26:42","slug":"using-python-scripting-how-can-i-get-the-part-id-and-select-the-part-based-on-the-part-name","status":"publish","type":"topic","link":"https:\/\/innovationspace.ansys.com\/knowledge\/forums\/topic\/using-python-scripting-how-can-i-get-the-part-id-and-select-the-part-based-on-the-part-name\/","title":{"rendered":"Using Python scripting, how can I get the part id and select the part based on the part name?"},"content":{"rendered":"<p>This can be done with the following, where Flowfield is the part name.  p_ID = ensight.objs.core.PARTS[&#8216;Flowfield&#8217;][0].PARTNUMBER     Note, the example will throw an exception if &#8216;Flowfield&#8217; does not exist (the returned ensobjlist would have length of 0 if the part did not exist).  It will also avoid the side effect of changing the part selection.  If you need part selection as well, then:  part = ensight.objs.core.PARTS[&#8216;Flowfield&#8217;][0] part.SELECTED = True p_ID = part.PARTNUMBER     Should work.     This exploits that fact that the PARTS attribute is not a list, but an instance of an ensobjlist, which supports attribute based find operations (via .find(), which includes things like wildcards, etc) and implicit find using a string (or iterator of strings) as the index.  It also supports things like:  parts = ensight.objs.core.PARTS[[&#8216;Ground&#8217;,&#8217;Coil&#8217;]]<\/p>\n","protected":false},"template":"","class_list":["post-164999","topic","type-topic","status-publish","hentry","topic-tag-2020-r2","topic-tag-ensight","topic-tag-fluid-dynamics","topic-tag-scripting"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_wp_page_template":["default"],"_bbp_last_active_time":["3-15-2023  20:20:20"],"_bbp_forum_id":["27796"],"_bbp_author_ip":["23.56.168.180"],"_btv_view_count":["1553"],"siebel_km_number":["2063231"],"product_version":["2020 R2"],"km_published_date":["0"],"family":["Fluid Dynamics"],"application_name":["Ensight"]},"test":"articlesansys-com"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/topics\/164999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/topics\/164999\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/knowledge\/wp-json\/wp\/v2\/media?parent=164999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}