• Blog posts

    Bio

    By Luke Davenport

    A little iLogic break for you guys – Here’s how you can link your positional and view representations in an Inventor assembly (so that if you change the active positional rep, the view rep automatically changes). This will allow simple control of part visibility, colour overrides and view angle (View Rep) as well as positional changes based on assembly constraints (Pos Rep). Here’s all the code I’ve used (thanks to Curtis Waguespack for the meaty bits) – and check out this video for more information. Enjoy!

     

    Code for Using an iLogic Form

     

    ' set a reference to the assembly component definintion.

    ' This assumes an assembly document is open.

    Dim oAsmCompDef As AssemblyComponentDefinition

    oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

     

    'set View and Positional Representation based on parameter

    If SetViewandPosReps = "CLOSED" Then

    oAsmCompDef.RepresentationsManager.PositionalRepresentations.Item("CLOSED").activate

    oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("CLOSED").activate

    Else If SetViewandPosReps = "OPEN" Then

    oAsmCompDef.RepresentationsManager.PositionalRepresentations.Item("OPEN").activate

    oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("OPEN").activate

    End If

     

    Set View Rep Based on Active Positional Rep.

    ' set a reference to the assembly component definintion.

    ' This assumes an assembly document is open.

    Dim oAsmCompDef As AssemblyComponentDefinition

    oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

     

    'set View Representation based on the active Positional Representation

    If oAsmCompDef.RepresentationsManager.ActivePositionalRepresentation.Name = "CLOSED" Then

    oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("CLOSED").activate

    ElseIf oAsmCompDef.RepresentationsManager.ActivePositionalRepresentation.Name = "OPEN" Then

    oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("OPEN").activate

    End If