How to select a pattern and suppress a element of pattern using ilogic

How to select a pattern and suppress a element of pattern using ilogic

aniketpunwatkar
Participant Participant
339 Views
1 Reply
Message 1 of 2

How to select a pattern and suppress a element of pattern using ilogic

aniketpunwatkar
Participant
Participant

I have been working on a project where I wanted user to pick pattern ,and enter the number of a element to suppress.

Here is my ilogic code for your help:

 

Imports Inventor

Dim doc As AssemblyDocument
doc = ThisApplication.ActiveDocument

' Attempt to pick an occurrence pattern
Dim selectedPattern As OccurrencePattern
selectedPattern = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrencePatternFilter, "Select a pattern")

If Not IsNothing(selectedPattern) Then
' Correctly reference the selected pattern
Dim oPattern As OccurrencePattern
oPattern = selectedPattern

' Get user input for the pattern element index
myparam = CInt(InputBox("Enter a value greater than 1", "Input", 2))

' Suppress the specified element in the pattern
If myparam > 0 And myparam <= oPattern.OccurrencePatternElements.Count Then
Dim oElement As OccurrencePatternElement
oElement = oPattern.OccurrencePatternElements.Item(myparam)
oElement.Suppressed = True
Else
MsgBox ("Invalid index. Please enter a value between 1 and ")
End If
Else
MsgBox ("No pattern selected.")
End If

 

 

 

 

0 Likes
Accepted solutions (1)
340 Views
1 Reply
Reply (1)
Message 2 of 2

AndrewHumiston
Advocate
Advocate
Accepted solution

Afternoon,

 

here is the code i came up with. there is a filter set to only allow for slection of patterns and an input box that will show the max number of instances.

 

Dim oAssyDoc As AssemblyDocument = ThisApplication.ActiveDocument

'select edge for second chamfer input
Dim oSelection As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrencePatternFilter, "Select First Chamfer Edge")

Dim Ans As Integer = InputBox("Set instance Number to Suppress" & vbNewLine & "From 1 to " & oSelection.OccurrencePatternElements.Count, "Suppress Instance", "#")

oSelection.OccurrencePatternElements.Item(Ans).Suppressed = True

 

please accept as solved if this meets your needs. 

 

please reach out with any other questions. thank you! 

0 Likes