Trying to work with the combine feature like you suggested. Makes sense. I just can't figure it out. Looked at a lot of code in the forums, but can't seem to get any of it to work.
Code above this created the screw body and now I am trying to make the second body in the component.
#create the body clearance
subtractBodySketch = sketches.add(xyPlane)
subtractBodySketch.sketchCurves.sketchCircles.addByCenterRadius(center, self.bodyClearance/2)
subtractBodyProf = subtractBodySketch.profiles[0]
subtractBodyExtInput = extrudes.createInput(subtractBodyProf, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
subtractBodyExtInput.setAllExtent(adsk.fusion.ExtentDirections.NegativeExtentDirection)
distance = adsk.core.ValueInput.createByReal(BodyLength-( BodyDiameter * ThreadEngage ))
subtractBodyExtInput.setDistanceExtent(False, distance)
subtractBodyExt = extrudes.add(subtractBodyExtInput)
# create the head clearance
subtractHeadSketch = sketches.add(xyPlane)
subtractHeadSketch.sketchCurves.sketchCircles.addByCenterRadius(center, self.headClearance/2)
subtractHeadProf = subtractHeadSketch.profiles[0]
subtractHeadExtInput = extrudes.createInput(subtractHeadProf, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
subtractHeadExtInput.setAllExtent(adsk.fusion.ExtentDirections.NegativeExtentDirection)
distance = adsk.core.ValueInput.createByReal(ClearanceLength-BodyLength+( BodyDiameter * -1.5 ))
subtractHeadExtInput.setDistanceExtent(False, distance)
subtractHeadExt = extrudes.add(subtractHeadExtInput)
# create the tap drill hole
subtractTapDrillSketch = sketches.add(xyPlane)
subtractTapDrillSketch.sketchCurves.sketchCircles.addByCenterRadius(center, self.tapDrill/2)
subtractTapDrillProf = subtractTapDrillSketch.profiles[0]
subtractTapDrillExtInput = extrudes.createInput(subtractTapDrillProf, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
subtractTapDrillExtInput.setAllExtent(adsk.fusion.ExtentDirections.NegativeExtentDirection)
distance = adsk.core.ValueInput.createByReal(BodyLength + BodyDiameter)
subtractTapDrillExtInput.setDistanceExtent(False, distance)
subtractTapDrillExt = extrudes.add(subtractTapDrillExtInput)
# create tap drill point
drillPointSketch = sketches.add(xyPlane)
center1 = adsk.core.Point3D.create(0, 0, (BodyLength + BodyDiameter))
distance = adsk.core.ValueInput.createByReal(BodyLength)
distance1 = adsk.fusion.DistanceExtentDefinition.create(distance)
deg = adsk.core.ValueInput.createByString('-57 deg')
drillPointSketch.sketchCurves.sketchCircles.addByCenterRadius(center1, self.tapDrill/2)
drillPointExtProf = drillPointSketch.profiles[0]
drillPointExtInput = extrudes.createInput(drillPointExtProf, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
drillPointExtInput.setOneSideExtent(distance1, adsk.fusion.ExtentDirections.PositiveExtentDirection, deg)
drillPointExt = extrudes.add(drillPointExtInput)
# create subtract body with combine
subtractBody = subtractHeadExtInput
bodyCollection = adsk.core.ObjectCollection.create()
bodyCollection.add(subtractHeadExtInput)
bodyCollection.add(subtractBodyExtInput)
bodyCollection.add(subtractTapDrillExtInput)
bodyCollection.add(drillPointExtInput)
model = design.activeComponent
features = model.features
combineFeatures = features.combineFeatures
combineFeatureInput = combineFeatures.createInput(subtractBody, bodyCollection)
subtractBody = combineFeatures.add(combineFeatureInput)
When I hit the line in red, I get the following error.
I don't understand it at all.
Any help appreciated.