iLogic. Retrieve parent assembly property (like stock number) by child part rule

Vadim-the-Engineer
Advocate

iLogic. Retrieve parent assembly property (like stock number) by child part rule

Vadim-the-Engineer
Advocate
Advocate

My goal is to force every part that created inside the parent assembly to retrieve property from the parent assembly and copy the property to itself (for example Stock Number)

 

SyntaxEditor Code Snippet

stockNum = iProperties.Value(ThisDoc.Path, "Project" , "Stock Number")
iProperties.Value("Project", "Stock Number") = stockNum

I believe instead of "ThisDoc.Path" should be some other command...

 

I also found an example to do such an operation from assembly rule other than part rule however it runs in a loop over all parts each time to change their properties which not good enough considering I'd like to retrieve different properties for different kind of parts...

For better understanding: parts are saved as templates and created using iLogic within the assembly...

0 Likes
Reply
Accepted solutions (1)
2,052 Views
6 Replies
Replies (6)

tdant
Collaborator
Collaborator

MechMachineMan
Advisor
Advisor

Inventor also doesn't store Parent file information in parts.

 

Parts only contain information about that part.

 

Assemblies are like a recipe and tell you what files are needed.

 

To get parent information, you need to instead iterate through the assembly and add the information to that assemblies children components.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type

tdant
Collaborator
Collaborator

As long as there's some way to distinguish which parts need changes from the assembly level, the iLogic is not that difficult. Is there some sort of naming convention that's reliable enough to tell what parts need to be updated?

Vadim-the-Engineer
Advocate
Advocate

There is actually: SC1, SC2..., TS1, TS2..., LL1, LL2..., LT, RB... could You give me an example for recognizing part by name, please?

0 Likes

tdant
Collaborator
Collaborator
Accepted solution

This loop, placed in a rule at the parent assembly level, will find all instances of a part in the assembly with the target name and do something to them:

 

SyntaxEditor Code Snippet

Dim targetVariable As String
targetVariable
= "part name" For Each oOcc In ThisDoc.Document.ComponentDefinition.Occurrences.AllLeafOccurrences If InStr(oOcc.Name, targetVariable) Then 'do something to the part found by name End If Next

 

Vadim-the-Engineer
Advocate
Advocate

This should do the trick. Thank You very much!

0 Likes