<?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: Sketches on multiple offset construction planes in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sketches-on-multiple-offset-construction-planes/m-p/7075025#M18149</link>
    <description>&lt;P&gt;Thank you much for the code and explanation - this makes more sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, funny you added the loft - I was going to ask a follow up question about doing something similar using tsplines - the question being, how would I go about creating coordinate control points - but what you did does just that!&lt;/P&gt;</description>
    <pubDate>Wed, 10 May 2017 16:23:39 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-05-10T16:23:39Z</dc:date>
    <item>
      <title>Sketches on multiple offset construction planes</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sketches-on-multiple-offset-construction-planes/m-p/7073072#M18147</link>
      <description>&lt;P&gt;Hi all-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fairly new to Fusion 360 and definitely to this API/programming...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to basically have an external file of coordinates being imported (something like the importCSV script) and have curves drawn on sketches that are on a series of offset construction planes (see below) - we'll deal with looping later... I've been cobbling together two of the sample API scripts to get a better grasp of how to do this and have ended up with this so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, how do I 1. create a sketch on a construction plane and 2. create a curve on that new sketch? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;*********************&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;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;# Create a document.&lt;/P&gt;&lt;P&gt;doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;product = app.activeProduct&lt;/P&gt;&lt;P&gt;design = adsk.fusion.Design.cast(product)&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 sketch&lt;/P&gt;&lt;P&gt;sketches = rootComp.sketches&lt;/P&gt;&lt;P&gt;sketch = sketches.add(rootComp.xZConstructionPlane)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create sketch circle&lt;/P&gt;&lt;P&gt;sketchCircles = sketch.sketchCurves.sketchCircles&lt;/P&gt;&lt;P&gt;centerPoint = adsk.core.Point3D.create(0, 0, 0)&lt;/P&gt;&lt;P&gt;sketchCircles.addByCenterRadius(centerPoint, 5.0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Get the profile defined by the circle&lt;/P&gt;&lt;P&gt;prof = sketch.profiles.item(0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Get construction planes&lt;/P&gt;&lt;P&gt;planes = rootComp.constructionPlanes&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create construction plane input&lt;/P&gt;&lt;P&gt;planeInput = planes.createInput()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Add construction plane by offset&lt;/P&gt;&lt;P&gt;offsetValue = adsk.core.ValueInput.createByReal(3.0)&lt;/P&gt;&lt;P&gt;planeInput.setByOffset(prof, offsetValue)&lt;/P&gt;&lt;P&gt;planeOne = planes.add(planeInput)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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 = adsk.core.ObjectCollection.create()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Define the points the spline with fit through.&lt;/P&gt;&lt;P&gt;points.add(adsk.core.Point3D.create(0, 0, 0))&lt;/P&gt;&lt;P&gt;points.add(adsk.core.Point3D.create(5, 1, 0))&lt;/P&gt;&lt;P&gt;points.add(adsk.core.Point3D.create(6, 4, 0))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create the spline.&lt;/P&gt;&lt;P&gt;sketch.sketchCurves.sketchFittedSplines.add(points)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;offsetValue = adsk.core.ValueInput.createByReal(6.0)&lt;/P&gt;&lt;P&gt;planeInput.setByOffset(prof, offsetValue)&lt;/P&gt;&lt;P&gt;planeTwo = planes.add(planeInput)&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 = adsk.core.ObjectCollection.create()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Define the points the spline with fit through.&lt;/P&gt;&lt;P&gt;points.add(adsk.core.Point3D.create(0, 0, 0))&lt;/P&gt;&lt;P&gt;points.add(adsk.core.Point3D.create(3, 7, 0))&lt;/P&gt;&lt;P&gt;points.add(adsk.core.Point3D.create(5, 9, 0))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create the spline.&lt;/P&gt;&lt;P&gt;sketch.sketchCurves.sketchFittedSplines.add(points)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;offsetValue = adsk.core.ValueInput.createByReal(9.0)&lt;/P&gt;&lt;P&gt;planeInput.setByOffset(prof, offsetValue)&lt;/P&gt;&lt;P&gt;planeThree = planes.add(planeInput)&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 = adsk.core.ObjectCollection.create()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Define the points the spline with fit through.&lt;/P&gt;&lt;P&gt;points.add(adsk.core.Point3D.create(0, 0, 0))&lt;/P&gt;&lt;P&gt;points.add(adsk.core.Point3D.create(2, 5, 0))&lt;/P&gt;&lt;P&gt;points.add(adsk.core.Point3D.create(3, 8, 0))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Create the spline.&lt;/P&gt;&lt;P&gt;sketch.sketchCurves.sketchFittedSplines.add(points)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;*********************&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fusion360-sketchOnConstructionPlane.png" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/354362iB92B56A38D2C8524/image-size/large?v=v2&amp;amp;px=999" role="button" title="fusion360-sketchOnConstructionPlane.png" alt="fusion360-sketchOnConstructionPlane.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 21:24:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sketches-on-multiple-offset-construction-planes/m-p/7073072#M18147</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-05-09T21:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sketches on multiple offset construction planes</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sketches-on-multiple-offset-construction-planes/m-p/7073172#M18148</link>
      <description>&lt;P&gt;Here's a modified version of your program that creates a series of curves on different construction planes and then creates a loft feature through them.&amp;nbsp; The thing to always start with when you're automating some process like this is to go through the same steps in the user interface and pay careful attention to the steps needed.&amp;nbsp;In your code you were getting the profile from the sketch and using that to create then construction plane.&amp;nbsp; Profiles represent the closed areas within a sketch that are drawn as filled in.&amp;nbsp; When drawing a single open curve, there aren't any profiles.&amp;nbsp; I modified the program to build the construction planes using one of the base construction planes.&amp;nbsp;For open curves you can create a "Path" rather than a profile.&amp;nbsp; I do that with each curve that's drawn and then finally use those paths to create a loft feature.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
         
        # Create a document.
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
         
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
         
        # Get the root component of the active design
        rootComp = design.rootComponent
         
        # Create sketch
        sketches = rootComp.sketches
        sketch = sketches.add(rootComp.xZConstructionPlane)
         
        # Create sketch circle
        sketchArcs = sketch.sketchCurves.sketchArcs
        arc = sketchArcs.addByThreePoints(adsk.core.Point3D.create(0,0,0),
                                          adsk.core.Point3D.create(3,2,0),
                                          adsk.core.Point3D.create(6,0,0))
         
        # Create a path using the arc.
        paths = []
        paths.append(adsk.fusion.Path.create(arc, adsk.fusion.ChainedCurveOptions.noChainedCurves))
         
        # Get construction planes
        planes = rootComp.constructionPlanes
         
        # Create construction plane input
        planeInput = planes.createInput()
         
        # Add construction plane by offset
        offsetValue = adsk.core.ValueInput.createByReal(3.0)
        planeInput.setByOffset(rootComp.xZConstructionPlane, offsetValue)
        constPlane = planes.add(planeInput)
        
        sketch = sketches.add(constPlane)
             
        # Create an object collection for the points.
        points = adsk.core.ObjectCollection.create()
         
        # Define the points the spline with fit through.
        points.add(adsk.core.Point3D.create(0, 0, 0))
        points.add(adsk.core.Point3D.create(5, 1, 0))
        points.add(adsk.core.Point3D.create(6, 4, 0))
         
        # Create the spline.
        curve = sketch.sketchCurves.sketchFittedSplines.add(points)
    
        paths.append(adsk.fusion.Path.create(curve, adsk.fusion.ChainedCurveOptions.noChainedCurves))
    
         
        offsetValue = adsk.core.ValueInput.createByReal(6.0)
        planeInput.setByOffset(rootComp.xZConstructionPlane, offsetValue)
        constPlane = planes.add(planeInput)
    
        sketch = sketches.add(constPlane)
         
        # Create an object collection for the points.
        points = adsk.core.ObjectCollection.create()
         
        # Define the points the spline with fit through.
        points.add(adsk.core.Point3D.create(0, 0, 0))
        points.add(adsk.core.Point3D.create(3, 7, 0))
        points.add(adsk.core.Point3D.create(5, 9, 0))
         
        # Create the spline.
        curve = sketch.sketchCurves.sketchFittedSplines.add(points)
    
        paths.append(adsk.fusion.Path.create(curve, adsk.fusion.ChainedCurveOptions.noChainedCurves))
         
        offsetValue = adsk.core.ValueInput.createByReal(9.0)
        planeInput.setByOffset(rootComp.xZConstructionPlane, offsetValue)
        constPlane = planes.add(planeInput)
    
        sketch = sketches.add(constPlane)
         
        # Create an object collection for the points.
        points = adsk.core.ObjectCollection.create()
         
        # Define the points the spline with fit through.
        points.add(adsk.core.Point3D.create(0, 0, 0))
        points.add(adsk.core.Point3D.create(2, 5, 0))
        points.add(adsk.core.Point3D.create(3, 8, 0))
         
        # Create the spline.
        curve = sketch.sketchCurves.sketchFittedSplines.add(points)
    
        paths.append(adsk.fusion.Path.create(curve, adsk.fusion.ChainedCurveOptions.noChainedCurves))
        
        loftInput = rootComp.features.loftFeatures.createInput(adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
        for path in paths:
            loftInput.loftSections.add(path)
            
        rootComp.features.loftFeatures.add(loftInput)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 May 2017 22:17:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sketches-on-multiple-offset-construction-planes/m-p/7073172#M18148</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2017-05-09T22:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sketches on multiple offset construction planes</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sketches-on-multiple-offset-construction-planes/m-p/7075025#M18149</link>
      <description>&lt;P&gt;Thank you much for the code and explanation - this makes more sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, funny you added the loft - I was going to ask a follow up question about doing something similar using tsplines - the question being, how would I go about creating coordinate control points - but what you did does just that!&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 16:23:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/sketches-on-multiple-offset-construction-planes/m-p/7075025#M18149</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-05-10T16:23:39Z</dc:date>
    </item>
  </channel>
</rss>

