Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic: turn part visibility on/off

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Jefkee
5244 Views, 3 Replies

iLogic: turn part visibility on/off

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!

Inventor 2013
3 REPLIES 3
Message 2 of 4
salariua
in reply to: Jefkee

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.

Adrian S.
blog.ads-sol.com 

AIP2012-2020 i7 6700k AMD R9 370
Did you find this reply helpful ?
If so please use the Accepted Solutions or Like button - Thank you!
Message 3 of 4
cwhetten
in reply to: Jefkee

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:

 

SetDesignViewRepresentation Method.PNG

 

 

Please click "Accept as Solution" if this response answers your question.

Cameron Whetten
Inventor 2014

Message 4 of 4
Jefkee
in reply to: cwhetten

Thanks!! works like a charm!!

Inventor 2013

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report