column of BOM for “Area”of component

<?xml encoding=”UTF-8″>By Xiaodong Liang

Question:
Is there any way to get an area for the entire assembly on the BOM?  If you go to iProperties –> Physical it is shown there. But how to pull it from there and have it as Column in BOM? Can it be done using API ?

Solution:
Firstly, currently, no API to add/remove column of BOM. You have to add it manually in advance. The following is the steps to achieve your requirement. This also applies to Mass/Volume or other iProperties.

  1. In the component file (such as a part), add one custom iProperty manually e.g. named  “Area”. The type is Text.

image

  1. add a iLogic rule with the component file. It will get the Area value from iProperty, and update the custom iProperty.

image

<font color="#808080"><em><font size="1"><span>'</span><span>current document</span></font></em></font><span>
</span><font size="1"><span><font color="#800000">doc</font></span><span> </span><span><strong>=</strong></span><span> </span><span><font color="#800080"><strong>ThisDoc</strong></font></span><span>.</span><span><font color="#800080"><strong>Document</strong></font></span></font><span>
</span><font color="#808080"><em><font size="1"><span>'</span><span>unit manager of the document</span></font></em></font><span>
</span><font size="1"><span><font color="#800000">oUOM</font></span><span> </span><span><strong>=</strong></span><span> </span><span><font color="#800000">doc</font></span><span>.</span><span><font color="#800000">UnitsOfMeasure</font></span></font><span>
</span><font color="#808080"><em><font size="1"><span>'</span><span>get the value of Area</span></font></em></font><span>
</span><font size="1"><span><font color="#800000">surfaceArea</font></span><span> </span><span><strong>=</strong></span><span> </span><span><font color="#800080"><strong>iProperties</strong></font></span><span>.</span><span><font color="#800080"><strong>Area</strong></font></span></font><span>
</span><font color="#808080"><em><font size="1"><span>'</span><span>round the value with 4 valid numbers (optional)</span></font></em></font><span>
</span><font size="1"><span><font color="#800000">surfaceArea</font></span><span> </span><span><strong>=</strong></span><span> </span><strong><span><font color="#800080">Round</font></span><span>(</span></strong><span><font color="#800000">surfaceArea</font></span><span>, </span><strong><span>4</span><span>)</span></strong></font><font size="1"><span>
</span><font color="#808080"><em><span>'</span><span>convert the value to a string with the unit of the document</span></em></font></font><span>
</span><font size="1"><span><font color="#800000">surfaceArea</font></span><span> </span><span><strong>=</strong></span><span> </span><span><font color="#800000">surfaceArea</font></span><span>.</span><span><font color="#800000">ToString</font></span><span><strong>()</strong></span><span> </span><span><font color="#ff0000"><strong>+</strong></font></span><span> </span><font color="#008080"><span>"</span><span> </span><span>"</span></font><span> </span><span><font color="#ff0000"><strong>+</strong></font></span><span> </span><span><font color="#800000">oUOM</font></span><span>.</span><span><font color="#800000">GetStringFromType</font></span><span><strong>(</strong></span><span><font color="#800000">oUOM</font></span><span>.</span><span><font color="#800000">LengthUnits</font></span><span><strong>)</strong></span><span> </span><span><font color="#ff0000"><strong>+</strong></font></span><span> </span><font color="#008080"><span>"</span><span>^2</span><span>"</span></font></font><font size="1"><span>
</span><font color="#808080"><em><span>'</span><span>update the custom property "Area" we created</span></em></font></font><span>
</span><font size="1"><span><font color="#800080"><strong>iProperties</strong></font></span><span>.</span><strong><span><font color="#800080">Value</font></span><span>(</span></strong><font color="#008080"><span>"</span><span>Custom</span><span>"</span></font><span>, </span><font color="#008080"><span>"</span><span>Area</span><span>"</span></font><span><strong>)</strong></span><span> </span><span><strong>=</strong></span><span> </span><span><font color="#800000">surfaceArea</font></span></font>
  1. add this rule with the iLogic trigger “Part Geometry Change”thus when the model changes, the rule will be executed automatically and update the custom property.

 

image

 

  1. In the assembly >> BOM, add one custom column named “Area”.This column will read the custom property from the component.

image

 

image


Comments

One response to “column of BOM for “Area”of component”

  1. Thank you! This is great! It is also works for *.iam models.

Leave a Reply to AlexCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading