We have an exciting announcement about badges coming in May 2025. Until then, we will temporarily stop issuing new badges for course completions and certifications. However, all completions will be recorded and fulfilled after May 2025.
General

General

Using Python scripting, how can I get the part id and select the part based on the part name?

    • FAQFAQ
      Participant

      This can be done with the following, where Flowfield is the part name. p_ID = ensight.objs.core.PARTS[‘Flowfield’][0].PARTNUMBER Note, the example will throw an exception if ‘Flowfield’ 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[‘Flowfield’][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[[‘Ground’,’Coil’]]