<?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: Array of spline ? in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/array-of-spline/m-p/6401703#M19681</link>
    <description>&lt;P&gt;HI,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to define empty arrays first, and then append items to the arrays. I made a little change on your script, then it should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;import adsk.core, adsk.fusion, traceback
 
def run(context):
    ui = None
    try:
     
        app = adsk.core.Application.get()
        ui = app.userInterface
         
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        design = app.activeProduct
         
        # Get the root component of the active design.
        rootComp = design.rootComponent
         
        # Create a new sketch on the xy plane.
        sketch = rootComp.sketches.add(rootComp.xYConstructionPlane)
         
        points = []
        spline = []
        # Create an object collection for the points.
        points.append(adsk.core.ObjectCollection.create())
        # Define the points the spline with fit through.
        points[0].add(adsk.core.Point3D.create(0, 0, 0))
        points[0].add(adsk.core.Point3D.create(5, 1, 0))
        points[0].add(adsk.core.Point3D.create(6, 4, 3))
        # Create the spline.
        spline.append(sketch.sketchCurves.sketchFittedSplines.add(points[0]))
         
        # Create an object collection for the points.
        points.append(adsk.core.ObjectCollection.create())
        points[1].add(adsk.core.Point3D.create(7, 6, 6))
        points[1].add(adsk.core.Point3D.create(2, 3, 0))
        points[1].add(adsk.core.Point3D.create(0, 1, 0))
        # Create the spline.
        spline.append(sketch.sketchCurves.sketchFittedSplines.add(points[1]))
 
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Jack&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jun 2016 01:43:23 GMT</pubDate>
    <dc:creator>liujac</dc:creator>
    <dc:date>2016-06-24T01:43:23Z</dc:date>
    <item>
      <title>Array of spline ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/array-of-spline/m-p/6401247#M19680</link>
      <description>&lt;P&gt;I'm new to Fusion 360 API and object oriented programming.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's very interesting. I'm studing the simple examples of the help.&lt;/P&gt;&lt;P&gt;I would like to understand why it's not possible write this kind of code.&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import adsk.core, adsk.fusion, traceback&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;def run(context):&lt;/P&gt;&lt;P&gt;ui = None&lt;/P&gt;&lt;P&gt;try:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;app = adsk.core.Application.get()&lt;/P&gt;&lt;P&gt;ui = app.userInterface&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)&lt;/P&gt;&lt;P&gt;design = app.activeProduct&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Get the root component of the active design.&lt;/P&gt;&lt;P&gt;rootComp = design.rootComponent&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create a new sketch on the xy plane.&lt;/P&gt;&lt;P&gt;sketch = rootComp.sketches.add(rootComp.xYConstructionPlane)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create an object collection for the points.&lt;/P&gt;&lt;P&gt;points[0] = adsk.core.ObjectCollection.create()&lt;/P&gt;&lt;P&gt;# Define the points the spline with fit through.&lt;/P&gt;&lt;P&gt;points[0].add(adsk.core.Point3D.create(0, 0, 0))&lt;/P&gt;&lt;P&gt;points[0].add(adsk.core.Point3D.create(5, 1, 0))&lt;/P&gt;&lt;P&gt;points[0].add(adsk.core.Point3D.create(6, 4, 3))&lt;/P&gt;&lt;P&gt;# Create the spline.&lt;/P&gt;&lt;P&gt;spline[0]=sketch.sketchCurves.sketchFittedSplines.add(points[0])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create an object collection for the points.&lt;/P&gt;&lt;P&gt;points[1] = adsk.core.ObjectCollection.create()&lt;/P&gt;&lt;P&gt;points[1].add(adsk.core.Point3D.create(7, 6, 6))&lt;/P&gt;&lt;P&gt;points[1].add(adsk.core.Point3D.create(2, 3, 0))&lt;/P&gt;&lt;P&gt;points[1].add(adsk.core.Point3D.create(0, 1, 0))&lt;/P&gt;&lt;P&gt;# Create the spline.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;spline[1]=&lt;/SPAN&gt;sketch.sketchCurves.sketchFittedSplines.add(points[1])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;except:&lt;/P&gt;&lt;P&gt;if ui:&lt;/P&gt;&lt;P&gt;ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is another way to use array of spline ?&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;Dino&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 20:13:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/array-of-spline/m-p/6401247#M19680</guid>
      <dc:creator>dinocoglitore</dc:creator>
      <dc:date>2016-06-23T20:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: Array of spline ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/array-of-spline/m-p/6401703#M19681</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to define empty arrays first, and then append items to the arrays. I made a little change on your script, then it should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;import adsk.core, adsk.fusion, traceback
 
def run(context):
    ui = None
    try:
     
        app = adsk.core.Application.get()
        ui = app.userInterface
         
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        design = app.activeProduct
         
        # Get the root component of the active design.
        rootComp = design.rootComponent
         
        # Create a new sketch on the xy plane.
        sketch = rootComp.sketches.add(rootComp.xYConstructionPlane)
         
        points = []
        spline = []
        # Create an object collection for the points.
        points.append(adsk.core.ObjectCollection.create())
        # Define the points the spline with fit through.
        points[0].add(adsk.core.Point3D.create(0, 0, 0))
        points[0].add(adsk.core.Point3D.create(5, 1, 0))
        points[0].add(adsk.core.Point3D.create(6, 4, 3))
        # Create the spline.
        spline.append(sketch.sketchCurves.sketchFittedSplines.add(points[0]))
         
        # Create an object collection for the points.
        points.append(adsk.core.ObjectCollection.create())
        points[1].add(adsk.core.Point3D.create(7, 6, 6))
        points[1].add(adsk.core.Point3D.create(2, 3, 0))
        points[1].add(adsk.core.Point3D.create(0, 1, 0))
        # Create the spline.
        spline.append(sketch.sketchCurves.sketchFittedSplines.add(points[1]))
 
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Jack&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 01:43:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/array-of-spline/m-p/6401703#M19681</guid>
      <dc:creator>liujac</dc:creator>
      <dc:date>2016-06-24T01:43:23Z</dc:date>
    </item>
    <item>
      <title>Re: Array of spline ?</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/array-of-spline/m-p/6402012#M19682</link>
      <description>&lt;P&gt;Hi Jack, your solution let me understand that my problem is on Python syntax.&lt;/P&gt;&lt;P&gt;I thank you very much for the answer.&lt;/P&gt;&lt;P&gt;It solved my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dino&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 08:35:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/array-of-spline/m-p/6402012#M19682</guid>
      <dc:creator>dinocoglitore</dc:creator>
      <dc:date>2016-06-24T08:35:27Z</dc:date>
    </item>
  </channel>
</rss>

