iLogic commands for adding a participant to a cut..

iLogic commands for adding a participant to a cut..

Anonymous
Not applicable
4,061 Views
21 Replies
Message 1 of 22

iLogic commands for adding a participant to a cut..

Anonymous
Not applicable

Hi guys,

 

I have a pattern that patterns a number of wall panels into a room, depending on the width of the room.. I have a cut that runs along the top to take the slope of the room that cuts the panels to the height of the room at various points.

 

When i change the width, the number of components in the pattern change, but the cut will ignore them until I add participant manually.. I dont want to do this manually.

 

I have trawled the net but to no avail.. Can anyone help with this??

 

Thanks 

Mike

0 Likes
4,062 Views
21 Replies
Replies (21)
Message 21 of 22

dgreatice
Collaborator
Collaborator

Try this,

 

using Vba.net:

Public Sub AddParticipant()
Dim oApp As Application
Dim oAD As AssemblyDocument
Dim oACD As AssemblyComponentDefinition
Dim oFeats As Features
Dim oObjFeat As Object
Dim oObjCompCol As ObjectCollection
Dim oCoCC As ComponentOccurrence
Dim oFirstStep As Boolean
Dim oSecondStep As Boolean
oFirstStep = False
oSecondStep = False
Dim oIE As InteractionEvents
Dim oSE As SelectEvents
Dim oSelect As clsSelect

Set oApp = ThisApplication

If oApp.ActiveDocumentType = kAssemblyDocumentObject Then
Set oAD = oApp.ActiveDocument
Set oACD = oAD.ComponentDefinition
Set oFeats = oACD.Features
Set oObjCompCol = oApp.TransientObjects.CreateObjectCollection

Do Until oFirstStep = True
Set oObjFeat = oApp.CommandManager.Pick(kAssemblyFeatureFilter, "Pick feature. Esc to exit.")

If oObjFeat Is Nothing Then
WantContinueSelecting = MsgBox("No feature are selected, want continue selecting?", vbYesNo + vbCritical, "Selection Feature Result")
If WantContinueSelecting = vbYes Then
oFirstStep = False
Else
Set oObjCompCol = Nothing
Set oFeats = Nothing
Set oACD = Nothing
Set oAD = Nothing
Set oApp = Nothing
Exit Sub
End If
Else
oFirstStep = True
End If
Loop

Do Until oSecondStep = True
Set oSelect = New clsSelect
oSelect.Pick SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, oObjCompCol

If oObjCompCol.Count = 0 Then
WantContinueSelecting = MsgBox("No component are selected, want continue selecting?", vbYesNo + vbCritical, "Selection Component Result")
If WantContinueSelecting = vbYes Then
oSecondStep = False
Else
Exit Sub
End If
Else
oSecondStep = True
End If
Loop

For Each Item In oObjCompCol
oObjFeat.AddParticipant Item
Next

End If
End Sub

 

create class module, name it "clsSelect" :

Private WithEvents oInteractEvents As InteractionEvents
Private WithEvents oSelectEvents As SelectEvents

' Declare a flag that's used to determine when selection stops.
Private bStillSelecting As Boolean

Public Function Pick(ByVal filter As SelectionFilterEnum, ByRef oBjcol As ObjectCollection) As Object
' Initialize flag.
bStillSelecting = True

' Create an InteractionEvents object.
Set oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents

' Ensure interaction is enabled.
oInteractEvents.InteractionDisabled = False

' Set a reference to the select events.
Set oSelectEvents = oInteractEvents.SelectEvents

' Set the filter using the value passed in.
oSelectEvents.AddSelectionFilter filter
oSelectEvents.WindowSelectEnabled = True
' Start the InteractionEvents object.
' bTooltipEnabled = ThisApplication.GeneralOptions.ShowCommandPromptTooltips
ThisApplication.GeneralOptions.ShowCommandPromptTooltips = True

oInteractEvents.StatusBarText = "Please select component. Esc to exit."

oInteractEvents.Start

' Loop until a selection is made.
Do While bStillSelecting
ThisApplication.UserInterfaceManager.DoEvents
Loop

' Get the selected item. If more than one thing was selected,
' just get the first item and ignore the rest.
Dim oSelectedEnts As ObjectsEnumerator
Set oSelectedEnts = oSelectEvents.SelectedEntities

If oSelectedEnts.Count > 0 Then
For Each Item In oSelectedEnts
oBjcol.Add Item
Next
Else
Set Pick = Nothing
End If

' Stop the InteractionEvents object.
oInteractEvents.Stop

' Clean up.
Set oSelectEvents = Nothing
Set oInteractEvents = Nothing
End Function

Private Sub oInteractEvents_OnTerminate()
' Set the flag to indicate we're done.
bStillSelecting = False
End Sub

Private Sub oSelectEvents_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As View)
' Set the flag to indicate we're done.
bStillSelecting = False
End Sub

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 22 of 22

Anonymous
Not applicable

Thank you for your response.  I will try this and see if I get better results then what I have been using, which has been a bit inconsistent. 

0 Likes