How to use isOrientationAlognPath properly?

How to use isOrientationAlognPath properly?

tmelloCKF6Z
Explorer Explorer
527 Views
2 Replies
Message 1 of 3

How to use isOrientationAlognPath properly?

tmelloCKF6Z
Explorer
Explorer

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)

 

 
0 Likes
528 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor

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.

0 Likes
Message 3 of 3

tmelloCKF6Z
Explorer
Explorer

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!

 

0 Likes