Hi all,
I am trying to modify radius of curved body (cylinder/sphere) via API. I have tried the OffsetFeatures in the documentation but it seemed to offset the surface ONLY instead of the whole body.
I have used the sample code in the documentation:
def demo_offsetFeatures_add(rootComp: adsk.fusion.Design.rootComponent):
offsetFace = _ui.selectEntity('Select the face to offset.', 'Faces').entity
offsetFaces = adsk.core.ObjectCollection.create()
offsetFaces.add(offsetFace)
distance = adsk.core.ValueInput.createByReal(2)
operation = adsk.fusion.FeatureOperations.NewBodyFeatureOperation
offsetFeatures = rootComp.features.offsetFeatures
input = offsetFeatures.createInput(offsetFaces, distance, operation)
offsetFeature = offsetFeatures.add(input)
This results in a new surface body.
Is there any way to modify the radius of the solid body? Any help is appreciated!
Hi @j.han97 .
I thought I could just set the operation of OffsetFeatures.createInput to "JoinFeatureOperation".
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-2c24d7ef-a571-4d01-aa9f-987ee8620022
# Fusion360API Python script
import traceback
import adsk.fusion
import adsk.core
def run(context):
ui: adsk.core.UserInterface = None
try:
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
msg: str = 'Select the face to offset.'
selFiltter: str = 'Faces'
sel: adsk.core.Selection = selectEnt(msg, selFiltter)
if not sel:
return
# select face
offsetFace: adsk.fusion.BRepFace = sel.entity
# ObjectCollection
offsetFaces: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
offsetFaces.add(offsetFace)
# component
comp: adsk.fusion.Component = offsetFace.body.parentComponent
# OffsetFacesFeatures
offsetFeatures: adsk.fusion.OffsetFeatures = comp.features.offsetFeatures
# OffsetFeatureInput
offsetIpt: adsk.fusion.OffsetFeatureInput = offsetFeatures.createInput(
offsetFaces,
adsk.core.ValueInput.createByReal(2),
# adsk.fusion.FeatureOperations.NewBodyFeatureOperation # surface
adsk.fusion.FeatureOperations.JoinFeatureOperation # error
)
# create OffsetFeature
offsetFeature: adsk.fusion.OffsetFeature = offsetFeatures.add(offsetIpt)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def selectEnt(
msg: str,
filtterStr: str) -> adsk.core.Selection:
try:
app = adsk.core.Application.get()
ui = app.userInterface
sel = ui.selectEntity(msg, filtterStr)
return sel
except:
return None
When I actually try this, I get an error.
I was not able to Offset the solid.
Hi kandennti,
Thanks for your reply!
I have noticed this line in the documentation:
'NewBodyFeatureOperation' and 'NewComponentFeatureOperation' are the options supported.
I guess Fusion 360 API simply does not support this function at current stage.
Can't find what you're looking for? Ask the community or share your knowledge.