You can't scale an individual face in a body. However, you can copy a face out of a body to create a new body and then scale the new body and use the face in the new body for the replace. I was curious if the API supports everything you would need to do that and wrote a small script to test it out. It works. Besides scaling, I also rotate it a bit and then use it for the face replacement. Here's the code and I've attached the model I tested it with. I used the contoured face on the top of the model. The script has you select it.
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
root = design.rootComponent
# Have a face selected.
faceSel = ui.selectEntity('Select a face', 'Faces')
face = adsk.fusion.BRepFace.cast(faceSel.entity)
# Create an offset of the face to copy it.
objs = adsk.core.ObjectCollection.create()
objs.add(face)
offsetInput = root.features.offsetFeatures.createInput(objs, adsk.core.ValueInput.createByReal(0), adsk.fusion.FeatureOperations.NewBodyFeatureOperation, False)
offsetFeature = root.features.offsetFeatures.add(offsetInput)
# Scale the face body.
offsetBody = offsetFeature.bodies[0]
objs.clear()
objs.add(offsetBody)
scaleInput = root.features.scaleFeatures.createInput(objs, root.originConstructionPoint, adsk.core.ValueInput.createByReal(1.5))
scaleFeature = root.features.scaleFeatures.add(scaleInput)
# Define a transform to rotate the face body.
newFace = adsk.fusion.BRepFace.cast(scaleFeature.faces[0])
bnds = newFace.boundingBox
center = adsk.core.Point3D.create((bnds.minPoint.x + bnds.maxPoint.x)/2,
(bnds.minPoint.y + bnds.maxPoint.y)/2,
(bnds.minPoint.z + bnds.maxPoint.z)/2)
current = adsk.core.Matrix3D.create()
current.translation = center.asVector()
trans = current.copy()
trans.invert()
rot = adsk.core.Matrix3D.create()
rot.setToRotation(math.pi/16, adsk.core.Vector3D.create(1,0,0), adsk.core.Point3D.create(0,0,0))
# Use a move feature to rotate it.
trans.transformBy(rot)
trans.transformBy(current)
moveInput = root.features.moveFeatures.createInput(objs, trans)
moveFeature = root.features.moveFeatures.add(moveInput)
# Replace the original face with the new face.
sourceColl = adsk.core.ObjectCollection.create()
sourceColl.add(face)
targetColl = adsk.core.ObjectCollection.create()
targetColl.add(moveFeature.faces[0])
replaceInput = root.features.replaceFaceFeatures.createInput(sourceColl, False, targetColl)
root.features.replaceFaceFeatures.add(replaceInput)
# Hide the new face.
moveFeature.bodies[0].isVisible = False
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com