Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Modify radius of solid body (cylinder/sphere)

2 REPLIES 2
Reply
Message 1 of 3
j.han97
201 Views, 2 Replies

Modify radius of solid body (cylinder/sphere)

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.

jhan97_0-1633674088164.png

Is there any way to modify the radius of the solid body? Any help is appreciated!

 

Labels (1)
2 REPLIES 2
Message 2 of 3
kandennti
in reply to: j.han97

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.

Message 3 of 3
j.han97
in reply to: kandennti

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.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report