Skip to content

Instantly share code, notes, and snippets.

@stephensmitchell
Created November 28, 2025 00:28
Show Gist options
  • Select an option

  • Save stephensmitchell/159e41ff317a264c14b0fc34b913e372 to your computer and use it in GitHub Desktop.

Select an option

Save stephensmitchell/159e41ff317a264c14b0fc34b913e372 to your computer and use it in GitHub Desktop.
Get TreatAsPartInBOM status
import AlibreScript
def get_treat_as_part_in_BOM_status(assembled_item):
"""Get the TreatAsPartInBOM status of an AssembledItem.
Args:
assembled_item: The AssembledPart or AssembledSubAssembly object
Returns:
True/False for the TreatAsPartInBOM status, or None on error
"""
try:
Root = AlibreScript.API.Global.Root
top_session = Root.TopmostSession
occurrence = assembled_item.GetMappedOccurrence(top_session)
if occurrence is not None:
design_props = occurrence.DesignSession.DesignProperties
return design_props.TreatAsPartInBOM
return None
except Exception, ex:
print " Error getting status for %s: %s" % (assembled_item.Name, str(ex))
return None
Assy = CurrentAssembly()
for part in Assy.Parts:
status = get_treat_as_part_in_BOM_status(part)
print "%s: TreatAsPartInBOM = %s" % (part.Name, status)
for subassy in Assy.SubAssemblies:
status = get_treat_as_part_in_BOM_status(subassy)
print "%s: TreatAsPartInBOM = %s" % (subassy.Name, status)
>>>
measuring 110x140x16 6822 ZZ<1>: TreatAsPartInBOM = False
measuring 127x139x6,35 CSCA_CSXA050<1>: TreatAsPartInBOM = False
210_000_000 measuring 14x21x28<1>: TreatAsPartInBOM = False
measuring 15x32x8 16002<1>: TreatAsPartInBOM = False
210_000_000 measuring 16x18x70<1>: TreatAsPartInBOM = False
210_000_000 measuring 20x42x12_6004<1>: TreatAsPartInBOM = False
tool 10x19x5_6800<1>: TreatAsPartInBOM = False
tool 110x140x16 6822 ZZ<1>: TreatAsPartInBOM = False
tool2 110x140x16 6822 ZZ<1>: TreatAsPartInBOM = False
importing-exporting-data<1>: TreatAsPartInBOM = True
importing-exporting-data<2>: TreatAsPartInBOM = True
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment