<?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: Rectangle on non-parallel plane in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13751235#M22064</link>
    <description>&lt;P&gt;I'm not 100% what you need, but here is a script that prompts you to select a sketch point. It expects that point to be the end of a line. It then creates a rectangle in the sketch the line is in that is centered on the selected point and oriented parallel to the line. The size of the rectangle is hard-coded in the script.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"""This file acts as the main module for this script."""

import traceback
import adsk.core
import adsk.fusion

# Initialize the global variables for the Application and UserInterface objects.
app = adsk.core.Application.get()
ui  = app.userInterface


def run(_context: str):
    """This function is called by Fusion when the script is run."""

    try:
        # define the width and height of the rectangle
        length = 4
        width = 2

        # Have the sketch point selected.
        try:
            sel = ui.selectEntity('Select the sketch point.', adsk.core.SelectionFilters.SketchPoints)
        except:
            return
        
        skPnt: adsk.fusion.SketchPoint = sel.entity

        # Check if there's a single line connected to the point.
        if skPnt.connectedEntities.count != 1:
            ui.messageBox('A single line should connect to the selected point.')
            return
        
        if skPnt.connectedEntities[0].objectType != adsk.fusion.SketchLine.classType():
            ui.messageBox('A single line should connect to the selected point.')
            return

        skLine: adsk.fusion.SketchLine = skPnt.connectedEntities[0]

        # Get the direction of the line by going from the select poing to the other.
        # The line direction will be the length direction of the rectangle.
        if skPnt == skLine.startSketchPoint:
            lengthDir = skLine.startSketchPoint.geometry.vectorTo(skLine.endSketchPoint.geometry)
        else:
            lengthDir = skLine.endSketchPoint.geometry.vectorTo(skLine.startSketchPoint.geometry)
        lengthDir.normalize()

        # Calculate the width direction so it is 90 to the length direction.
        widthDir = adsk.core.Vector3D.create(0, 0, 1).crossProduct(lengthDir)
        widthDir.normalize()

        # Calculate the offset of the corner of the rectangle so the selected
        # point will be at the center of the rectangle.
        lengthDir.scaleBy(-length / 2)
        widthDir.scaleBy(-width / 2)
        pntOne = skPnt.geometry
        pntOne.translateBy(lengthDir)
        pntOne.translateBy(widthDir)

        # Calculate the other two points. A negative value is use when scaling
        # because it was scaled with a negative value when getting the first
        # point and this results in a positive scale.
        pntTwo = pntOne.copy()
        lengthDir.normalize()
        lengthDir.scaleBy(-length)
        pntTwo.translateBy(lengthDir)

        pntThree = pntTwo.copy()
        widthDir.normalize()
        widthDir.scaleBy(-width)
        pntThree.translateBy(widthDir)        

        # Create the rectangle.
        sk = skLine.parentSketch
        skLines = sk.sketchCurves.sketchLines
        skLines.addThreePointRectangle(pntOne, pntTwo, pntThree)
    except:  #pylint:disable=bare-except
        # Write the error message to the TEXT COMMANDS window.
        app.log(f'Failed:\n{traceback.format_exc()}')&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 02 Aug 2025 22:47:44 GMT</pubDate>
    <dc:creator>BrianEkins</dc:creator>
    <dc:date>2025-08-02T22:47:44Z</dc:date>
    <item>
      <title>Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13749006#M22054</link>
      <description>&lt;P&gt;How do you draw a rectangle on a plane that is not parallel to one of the origin planes using API?&lt;/P&gt;&lt;P&gt;The center of the rectangle is at one of the end points of the line, and the long side of the rectangle is parallel to the line.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Screenshot 2025-07-31 154636.png" style="width: 387px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1557588i4B07420B3FD0EAC3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2025-07-31 154636.png" alt="Screenshot 2025-07-31 154636.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 21:01:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13749006#M22054</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2025-07-31T21:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13749043#M22055</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;One way is to draw the rectangle on a sketch on YZplane or XZplane and then making a projection of its lines over a sketch over the tilted plane.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does it make sense for you?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 21:29:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13749043#M22055</guid>
      <dc:creator>Jorge_Jaramillo</dc:creator>
      <dc:date>2025-07-31T21:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13749378#M22056</link>
      <description>&lt;P&gt;Is the line in a sketch that was created on the face you want the rectangle on?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Aug 2025 05:15:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13749378#M22056</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2025-08-01T05:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13750559#M22060</link>
      <description>I don't think that would work because the dimensions would not be correct.&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Aug 2025 21:39:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13750559#M22060</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2025-08-01T21:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13750567#M22061</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Ok, understood.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd suggest two more options:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) To draw the rectangle on a new XY-based sketch, and then apply a transformation (rotation and displacement) to it.&lt;/P&gt;&lt;P&gt;This transformation have same rotations as the sketch when you draw the line; and a displacement from rectangle center point to one of the line's end-points.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Keep a copy of the transformation matrix of the current sketch (where you have the line), calculate an inverse transformation of its matrix, which will translate the sketch to a XY-Based sketch; then you can draw the rectangle with dimensions; and finally apply the already kept transformation matrix to set it back where it was at the beginning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does any of this options make sense for you?&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Aug 2025 21:59:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13750567#M22061</guid>
      <dc:creator>Jorge_Jaramillo</dc:creator>
      <dc:date>2025-08-01T21:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13751060#M22063</link>
      <description>I'm sorry Jorge but I have no idea what you are talking about.&lt;BR /&gt;It all sounds Greek to me.&lt;BR /&gt;&lt;BR /&gt;Brad&lt;BR /&gt;</description>
      <pubDate>Sat, 02 Aug 2025 16:13:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13751060#M22063</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2025-08-02T16:13:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13751235#M22064</link>
      <description>&lt;P&gt;I'm not 100% what you need, but here is a script that prompts you to select a sketch point. It expects that point to be the end of a line. It then creates a rectangle in the sketch the line is in that is centered on the selected point and oriented parallel to the line. The size of the rectangle is hard-coded in the script.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;"""This file acts as the main module for this script."""

import traceback
import adsk.core
import adsk.fusion

# Initialize the global variables for the Application and UserInterface objects.
app = adsk.core.Application.get()
ui  = app.userInterface


def run(_context: str):
    """This function is called by Fusion when the script is run."""

    try:
        # define the width and height of the rectangle
        length = 4
        width = 2

        # Have the sketch point selected.
        try:
            sel = ui.selectEntity('Select the sketch point.', adsk.core.SelectionFilters.SketchPoints)
        except:
            return
        
        skPnt: adsk.fusion.SketchPoint = sel.entity

        # Check if there's a single line connected to the point.
        if skPnt.connectedEntities.count != 1:
            ui.messageBox('A single line should connect to the selected point.')
            return
        
        if skPnt.connectedEntities[0].objectType != adsk.fusion.SketchLine.classType():
            ui.messageBox('A single line should connect to the selected point.')
            return

        skLine: adsk.fusion.SketchLine = skPnt.connectedEntities[0]

        # Get the direction of the line by going from the select poing to the other.
        # The line direction will be the length direction of the rectangle.
        if skPnt == skLine.startSketchPoint:
            lengthDir = skLine.startSketchPoint.geometry.vectorTo(skLine.endSketchPoint.geometry)
        else:
            lengthDir = skLine.endSketchPoint.geometry.vectorTo(skLine.startSketchPoint.geometry)
        lengthDir.normalize()

        # Calculate the width direction so it is 90 to the length direction.
        widthDir = adsk.core.Vector3D.create(0, 0, 1).crossProduct(lengthDir)
        widthDir.normalize()

        # Calculate the offset of the corner of the rectangle so the selected
        # point will be at the center of the rectangle.
        lengthDir.scaleBy(-length / 2)
        widthDir.scaleBy(-width / 2)
        pntOne = skPnt.geometry
        pntOne.translateBy(lengthDir)
        pntOne.translateBy(widthDir)

        # Calculate the other two points. A negative value is use when scaling
        # because it was scaled with a negative value when getting the first
        # point and this results in a positive scale.
        pntTwo = pntOne.copy()
        lengthDir.normalize()
        lengthDir.scaleBy(-length)
        pntTwo.translateBy(lengthDir)

        pntThree = pntTwo.copy()
        widthDir.normalize()
        widthDir.scaleBy(-width)
        pntThree.translateBy(widthDir)        

        # Create the rectangle.
        sk = skLine.parentSketch
        skLines = sk.sketchCurves.sketchLines
        skLines.addThreePointRectangle(pntOne, pntTwo, pntThree)
    except:  #pylint:disable=bare-except
        # Write the error message to the TEXT COMMANDS window.
        app.log(f'Failed:\n{traceback.format_exc()}')&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 02 Aug 2025 22:47:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13751235#M22064</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2025-08-02T22:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13753045#M22067</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5741855"&gt;@BrianEkins&lt;/a&gt;, the rectangle sketch plane is perpendicular to the plane that has the line sketch and parallel to the line.&lt;/P&gt;&lt;P&gt;The line would actually be where the two planes intersect.&lt;/P&gt;&lt;P&gt;I am creating a die spring.&lt;/P&gt;&lt;P&gt;The path for the spring and the guide path are created in the sketch with the line on the selected plane.&lt;/P&gt;&lt;P&gt;Hopefully the picture will help explain what I am trying to do.&lt;/P&gt;&lt;P&gt;If you need the entire script of what I have, I will gladly pass it along.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Screenshot 2025-08-04 114741.png" style="width: 887px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1558346i11E33403F0F13C7E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-08-04 114741.png" alt="Screenshot 2025-08-04 114741.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 17:08:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13753045#M22067</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2025-08-04T17:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13753416#M22068</link>
      <description>&lt;P&gt;Sorry, but it's still not clear to me what the geometry is. Maybe post a model with the results you're trying to create by manually creating it.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Aug 2025 23:30:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13753416#M22068</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2025-08-04T23:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13758343#M22073</link>
      <description>&lt;P&gt;Attached is a step model of two springs.&lt;/P&gt;&lt;P&gt;The red spring is correct. The rectangle is perpendicular to the centerline of the spring, and parallel to the plane it is on.&lt;/P&gt;&lt;P&gt;The plane the red spring is on is parallel to the X-Z plane.&lt;/P&gt;&lt;P&gt;The blue spring is the problem.&lt;/P&gt;&lt;P&gt;The plane it is on is not parallel to any origin plane.&lt;/P&gt;&lt;P&gt;The rectangle is not perpendicular to the spring centerline or parallel to the plane the spring is on.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Aug 2025 15:58:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13758343#M22073</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2025-08-07T15:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13776442#M22117</link>
      <description>&lt;P&gt;Sorry that it's taken me a while to get back to this. I'm still struggling to understand the geometry. It isn't easy to see the orientation of the geometry in a 2D picture. Maybe forget about the spring for now and focus on the initial input. You have a plane and a line. I don't know if the line lies on the plane or is perpendicular to the plane. From the STEP model I can now see what it means for a spring to be "on" a plane. I think what would help is to show the input the user provides to your program. And then go step-by-step through what you need to create to build the spring. Because the model is a STEP file I can't see the modeling operations or the sketches you created.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 00:54:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13776442#M22117</guid>
      <dc:creator>BrianEkins</dc:creator>
      <dc:date>2025-08-21T00:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Rectangle on non-parallel plane</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13777731#M22125</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5741855"&gt;@BrianEkins&lt;/a&gt;&amp;nbsp;I think at this point since it is quite confusing, if you send me your email address I will add you to the Entitlement list and you can down load the app from the app store.&lt;/P&gt;&lt;P&gt;If you search 'Springs' you will find Mold Tech Mold/Die Springs.&lt;/P&gt;&lt;P&gt;This app is not protected so you can see how it operates and access the code.&lt;/P&gt;&lt;P&gt;I hope that will help and thanks for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Brad&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 17:24:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/rectangle-on-non-parallel-plane/m-p/13777731#M22125</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2025-08-21T17:24:10Z</dc:date>
    </item>
  </channel>
</rss>

