Include all part occurrences in assembly feature

Include all part occurrences in assembly feature

Tony__Watkins
Explorer Explorer
328 Views
1 Reply
Message 1 of 2

Include all part occurrences in assembly feature

Tony__Watkins
Explorer
Explorer

I have a component pattern (12' lengths of material) that varies in quantity with respect to the overall length needed.  I then have an assembly cut that trims the last  occurrence to the desired overall length.  When the overall length is increased the added occurrences are not included in the assembly cut.  I manually "add participant" so it is included.  I think I need to have the ability to include all occurrences.  Is this the correct approach and if so how can I code it.

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

WCrihfield
Mentor
Mentor
Accepted solution

Hi @Tony__Watkins.  That is a fairly common problem when trying to automate assemblies with extrude/cut features.  You basically need to find that feature by code, then loop through every component in your assembly, and use the ExtrudeFeature.AddParticipant method.  The process is not very efficient, but does usually seem to work.  Here is one of the iLogic rules I a have used in one of my projects.  It could be shortened a bit, if you don't need the feedback.  You will need to change the name of the ExtrudeFeature to your feature's name.

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then Exit Sub
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oExtFeats As ExtrudeFeatures = oADef.Features.ExtrudeFeatures
Dim oExtFeat As ExtrudeFeature = Nothing
Dim sExtFeatName As String = "CUT REAR OFF TO LENGTH"
For Each oExtFeat In oExtFeats
	If oExtFeat.Name = sExtFeatName Then
		Exit For 'oExtFeat variable will retain its value
	End If
Next 'oExtFeat
If oExtFeat Is Nothing Then
	MsgBox("The ExtrudeFeature named '" & sExtFeatName & "' was not found." _
	& vbCrLf & "...So it could not be updated.", vbCritical, "iLogic")
	Exit Sub
End If
For Each oOcc As ComponentOccurrence In oADef.Occurrences
	Try : oExtFeat.RemoveParticipant(oOcc) : Catch : End Try
	Try : oExtFeat.AddParticipant(oOcc) : Catch : End Try
Next 'oOcc
oADoc.Update2(True)

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)