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: 

How to use isOrientationAlognPath properly?

2 REPLIES 2
Reply
Message 1 of 3
tmelloCKF6Z
126 Views, 2 Replies

How to use isOrientationAlognPath properly?

I am having trouble using the python API to set the Orientation of a path pattern to "Path Direction".

 

I have a body that I am patterning along a path (3d curve).  The body should be oriented with the path - not the default "Identical" option.

 

I have tried using both the PathPatternFeatureInput and the pathPatternFeaturesInput.  The feature input I can't seem to create properly (object and attributes appear to be set but the path feature is not made), while the features input will create a feature but won't have the proper orientation as specified. 

 

I believe I've seen some feature options access through the UI API, is there a solution using the ui feature dialog?

 

Any guidance would be helpful!

 

The code below yields an error that the "path_input" is not a PathPatternFeatureInput, yet the path_input classType is a PathPaternFeatureInput...

 

 

path_input = adsk.fusion.PathPatternFeatureInput
path_input.inputEntites = inputEntites
path_input.path=path
path_input.quantity = quantity
path_input.distance = patternDistance
path_input.patterDistanceType = adsk.fusion.PatternDistanceType.ExtentPatternDistanceType
path_input.isOrientationAlongPath = True

pathPattern = root.features.pathPatternFeatures

pathFeature = pathPattern.add(path_input)

 

 

I've also tried using a pathPatternInput which creates the feature but does not set the orientation as I would expect.

 

 

# Create the input for path pattern
pathPatterns = root.features.pathPatternFeatures

pathPatternInput = pathPatterns.createInput(inputEntites, path, quantity, patternDistance, adsk.fusion.PatternDistanceType.ExtentPatternDistanceType)

#set orientation
pathPatternInput.isOrientationAlongPath = True

# Create the path pattern
pathFeature = pathPatterns.add(pathPatternInput)

 

 
Labels (1)
2 REPLIES 2
Message 2 of 3
kandennti
in reply to: tmelloCKF6Z

Hi @tmelloCKF6Z .

 

I don't think you can create an instance with this way of writing.

path_input = adsk.fusion.PathPatternFeatureInput

Instances can be created using the method described at the bottom of the document.

1.png

 

As for the isOrientationAlognPath property, I tried it with the following script and attached data.

#Fusion360API Python script
import adsk.core, adsk.fusion, traceback

_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface
        des :adsk.fusion.Design = _app.activeProduct
        root :adsk.fusion.Component = des.rootComponent

        # select body
        msg :str = 'SelectBody'
        selFiltter :str = 'Bodies'
        sel :adsk.core.Selection = selectEnt(msg ,selFiltter)
        if not sel: return
        body :adsk.fusion.BRepBodies = sel.entity

        # select path
        msg :str = 'Select Sketch Curve'
        selFiltter :str = 'SketchCurves'
        sel :adsk.core.Selection = selectEnt(msg ,selFiltter)
        if not sel: return
        sketchCurve :adsk.fusion.SketchCurve = sel.entity
        
        # Create input entities for rectangular pattern
        inputEntites = adsk.core.ObjectCollection.create()
        inputEntites.add(body)
        
        # Create path for path pattern
        features :adsk.fusion.Features = root.features
        path = features.createPath(sketchCurve)
        
        # Quantity and distance
        quantity = adsk.core.ValueInput.createByString('10')
        patternDistance = adsk.core.ValueInput.createByString('50 cm')
        
        # Create the input for path pattern
        pathPatterns = features.pathPatternFeatures
        pathPatternInput = pathPatterns.createInput(
            inputEntites, 
            path, 
            quantity, 
            patternDistance, 
            adsk.fusion.PatternDistanceType.ExtentPatternDistanceType)


        # isOrientationAlongPath = True
        pathPatternInput.isOrientationAlongPath = True

        # Create the path pattern
        pathFeature = pathPatterns.add(pathPatternInput)
        pathFeature.name = 'True'


        # isOrientationAlongPath = False
        pathPatternInput.isOrientationAlongPath = False

        # Create the path pattern
        pathFeature = pathPatterns.add(pathPatternInput)
        pathFeature.name = 'False'


    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def selectEnt(
    msg :str, 
    filtterStr :str
    ) -> adsk.core.Selection :

    try:
        sel = _ui.selectEntity(msg, filtterStr)
        return sel
    except:
        return None

2.png

The blue color is "isOrientationAlognPath = False".
I think it works fine.

Message 3 of 3
tmelloCKF6Z
in reply to: kandennti

I appreciate your follow up.

The second set of code I posted seems identical to what you did, yet mine isn't working!  I re-ran it today and it worked!

 

Thank you for posting the proper use of this function!  It was very helpful!

 

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