<?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: Difference of geometryOrOriginOne and geometryOrOriginOneTwo in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9847414#M10273</link>
    <description>&lt;P&gt;Combining the fact that&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;joint.geometryOrOriginTwo.origin.asArray() constantly return relative coordinate of the joint&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;joint.occurrenceTwo.transform.translation.asArray() returns the link origin&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;I come to the conclusion like this. It seems working for both cases.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;import adsk.core, adsk.fusion, traceback
try:
    app = adsk.core.Application.get()
    ui  = app.userInterface
    product = app.activeProduct
    design = adsk.fusion.Design.cast(product)
    rootComp = design.rootComponent
    for joint in rootComp.joints:
        xyz_from_two_to_joint = joint.geometryOrOriginTwo.origin.asArray()
        xyz_of_two            = joint.occurrenceTwo.transform.translation.asArray()
        xyz_of_joint          = [a+b for a, b in zip(xyz_from_two_to_joint, xyz_of_two)]
        print("Joint position ", xyz_of_joint)
except:
    print('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;</description>
    <pubDate>Thu, 05 Nov 2020 09:52:26 GMT</pubDate>
    <dc:creator>yamamoto.mas</dc:creator>
    <dc:date>2020-11-05T09:52:26Z</dc:date>
    <item>
      <title>Difference of geometryOrOriginOne and geometryOrOriginOneTwo</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9837767#M10270</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the difference between geometryOrOriginOne and geometryOrOriginOneTwo of JointInput Object.&lt;/P&gt;&lt;P&gt;I found their origin coordinates are sometimes identical and sometimes different.&lt;/P&gt;&lt;P&gt;I'd like to know which has true joint's coordinates.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="capture.PNG" style="width: 863px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/838948iCD566AECA060D15E/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture.PNG" alt="capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This might be a basic question, but I could not find any explanation about it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Nov 2020 06:54:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9837767#M10270</guid>
      <dc:creator>yamamoto.mas</dc:creator>
      <dc:date>2020-11-01T06:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of geometryOrOriginOne and geometryOrOriginOneTwo</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9841497#M10271</link>
      <description>&lt;P&gt;I have further investigated the difference through experiments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I compared two models:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;"joint_test1 v2.f3d": Four 5cm blocks are stacked with joints located at other than component origins.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;"joint_test2 v2.f3d": Four 5cm blocks are stacked with joints located at each component origin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="capture1.PNG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/839640i044C735EA408D920/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture1.PNG" alt="capture1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In this first case OriginOne vector shows joint position in world coordinate, while OriginTwo vector shows local coordinate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="capture2.PNG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/839641i4F146A6307C04ECE/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture2.PNG" alt="capture2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In this second case, OriginOne vector is just garbage (zero vector), while OriginTwo vector is correctly showing local coordinates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, second case is very inconvenient to know world coordinate of the joint.&lt;/P&gt;&lt;P&gt;Is there anyway to know the joint's world coordinate constantly, irrespective of component's condition ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 02:24:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9841497#M10271</guid>
      <dc:creator>yamamoto.mas</dc:creator>
      <dc:date>2020-11-03T02:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of geometryOrOriginOne and geometryOrOriginOneTwo</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9841651#M10272</link>
      <description>&lt;P&gt;The first picture above is wrong. It should be swapped to:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="capture1.PNG" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/839658iA48ED0B4FE3D19DF/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture1.PNG" alt="capture1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 04:53:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9841651#M10272</guid>
      <dc:creator>yamamoto.mas</dc:creator>
      <dc:date>2020-11-03T04:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of geometryOrOriginOne and geometryOrOriginOneTwo</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9847414#M10273</link>
      <description>&lt;P&gt;Combining the fact that&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;joint.geometryOrOriginTwo.origin.asArray() constantly return relative coordinate of the joint&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;joint.occurrenceTwo.transform.translation.asArray() returns the link origin&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN style="font-family: inherit;"&gt;I come to the conclusion like this. It seems working for both cases.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;import adsk.core, adsk.fusion, traceback
try:
    app = adsk.core.Application.get()
    ui  = app.userInterface
    product = app.activeProduct
    design = adsk.fusion.Design.cast(product)
    rootComp = design.rootComponent
    for joint in rootComp.joints:
        xyz_from_two_to_joint = joint.geometryOrOriginTwo.origin.asArray()
        xyz_of_two            = joint.occurrenceTwo.transform.translation.asArray()
        xyz_of_joint          = [a+b for a, b in zip(xyz_from_two_to_joint, xyz_of_two)]
        print("Joint position ", xyz_of_joint)
except:
    print('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;</description>
      <pubDate>Thu, 05 Nov 2020 09:52:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9847414#M10273</guid>
      <dc:creator>yamamoto.mas</dc:creator>
      <dc:date>2020-11-05T09:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of geometryOrOriginOne and geometryOrOriginOneTwo</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9851969#M10274</link>
      <description>&lt;P&gt;I have generalized the algorithm so that it can cope with the case like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="capture.PNG" style="width: 873px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/841425iA9B6CFB034422A27/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture.PNG" alt="capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;import adsk.core, adsk.fusion, traceback

# Coordinate transformation by matrix
# M: 4x4 transformation matrix
# a: 3D vector
def trans(M, a):
    ex = [M[0],M[4],M[8]]
    ey = [M[1],M[5],M[9]]
    ez = [M[2],M[6],M[10]]
    oo = [M[3],M[7],M[11]]
    b = [0, 0, 0]
    for i in range(3):
        b[i] = a[0]*ex[i]+a[1]*ey[i]+a[2]*ez[i]+oo[i]
    return(b)

# Returns True if two arrays are element-wise equal within a tolerance
def allclose(v1, v2, tol=1e-6):
    return( max([abs(a-b) for a,b in zip(v1, v2)]) &amp;lt; tol )

try:
    app = adsk.core.Application.get()
    ui  = app.userInterface
    product = app.activeProduct
    design = adsk.fusion.Design.cast(product)
    rootComp = design.rootComponent
    for joint in rootComp.joints:

        # Basic information
        xyz_from_one_to_joint = joint.geometryOrOriginOne.origin.asArray() # Relative Joint pos
        xyz_from_two_to_joint = joint.geometryOrOriginTwo.origin.asArray() # Relative Joint pos
        xyz_of_one            = joint.occurrenceOne.transform.translation.asArray() # Link origin
        xyz_of_two            = joint.occurrenceTwo.transform.translation.asArray() # Link origin
        M_two = joint.occurrenceTwo.transform.asArray() # Matrix as a 16 element array.

        # Compose joint position
        case1 = allclose(xyz_from_two_to_joint, xyz_from_one_to_joint)
        case2 = allclose(xyz_from_two_to_joint, xyz_of_one)
        if case1 or case2:
            xyz_of_joint = xyz_from_two_to_joint
        else:
            xyz_of_joint = trans(M_two, xyz_from_two_to_joint)

        # Show result
        print('-----', joint.name, '-----')
        print('J1', [round(x,3) for x in xyz_from_one_to_joint])
        print('J2', [round(x,3) for x in xyz_from_two_to_joint]) 
        print('L1', [round(x,3) for x in xyz_of_one])
        print('L2', [round(x,3) for x in xyz_of_two]) 
        print(case1, case2)
        print("Joint position ", [round(x, 3) for x in xyz_of_joint])
except:
    print('Failed:\n{}'.format(traceback.format_exc()))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still skeptical about the result:&lt;/P&gt;&lt;P&gt;* Can this algorithm cope with all possible cases ?&lt;/P&gt;&lt;P&gt;* Do AUTODESK engineers do such complicated computation just to get joint coordinates ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Nov 2020 04:27:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/difference-of-geometryororiginone-and-geometryororiginonetwo/m-p/9851969#M10274</guid>
      <dc:creator>yamamoto.mas</dc:creator>
      <dc:date>2020-11-07T04:27:56Z</dc:date>
    </item>
  </channel>
</rss>

