<?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: Python: Using Scale Features at originConstructionPoint moves bodies. in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/python-using-scale-features-at-originconstructionpoint-moves/m-p/11804813#M4294</link>
    <description>at first this wasn't a solution for me because i also move the bodies in my script and that doesn't work with the line. but then i just changed my script a bit so that i first move and then scale. and that worked perfectly!&lt;BR /&gt;&lt;BR /&gt;Thank you for your great help and your commitment to the community!&lt;BR /&gt;&lt;BR /&gt;I have another small question, for which it's probably not really worth creating a new post.&lt;BR /&gt;It's about the creation of matrices, the setting of their rotation and translation is documented here : &lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-GUID-b831d9f4-c231-4b9f-9b4d-658614ecdc79" target="_blank"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-GUID-b831d9f4-c231-4b9f-9b4d-658614ecdc79&lt;/A&gt;. But why is there no scaling? I mean I could get the individual positions from the transformation matrix and then multiply them by a scaling factor and then set them back to their position in the matrix (which unfortunately didn't work :D). But in my opinion, the methods of a transformation matrix also include scaling. It feels particularly problematic because fusion or many or possibly all CAD programs make a minimal error in the calculation or creation of transformation matrices and as soon as there is a small error in the input, this information is not accepted and the transformation matrix does not work.&lt;BR /&gt;But it is not that important because i have now my way to solve that problem!&lt;BR /&gt;&lt;BR /&gt;Thank you and much love for you &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;</description>
    <pubDate>Tue, 07 Mar 2023 17:07:59 GMT</pubDate>
    <dc:creator>Mehrab.Nasrabadi</dc:creator>
    <dc:date>2023-03-07T17:07:59Z</dc:date>
    <item>
      <title>Python: Using Scale Features at originConstructionPoint moves bodies.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/python-using-scale-features-at-originconstructionpoint-moves/m-p/11802939#M4292</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have a small problem when using the ScaleFeature. I want to iterate through all the bodies and then scale them non-uniformly. The point from which I want to scale should always be the origin of the component of the body. However, I have the problem that the bodies are scaled as I want but as soon as the ScaleFeature is executed the bodies move. I think it is either because of my declaration of the origin or because the scaleFeuture.add(...) does more than it should.&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt; But unfortunately, I'm not getting any smarter from this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am very grateful for any help and advice!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the culprit, maybe someone has the time and inclination to look over it!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards from Leipzig, Germany&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import adsk.core           
import adsk.fusion
import traceback

def run(context):
    ui = None
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface

        design: adsk.fusion.Design = app.activeProduct
        design.designType = adsk.fusion.DesignTypes.ParametricDesignType
        rootComp: adsk.fusion.Component = design.rootComponent

        for i in range(0, rootComp.allOccurrences.count):
            occ = rootComp.allOccurrences.item(i)   
            # Get the associated component.
            comp = occ.component
            
            # iterate over bodies
            for j in range(0, comp.bRepBodies.count):
                bodies: adsk.core.ObjectCollection = adsk.core.ObjectCollection.create()
                bodies.clear()
                body = comp.bRepBodies.item(j)
                body = body.createForAssemblyContext(occ)
                bodies.add(body)

                scalePoint = comp.originConstructionPoint.createForAssemblyContext(occ)
                ui.messageBox(str(scalePoint.geometry.asArray()))
                scaleFactor = adsk.core.ValueInput.createByReal(0.5)
                scaleFeatures = rootComp.features.scaleFeatures
                                    
                xScale = adsk.core.ValueInput.createByReal(float(1.55))
                yScale = adsk.core.ValueInput.createByReal(float(1.45))
                zScale = adsk.core.ValueInput.createByReal(float(1.35))
                
                input = scaleFeatures.createInput(bodies, scalePoint, scaleFactor)
                input.setToNonUniform(xScale, yScale, zScale)
                
                scaleFeature = scaleFeatures.add(input)
                
                ui.messageBox(str(scalePoint.geometry.asArray()))
                  

        &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 00:46:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/python-using-scale-features-at-originconstructionpoint-moves/m-p/11802939#M4292</guid>
      <dc:creator>Mehrab.Nasrabadi</dc:creator>
      <dc:date>2023-03-07T00:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python: Using Scale Features at originConstructionPoint moves bodies.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/python-using-scale-features-at-originconstructionpoint-moves/m-p/11803205#M4293</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13073600"&gt;@Mehrab.Nasrabadi&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may not have finalized the position of the component after it has been moved.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/fusion-360-api-and-scripts/transformation-on-occurrence-getting-reset/m-p/8402626#M6887" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/fusion-360-api-and-scripts/transformation-on-occurrence-getting-reset/m-p/8402626#M6887&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/fusion-360-api-and-scripts/quot-move-copy-quot-in-the-context-menu/m-p/9443651#M9824" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/fusion-360-api-and-scripts/quot-move-copy-quot-in-the-context-menu/m-p/9443651#M9824&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about modifying it like this?&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;・・・
        design: adsk.fusion.Design = app.activeProduct
        design.designType = adsk.fusion.DesignTypes.ParametricDesignType
        rootComp: adsk.fusion.Component = design.rootComponent

        design.snapshots.add()

        for i in range(0, rootComp.allOccurrences.count):
・・・&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 04:34:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/python-using-scale-features-at-originconstructionpoint-moves/m-p/11803205#M4293</guid>
      <dc:creator>kandennti</dc:creator>
      <dc:date>2023-03-07T04:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Python: Using Scale Features at originConstructionPoint moves bodies.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/python-using-scale-features-at-originconstructionpoint-moves/m-p/11804813#M4294</link>
      <description>at first this wasn't a solution for me because i also move the bodies in my script and that doesn't work with the line. but then i just changed my script a bit so that i first move and then scale. and that worked perfectly!&lt;BR /&gt;&lt;BR /&gt;Thank you for your great help and your commitment to the community!&lt;BR /&gt;&lt;BR /&gt;I have another small question, for which it's probably not really worth creating a new post.&lt;BR /&gt;It's about the creation of matrices, the setting of their rotation and translation is documented here : &lt;A href="https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-GUID-b831d9f4-c231-4b9f-9b4d-658614ecdc79" target="_blank"&gt;https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-GUID-b831d9f4-c231-4b9f-9b4d-658614ecdc79&lt;/A&gt;. But why is there no scaling? I mean I could get the individual positions from the transformation matrix and then multiply them by a scaling factor and then set them back to their position in the matrix (which unfortunately didn't work :D). But in my opinion, the methods of a transformation matrix also include scaling. It feels particularly problematic because fusion or many or possibly all CAD programs make a minimal error in the calculation or creation of transformation matrices and as soon as there is a small error in the input, this information is not accepted and the transformation matrix does not work.&lt;BR /&gt;But it is not that important because i have now my way to solve that problem!&lt;BR /&gt;&lt;BR /&gt;Thank you and much love for you &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;</description>
      <pubDate>Tue, 07 Mar 2023 17:07:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/python-using-scale-features-at-originconstructionpoint-moves/m-p/11804813#M4294</guid>
      <dc:creator>Mehrab.Nasrabadi</dc:creator>
      <dc:date>2023-03-07T17:07:59Z</dc:date>
    </item>
  </channel>
</rss>

