Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
gcoombridge
in reply to: Anonymous

Hi, this is what I was using for something similar. This was for iLogic not VBA. In this case the extrusions are already created - I just wanted to make sure they cut through every solid. It does require all cut extrusions to come after new solids in the tree I think (otherwise it is adding bodies to the collection that don't exist when the subtraction is taking place). A try/catch operation would probably fix that... I also planned to add revolves in there but haven't had time.

 

'This rule compiles all the solids created by extrusions and commands all cuts to cut through all solids
'This is required where you have an unknown amount of solids to cut through (i.e. tank strakes)
Dim oDoc As PartDocument
oDoc = ThisDoc.Document
Dim oPartDef As ComponentDefinition
oPartDef = oDoc.ComponentDefinition

'create a collection to hold the solids to act on
Dim oExtrusion As ExtrudeFeature 
Dim NewBodyObjCol As ObjectCollection
NewBodyObjCol = ThisApplication.TransientObjects.CreateObjectCollection

'Iterate through each extrudefeature in part, establish if its a cut and then set to the list of all bodies
For Each oExtrusion In oPartDef.Features.ExtrudeFeatures
	'If an extrusion creates a new solid then add the solid it creates to a collection
	If oExtrusion.Definition.Operation = kNewBodyOperation Then
		NewBodyObjCol.Add(oExtrusion.Definition.AffectedBodies.Item(1))
			'Alternatively if the extrusion is a cut then use the collection created above to cut through everything
	Else If oExtrusion.Definition.Operation = kCutOperation Then
		oExtrusion.SetAffectedBodies(NewBodyObjCol)
	End If
Next oExtrusion


	

Cheers, Glenn

Use iLogic Copy? Please consider voting for this long overdue idea (not mine):https://forums.autodesk.com/t5/inventor-ideas/string-replace-for-ilogic-design-copy/idi-p/3821399