Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Design View Reps of pattern members using A.P.I.?

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
367 Views, 3 Replies

Design View Reps of pattern members using A.P.I.?

Hello,

 

I was wondering if anyone knows how to change the Design View Reps of the members of a pattern using iLogic or A.P.I. code.

I have been working on a rule to do this, but the best I've been able to do is get the pattern members Design View reps to change to "Master".

I need them to be set to "Default".

 

Also, the number of members in the pattern varies and that is why I cannot manually change the Design View Representation to "Default" and check the Assocciative checkbox. When the number in the pattern changes, the Design View Reps are reset to Master.

 

Can anyone help with this?

3 REPLIES 3
Message 2 of 4
wayne.brill
in reply to: Anonymous

Hi,

 

I may need to get your assembly to test this. Below is the VBA code I used with my simple assembly and it is changing the active view rep of pattern elements.

 

In the assembly I am testing with, "View1" has a component that is not visible. When I run the code the component displays if one of these lines is uncommented.

' oCC.SetDesignViewRepresentation ("Default")
'oCC.SetDesignViewRepresentation ("Master") 

 

 

Public Sub occPatternRep_Test()
   
    Dim occPats As OccurrencePatterns
    Set occPats = ThisApplication.ActiveDocument.ComponentDefinition.OccurrencePatterns
   
    Dim occPat As OccurrencePattern
    Set occPat = occPats.Item(1)
 
    Dim circOctPat As CircularOccurrencePattern
    Set circOctPat = occPat
   
    Dim occPatElem As OccurrencePatternElement
    Dim oCC As ComponentOccurrence
    For Each occPatElem In circOctPat.OccurrencePatternElements
        ' Get the component used by OccurrencePatternElement
        Set oCC = occPatElem.Components(1)
        'Change the design view
       ' oCC.SetDesignViewRepresentation ("Default")
        oCC.SetDesignViewRepresentation ("View1")
       'oCC.SetDesignViewRepresentation ("Master")
    Next
  
End Sub

 

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
Anonymous
in reply to: wayne.brill

Hello Wayne,

 

My assembly has multiple patterns.

How can I have the code locate the specific pattern name in the tree, count the number of members in the pattern and then switch their design view reps to "Default"?

 

Len

Message 4 of 4
wayne.brill
in reply to: Anonymous

Hi Len,

 

You can use the name property of the OccurrencePattern in a for loop to find the pattern. The
OccurrencePatternElements.Count property will get the number of  OccurrencePatternElement. Here is a VBA example I tested.

 

Public Sub occPatternRep_Test2()
   
    Dim occPats As OccurrencePatterns
    Set occPats = ThisApplication.ActiveDocument.ComponentDefinition.OccurrencePatterns
 
    Dim occPat As OccurrencePattern
    Dim occPatElem As OccurrencePatternElement
    Dim oCC As ComponentOccurrence
   
    For Each occPat In occPats
        ' Finding the pattern using the name
       ' If occPat.Name = "Component Pattern 2:1" Then
       If occPat.Name = "Component Pattern 3:1" Then
           'If occPat.OccurrencePatternElements.Count = 4 Then
            If occPat.OccurrencePatternElements.Count = 2 Then
              For Each occPatElem In occPat.OccurrencePatternElements
                ' Get the component used by OccurrencePatternElement
                Set oCC = occPatElem.Components(1)
                'Change the design view
                oCC.SetDesignViewRepresentation ("Default")
               ' oCC.SetDesignViewRepresentation ("View1")
               Next occPatElem
             End If
             Exit For
        End If
     Next occPat
End Sub

 

 

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report