<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SweepFeature path access errors in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sweepfeature-path-access-errors/m-p/11085963#M6267</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3278101"&gt;@codereclaimers&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried it and was able to replace the path without any problems.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# 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

        app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        # create sweep
        initSweep()

        vp: adsk.core.Viewport = app.activeViewport
        vp.fit()
        ui.messageBox('Before replacement')

        # get SweepFeature
        tl: adsk.fusion.Timeline = des.timeline
        sweepFeat: adsk.fusion.SweepFeature = adsk.fusion.SweepFeature.cast(
            tl.item(tl.markerPosition - 1).entity
        )
        if not sweepFeat:
            return

        # create new path
        newPathSkt: adsk.fusion.Sketch = root.sketches.add(
            root.xYConstructionPlane
        )
        pnts: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
        pnts.add(adsk.core.Point3D.create(0, 0, 0))
        pnts.add(adsk.core.Point3D.create(2, 1, 0))
        pnts.add(adsk.core.Point3D.create(2, 4, 3))
        pnts.add(adsk.core.Point3D.create(-2, 6, 6))
        newPathSkt.sketchCurves.sketchFittedSplines.add(pnts)

        path: adsk.fusion.Path = adsk.fusion.Path.create(
            newPathSkt.sketchCurves.sketchFittedSplines[0],
            adsk.fusion.ChainedCurveOptions.noChainedCurves
        )

        # replace　path
        sweepFeat.timelineObject.rollTo(True)
        sweepFeat.path = path

        tl.moveToEnd()

        vp.fit()
        ui.messageBox('After replacement')


    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def initSweep():
    app: adsk.core.Application = adsk.core.Application.get()
    des: adsk.fusion.Design = app.activeProduct
    root: adsk.fusion.Component = des.rootComponent

    profSkt: adsk.fusion.Sketch = root.sketches.add(
        root.yZConstructionPlane
    )
    profSkt.sketchCurves.sketchCircles.addByCenterRadius(
        adsk.core.Point3D.create(0, 0, 0),
        1.0
    )

    pathSkt: adsk.fusion.Sketch = root.sketches.add(
        root.xYConstructionPlane
    )
    pnts: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
    pnts.add(adsk.core.Point3D.create(0, 0, 0))
    pnts.add(adsk.core.Point3D.create(5, 1, 0))
    pnts.add(adsk.core.Point3D.create(6, 4, 3))
    pnts.add(adsk.core.Point3D.create(7, 6, 6))
    pathSkt.sketchCurves.sketchFittedSplines.add(pnts)

    path: adsk.fusion.Path = root.features.createPath(
        pathSkt.sketchCurves.sketchFittedSplines[0]
    )
    
    sweeps: adsk.fusion.SweepFeatures = root.features.sweepFeatures
    sweepIpt: adsk.fusion.SweepFeatureInput = sweeps.createInput(
        profSkt.profiles[0],
        path,
        adsk.fusion.FeatureOperations.NewBodyFeatureOperation
    )
    sweeps.add(sweepIpt)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may be a good idea to check if the shape of the path can be replaced in the GUI.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Apr 2022 00:54:49 GMT</pubDate>
    <dc:creator>kandennti</dc:creator>
    <dc:date>2022-04-06T00:54:49Z</dc:date>
    <item>
      <title>SweepFeature path access errors</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sweepfeature-path-access-errors/m-p/11084982#M6266</link>
      <description>&lt;P&gt;When a SweepFeature's path has been deleted, I get an error when attempting to set the path member of the SweepFeature object (note that &lt;STRONG&gt;&lt;EM&gt;spline&lt;/EM&gt;&lt;/STRONG&gt; is a SketchFittedSpline that was created to replace the original path):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;if obj.objectType == adsk.fusion.SweepFeature.classType():                        
    path = adsk.fusion.Path.create(spline, adsk.fusion.ChainedCurveOptions.noChainedCurves)
    obj.timelineObject.rollTo(True)
    obj.path = path&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;File "C:/Users/alan/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/SplineModificationTest/SplineModificationTest.py", line 35, in run&lt;/P&gt;&lt;P&gt;obj.path = path&lt;/P&gt;&lt;P&gt;File "C:\Users/alan/AppData/Local/Autodesk/webdeploy/production/19107935ce2ad08720646cb4a31efe37d8a5f41b/Api/Python/packages\adsk\fusion.py", line 66391, in _set_path&lt;/P&gt;&lt;P&gt;return _fusion.SweepFeature__set_path(self, value)&lt;/P&gt;&lt;P&gt;RuntimeError: 2 : InternalValidationError : curPath&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I want to update a SweepFeature that's been invalidated by other operations, am I just out of luck?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(I also get a similar error if I instead attempt to get the current path from the invalidated SweepFeature; I would expect it to return None.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 16:56:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sweepfeature-path-access-errors/m-p/11084982#M6266</guid>
      <dc:creator>codereclaimers</dc:creator>
      <dc:date>2022-04-05T16:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: SweepFeature path access errors</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sweepfeature-path-access-errors/m-p/11085963#M6267</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3278101"&gt;@codereclaimers&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried it and was able to replace the path without any problems.&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;# 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

        app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent

        # create sweep
        initSweep()

        vp: adsk.core.Viewport = app.activeViewport
        vp.fit()
        ui.messageBox('Before replacement')

        # get SweepFeature
        tl: adsk.fusion.Timeline = des.timeline
        sweepFeat: adsk.fusion.SweepFeature = adsk.fusion.SweepFeature.cast(
            tl.item(tl.markerPosition - 1).entity
        )
        if not sweepFeat:
            return

        # create new path
        newPathSkt: adsk.fusion.Sketch = root.sketches.add(
            root.xYConstructionPlane
        )
        pnts: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
        pnts.add(adsk.core.Point3D.create(0, 0, 0))
        pnts.add(adsk.core.Point3D.create(2, 1, 0))
        pnts.add(adsk.core.Point3D.create(2, 4, 3))
        pnts.add(adsk.core.Point3D.create(-2, 6, 6))
        newPathSkt.sketchCurves.sketchFittedSplines.add(pnts)

        path: adsk.fusion.Path = adsk.fusion.Path.create(
            newPathSkt.sketchCurves.sketchFittedSplines[0],
            adsk.fusion.ChainedCurveOptions.noChainedCurves
        )

        # replace　path
        sweepFeat.timelineObject.rollTo(True)
        sweepFeat.path = path

        tl.moveToEnd()

        vp.fit()
        ui.messageBox('After replacement')


    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def initSweep():
    app: adsk.core.Application = adsk.core.Application.get()
    des: adsk.fusion.Design = app.activeProduct
    root: adsk.fusion.Component = des.rootComponent

    profSkt: adsk.fusion.Sketch = root.sketches.add(
        root.yZConstructionPlane
    )
    profSkt.sketchCurves.sketchCircles.addByCenterRadius(
        adsk.core.Point3D.create(0, 0, 0),
        1.0
    )

    pathSkt: adsk.fusion.Sketch = root.sketches.add(
        root.xYConstructionPlane
    )
    pnts: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
    pnts.add(adsk.core.Point3D.create(0, 0, 0))
    pnts.add(adsk.core.Point3D.create(5, 1, 0))
    pnts.add(adsk.core.Point3D.create(6, 4, 3))
    pnts.add(adsk.core.Point3D.create(7, 6, 6))
    pathSkt.sketchCurves.sketchFittedSplines.add(pnts)

    path: adsk.fusion.Path = root.features.createPath(
        pathSkt.sketchCurves.sketchFittedSplines[0]
    )
    
    sweeps: adsk.fusion.SweepFeatures = root.features.sweepFeatures
    sweepIpt: adsk.fusion.SweepFeatureInput = sweeps.createInput(
        profSkt.profiles[0],
        path,
        adsk.fusion.FeatureOperations.NewBodyFeatureOperation
    )
    sweeps.add(sweepIpt)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may be a good idea to check if the shape of the path can be replaced in the GUI.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 00:54:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sweepfeature-path-access-errors/m-p/11085963#M6267</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-04-06T00:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: SweepFeature path access errors</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sweepfeature-path-access-errors/m-p/11085987#M6268</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3278101"&gt;@codereclaimers&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I made a mistake.&lt;BR /&gt;Indeed, in the case of Sweep, where the Path is an error that has been deleted, changing the Path was an error.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 01:15:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sweepfeature-path-access-errors/m-p/11085987#M6268</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2022-04-06T01:15:49Z</dc:date>
    </item>
  </channel>
</rss>

