Suppressing part within a nested assembly using iLogic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am building a parametric model and sometimes subassemlies within that model need to be changed. I do this by suppressing parts in these subassemblies. This all is done using an if statement to determine which product is wanted. My iLogic scripts then suppress certain components, turn mates on or off and set the dimensions used by the model.
This all is run through a iLogic script in my main assembly. I call this "run all rules". Within that rule I trigger parts of my assembly to update using the following:
iLogicVb.RunRule("xxxx.iam", "Run all rules") 'description of which subassembly or part this line refers to
This works fine for assemblies where I only change dimensions or mates. But suppressing parts gives me problems.
The problems seem to stem form the fact that a level of detail is required to save suppression states. And when I run this rule from my main assembly it may happen that the assembly is not opened in the right level of detail.
I have tried adding this piece of code to trigger before all other rules when the rule within the document is called:
Dim doc As AssemblyDocument = ThisDoc.Document Dim oLOD As LevelOfDetailRepresentation Dim oAsmCompDef As ComponentDefinition oAsmCompDef = doc.ComponentDefinition Try oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("iLogic").Activate(True) Catch Dim nLOD As LevelOfDetailRepresentation nLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Add("iLogic") oLOD = nLOD Finally oLOD = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("iLogic").Activate(True) End Try
What this does is it changes the active level of detail to a level of detail called iLogic. This piece of code works when manually running the rule from the subassembly, but also gives errors when run through the main assembly.
Now for the fun part. When I open the subassembly and manually trigger my rule all parts get suppressed and the model works. When i run the same rule from the main assembly, I get the following errors (in order):
000076255.iam is the subassembly where i want to change dimensions, suppress components and change mates.
First opening the part using and then running the rule as if i where to trigger it myself has also yielded no results.
What I would like to know is what happens when inventor executes this piece of code:
iLogicVb.RunRule("000076255.iam", "Run all rules")
And how can I influence which level of detail it uses. Any help is greatly appreciated.