<?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: Constrained points get duplicated when creating a spline in Fusion using Python in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/constrained-points-get-duplicated-when-creating-a-spline-in/m-p/13063094#M745</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd expect the&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;sketchFittedSplines_var.add()&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;method to use the sketchPoints supplied (as it receive both Point3D and SketchPoint objects), but it certainly duplicates them.&lt;/P&gt;&lt;P&gt;One solution could be just make the points collection of Point3Ds instead of SketchPoints, and then add the constraints after the spline creation, like in the following code snippet:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    spline = sketch.sketchCurves.sketchFittedSplines.add(points)
    for p in spline.fitPoints:
        textPointX = adsk.core.Point3D.create(p.geometry.x, -p.geometry.x, 0)
        textPointY = adsk.core.Point3D.create(p.geometry.x*1.5, p.geometry.y, 0)
        dims.addDistanceDimension(origin, p, adsk.fusion.DimensionOrientations.HorizontalDimensionOrientation, textPointX)
        dims.addDistanceDimension(origin, p, adsk.fusion.DimensionOrientations.VerticalDimensionOrientation, textPointY)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this can help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jorge Jaramillo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Oct 2024 17:08:13 GMT</pubDate>
    <dc:creator>Jorge_Jaramillo</dc:creator>
    <dc:date>2024-10-03T17:08:13Z</dc:date>
    <item>
      <title>Constrained points get duplicated when creating a spline in Fusion using Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/constrained-points-get-duplicated-when-creating-a-spline-in/m-p/13062653#M743</link>
      <description>&lt;P&gt;I have created a code that adds points to a sketch, dimensions them and then I would like a spline to go through it.&lt;BR /&gt;&lt;BR /&gt;For the spline not to be altered by accident in the future, I would like to constrain everything that is possible, starting with the points. I have accomplished that, and if I run my code (at the end of this question) without the line:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;spline = sketch.sketchCurves.sketchFittedSplines.add(points)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;everything works well and I get a sketch that looks like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="josikWFKBV_0-1727966127773.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1417466i785F168C91A4027D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="josikWFKBV_0-1727966127773.png" alt="josikWFKBV_0-1727966127773.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately when I try to add these points to a spline, I lose the constraints. Here if I try to move it to the side, I get double of all the points I have...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="josikWFKBV_1-1727966216156.png" style="width: 153px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1417467i06E4F0FF11A115F7/image-dimensions/153x463?v=v2" width="153" height="463" role="button" title="josikWFKBV_1-1727966216156.png" alt="josikWFKBV_1-1727966216156.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="josikWFKBV_2-1727966223532.png" style="width: 214px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1417468iA89EFB225751F3C6/image-dimensions/214x385?v=v2" width="214" height="385" role="button" title="josikWFKBV_2-1727966223532.png" alt="josikWFKBV_2-1727966223532.png" /&gt;&lt;/span&gt;Am I duplicating some points by accident, or is there some logical flaw in my process?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&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)

        # Create an object collection for the points.
        points = adsk.core.ObjectCollection.create()

        dims = adsk.fusion.SketchDimensions.cast(sketch.sketchDimensions)

        a = 4
        xStart = -2
        xEnd = 2
        increment = 1
        i = 0

        for x in range(xStart, xEnd, increment):
            
            y = a * x ** 2

            if x &amp;gt; 0:
                textY = -x 
            else:
                textY = x 
                

            origin = sketch.originPoint
            point = sketch.sketchPoints.add(adsk.core.Point3D.create(x, y, 0))
            points.add(point)
            textPointX = adsk.core.Point3D.create(x, textY, 0)   
            textPointY = adsk.core.Point3D.create(x*1.5, y, 0)              

            dim = sketch.sketchDimensions
            distanceDimension = dim.addDistanceDimension(origin, points[i], adsk.fusion.DimensionOrientations.HorizontalDimensionOrientation, textPointX)
            distanceDimension = dim.addDistanceDimension(origin, points[i], adsk.fusion.DimensionOrientations.VerticalDimensionOrientation, textPointY)
            

            i = i +1

        spline = sketch.sketchCurves.sketchFittedSplines.add(points)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking forward to your replies and ideas &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 14:42:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/constrained-points-get-duplicated-when-creating-a-spline-in/m-p/13062653#M743</guid>
      <dc:creator>josikWFKBV</dc:creator>
      <dc:date>2024-10-03T14:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Constrained points get duplicated when creating a spline in Fusion using Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/constrained-points-get-duplicated-when-creating-a-spline-in/m-p/13062679#M744</link>
      <description>I have partially solved this by adding "spline.isFixed = True"</description>
      <pubDate>Thu, 03 Oct 2024 14:49:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/constrained-points-get-duplicated-when-creating-a-spline-in/m-p/13062679#M744</guid>
      <dc:creator>josikWFKBV</dc:creator>
      <dc:date>2024-10-03T14:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Constrained points get duplicated when creating a spline in Fusion using Python</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/constrained-points-get-duplicated-when-creating-a-spline-in/m-p/13063094#M745</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd expect the&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;sketchFittedSplines_var.add()&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp;method to use the sketchPoints supplied (as it receive both Point3D and SketchPoint objects), but it certainly duplicates them.&lt;/P&gt;&lt;P&gt;One solution could be just make the points collection of Point3Ds instead of SketchPoints, and then add the constraints after the spline creation, like in the following code snippet:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    spline = sketch.sketchCurves.sketchFittedSplines.add(points)
    for p in spline.fitPoints:
        textPointX = adsk.core.Point3D.create(p.geometry.x, -p.geometry.x, 0)
        textPointY = adsk.core.Point3D.create(p.geometry.x*1.5, p.geometry.y, 0)
        dims.addDistanceDimension(origin, p, adsk.fusion.DimensionOrientations.HorizontalDimensionOrientation, textPointX)
        dims.addDistanceDimension(origin, p, adsk.fusion.DimensionOrientations.VerticalDimensionOrientation, textPointY)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this can help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jorge Jaramillo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 17:08:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/constrained-points-get-duplicated-when-creating-a-spline-in/m-p/13063094#M745</guid>
      <dc:creator>Jorge_Jaramillo</dc:creator>
      <dc:date>2024-10-03T17:08:13Z</dc:date>
    </item>
  </channel>
</rss>

