"ThisBOM: Could not find the part number"

"ThisBOM: Could not find the part number"

Anonymous
Not applicable
1,178 Views
10 Replies
Message 1 of 11

"ThisBOM: Could not find the part number"

Anonymous
Not applicable

I'm trying to gather part quantities from the BOM via iLogic so that I can apply pricing via code. I have used the iLogic snippet:

 

 

quantity = ThisBOM.CalculateQuantity("Model Data", partNumber)  

 

... but it only works on parts that Inventor names automatically. If I enter a Part Name via iProperties or use iLogic to dynamically generate a part number, I get the error:

 

Error in rule: myRule, in document: My Assembly.iam

ThisBOM: Could not find the part number "100001" in the BOM.

 

The code works in all virtual components though. Anyone know how to get around this? 

 

Thanks!

 

 

 

 

0 Likes
1,179 Views
10 Replies
Replies (10)
Message 2 of 11

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

Sorry I have not got clearly on the scenario. Is that part  placed to the assembly? Could you share a sample file dataset for diagnose? Thank you.

0 Likes
Message 3 of 11

Anonymous
Not applicable

Hi Xiaodong Liang,

 

I could if it were private. They are client files. Can you send your email address?

0 Likes
Message 4 of 11

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

I assume that you could reproduce the behaviour with a simple assembly as well: one assembly + one part

 

The question is:

- what exactly are you renaming and how? 

- what values are you passing to ThisBOM.CalculateQuantity() - i.e. the value of partNumber variable, where you get it from?

 

When I changed the Project >> Part Number value of the part in iProperties dialog of the part, then that value worked fine with ThisBOM.CalculateQuantity inside the containing assembly. 

 

Cheers,



Adam Nagy
Autodesk Platform Services
0 Likes
Message 5 of 11

tolgay.hickiran
Advisor
Advisor
There is always the other way around.

Use Occurances for your parts and count them in. We use Occurances for all the assemblies that have "Level of Detail" representations. If you happen to be using LoDs you might face such a problem that you are facing.

You can find a similar code how to count all the part occurances in an assembly or i can share it with you here if needed.

Some worthwhile ideas
Copy Design should rename ilogic Rules too!
Why Nastran In-CAD doesn't have an SDK?IMPLEMENTED!

Tolgay Hickiran
Founding Partner
SignatureSignature

website
emailskypelinkedinyoutubeemail

0 Likes
Message 6 of 11

Anonymous
Not applicable

From your message I found that the iLogic snippet:

 

quantity = ThisBOM.CalculateQuantity("Model Data", partNumber)

...only works within a single assembly, and cannot traverse to the sub assemblies. Which makes it pretty useless. I would like to be able to access the 'Parts Only' information that is in the top level BOM.  If you have a way to do that it would be great.

 

Thanks anyways.

 

 

 

0 Likes
Message 7 of 11

Anonymous
Not applicable

If you want to use the "Parts Only" BOM Quantity you must be in the Master LoD, hope this helps...

 

Try this

 

SyntaxEditor Code Snippet

'Change to Master Level of Detail
ThisApplication
.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Master").Activate
'Get the quantity
quantity = ThisBOM.CalculateQuantity("Parts Only", partNumber)
'Change back to your Level of Detail
ThisApplication.ActiveDocument.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Your Level Of Detail").Active
0 Likes
Message 8 of 11

tolgay.hickiran
Advisor
Advisor

There is a problem with using Master LoD;

 

You wouldn't get the right quantities if there are some parts that are suppressed etc. on the other LoD. Its not a good idea.


Some worthwhile ideas
Copy Design should rename ilogic Rules too!
Why Nastran In-CAD doesn't have an SDK?IMPLEMENTED!

Tolgay Hickiran
Founding Partner
SignatureSignature

website
emailskypelinkedinyoutubeemail

0 Likes
Message 9 of 11

Anonymous
Not applicable

Yea, I saw that. I don't use the Master LOD for the majority of my assembles....they are set to iLogic. I guess I'll have to code it longhand again. It really blows that iLogic has such poor access to the BOM. Thanks for the replies folks!

 

 

0 Likes
Message 10 of 11

Anonymous
Not applicable

I've used this code a couple of times and even though i'm switching to Master LoD it keeps my quantities correctly, as long as I run the rule in my custom LoD, give it a try... It worked for me

0 Likes
Message 11 of 11

Anonymous
Not applicable

Thanks, I'll give it a shot and post how it went.

0 Likes