Hi,
I made a "configurator" and it almost works. It just needs some fine-tuning and that's why i'm here.
I have several components in my "configurator" that can be turned on and off. This by setting the visibility true/false and changing the BOM-structure. (see code example).
If Nozzle_aan_uit_getal = 1 Then 'Nozzle is ON Component.Visible("Nozzle 001 Assembly") = True 'Visible Component.InventorComponent("Nozzle 001 Assembly").BOMStructure = BOMStructureEnum.kDefaultBOMStructure 'Sets BOM Structure to Default (Includes on BOM) Else 'Nozzle is OFF Component.Visible("Nozzle 001 Assembly") = False 'Invisible Component.InventorComponent("Nozzle 001 Assembly").BOMStructure = BOMStructureEnum.kReferenceBOMStructure 'Sets BOM Structure to Reference (Includes on BOM) End If
This works but it has a little problem. Every time a component is turned from OFF to ON the view-representation is set to MASTER (this is a problem).
I found a rule that allows me to set ALL components to default view but it's not ideal. Is there a way to add it into my rule?
Example
IF the nozzle = ON Then
- The nozzle is visible
- The nozzle has BOM-structure DEFAULT
- The nozzle it's View-representation = ASSOCIATIVE to default
Else
- The nozzle is invisible
- The nozzle has BOM-structure REFERENCE
Or is there no way to do this? I looked in the API but couldn't find a direct solution like this. Only the one that works for all the components.
Thanks for the time and effort!
Solved! Go to Solution.
Solved by cwhetten. Go to Solution.
How about getting the current design view and activate it at the end of the operation ?
This are bits of code from Curtis's posts:
'set a reference to the assembly component definintion. Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 'define view rep Dim oViewRep As DesignViewRepresentation 'record the active view rep name Dim sActiveViewRep As String sActiveViewRep = oAsmCompDef.RepresentationsManager.ActiveDesignViewRepresentation.Name If Nozzle_aan_uit_getal = 1 Then 'Nozzle is ON Component.Visible("Nozzle 001 Assembly") = True 'Visible Component.InventorComponent("Nozzle 001 Assembly").BOMStructure = BOMStructureEnum.kDefaultBOMStructure 'Sets BOM Structure to Default (Includes on BOM) Else 'Nozzle is OFF Component.Visible("Nozzle 001 Assembly") = False 'Invisible Component.InventorComponent("Nozzle 001 Assembly").BOMStructure = BOMStructureEnum.kReferenceBOMStructure 'Sets BOM Structure to Reference (Includes on BOM) End If 'Set previous design view rep oViewRep = oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item(sActiveViewRep) oViewRep.Activate
Go thank him if it works.
You would get more luck by posting this in the inventor customization forum.
Give this a try:
Component.InventorComponent("Nozzle 001 Assembly").SetDesignViewRepresentation("Name_of_component_view_rep_here", , True)
The True/False statement controls whether the view representation is set to associative. Don't forget the extra comma, it must be there. The image below is the description of the ComponentOccurrence.SetDesignViewRepresentation method from the API help documentation:
Please click "Accept as Solution" if this response answers your question.
Cameron Whetten
Inventor 2014