<?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: Component's origin point. in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5857724#M20840</link>
    <description>&lt;P&gt;I think there's a misunderstanding somewhere.&amp;nbsp; It might help if rather than talk about how to use certain API functionality if you&amp;nbsp;can instead&amp;nbsp;explain what it is that you're trying to accompish.&amp;nbsp;&amp;nbsp;I might be able to better help with a solution then.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Oct 2015 16:36:34 GMT</pubDate>
    <dc:creator>ekinsb</dc:creator>
    <dc:date>2015-10-12T16:36:34Z</dc:date>
    <item>
      <title>Component's origin point.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5805846#M20833</link>
      <description>&lt;P&gt;Please, help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get origin point (starting point) for different components in design?&lt;/P&gt;&lt;P&gt;If I use originConstructionPoint it returns '(0, 0, 0)', but&amp;nbsp;in UI origins&amp;nbsp;are not &amp;nbsp;located in the same place.&lt;/P&gt;&lt;P&gt;This code in Python returns different names of components and the same coordinates (0, 0, 0) :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            design = adsk.fusion.Design.cast(app.activeProduct)
            components = design.allComponents
            countComp=0
            while countComp&amp;lt;components.count:
                component = components.item(countComp)
                p = component.originConstructionPoint.geometry
                ui.messageBox(str(component.name)+"  "+str(p.x)+"  "+str(p.y)+"  "+str(p.z))
                countComp+=1&lt;/PRE&gt;&lt;P&gt;Please, how&amp;nbsp;can I get absolute value of coordinates of origins from UI?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2015 08:09:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5805846#M20833</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-09-07T08:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Component's origin point.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5805863#M20834</link>
      <description>&lt;P&gt;The terminology used in the UI is a bit confusing because there are actually components and instances of components.&amp;nbsp; What you see in the UI are the instances of components.&amp;nbsp; The API refers to these as "occurrences".&amp;nbsp; There's a topic in the API help that discusses this that should help.&amp;nbsp; &lt;A href="http://help.autodesk.com/view/NINVFUS/ENU/?guid=GUID-88A4DB43-CFDD-4CFF-B124-7EE67915A07A&amp;nbsp;" target="_blank"&gt;http://help.autodesk.com/view/NINVFUS/ENU/?guid=GUID-88A4DB43-CFDD-4CFF-B124-7EE67915A07A&amp;nbsp;&lt;/A&gt; What you actually want in your case are occurrences because they're what define the position within the assembly.&amp;nbsp; Each occurrence has a transform property which returns a transformation matrix which contains the position and orientation of the occurrence.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2015 08:21:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5805863#M20834</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2015-09-07T08:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Component's origin point.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5805910#M20835</link>
      <description>&lt;P&gt;Thank you for solution.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2015 09:18:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5805910#M20835</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-09-07T09:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: Component's origin point.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5852446#M20836</link>
      <description>&lt;P&gt;Good day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for returning to this issue.&lt;/P&gt;&lt;P&gt;But I faced with the same &amp;nbsp;problem again. How can I get the "occurrence.transform" (i.e. origin point) for every body in "design.allComponents"?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;design = adsk.fusion.Design.cast(app.activeProduct)
for comp in range(design.allComponents.count):
            component = design.allComponents.item(comp)
            bodies = component.bRepBodies
            for b in range(bodies.count):
                body = bodies.item(b)
                # here I need transformation matrix for body
                if design.rootComponent.allOccurrencesByComponent(component).count&amp;gt;0:
                     matrix = design.rootComponent.allOccurrencesByComponent(component).item(0).transform
                else:
                     matrix = adsk.core.Matrix3D.create()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it doesn't provide what I need.&lt;/P&gt;&lt;P&gt;Please, help with the ending part of code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2015 14:56:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5852446#M20836</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-10-08T14:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Component's origin point.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5853333#M20837</link>
      <description>&lt;P&gt;It's not clear to me what you're trying to do.&amp;nbsp; Bodies don't have an associated&amp;nbsp;transform.&amp;nbsp; They just exist in the space of their parent component.&amp;nbsp; Any occurrences that reference that component will display the body since it's part of the component.&amp;nbsp; Transforming the occurrence will result in the body be repositioned.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is some code that gets and displays the translation for every occurrence in an assembly.&amp;nbsp; There are two sets of code.&amp;nbsp; The first does this by getting all of the components and then all occurrence that reference that component and displaying information about them.&amp;nbsp; The second just gets every occurrence.&amp;nbsp; The only difference in the result is that they're organized differently and the all components list also lists the root component, although it will never have any occurrences that reference it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;def getOccurrencePositions():
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        design = adsk.fusion.Design.cast(app.activeProduct)
        # Iterate through all of the components in this design.
        results = ''
        for comp in design.allComponents:
            results += 'Component: ' + comp.name + '\n'

            # Get the occurrences that reference this component.
            for occ in design.rootComponent.allOccurrencesByComponent(comp):
                trans = occ.transform
                results += '   Occ: ' + occ.name + ', (' + str(trans.translation.x) + ',' + \
                            str(trans.translation.y) + ',' + str(trans.translation.z) + ')\n'

        ui.messageBox(results, 'Results by component')

        results = ''
        for occ in design.rootComponent.allOccurrences:
            trans = occ.transform
            results += '   Occ: ' + occ.name + ', (' + str(trans.translation.x) + ',' + \
                       str(trans.translation.y) + ',' + str(trans.translation.z) + ')\n'

        ui.messageBox(results, 'Results by occurrence')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Oct 2015 21:03:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5853333#M20837</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2015-10-08T21:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Component's origin point.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5854024#M20838</link>
      <description>&lt;P&gt;I am sorry for not clear explanation.&lt;/P&gt;&lt;P&gt;I really need&amp;nbsp;&lt;SPAN&gt; the position of the body within the assembly. But I get the list of all bodies from component,&amp;nbsp;though&amp;nbsp;not component but occurrence have the transform property. And one component is&amp;nbsp;referenced by some occurrences. So I can't to conect the component what I get the list of bodies from and the necessary ocurrence. &amp;nbsp;And it's still not clear to me...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 09:37:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5854024#M20838</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-10-09T09:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Component's origin point.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5854499#M20839</link>
      <description>&lt;P&gt;My final problem occured because of I didn't consider that all occurrences in chain have own transform properties.&lt;/P&gt;&lt;P&gt;So I tried to solve it with this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;occurrences= adsk.fusion.Design.cast(app.activeProduct).rootComponent.allOccurrences
for occurrence in occurrences:
      bodies = occurrence.component.bRepBodies
      matrix = GetMatrix(occurrence)


def GetMatrix(occurrence):            # method to get resulting matrix for the whole chain of occurrences
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        matrix = occurrence.transform
        while occurrence.assemblyContext:
            matrix.transformBy(occurrence.assemblyContext.transform)
            occurrence = occurrence.assemblyContext
        return matrix                                # returns resulting matrix
    except:
        if ui:
            ui.messageBox('Get Matrix failed:\n{}'.format(traceback.format_exc()))   &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope, it will work for all models...&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2015 14:37:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5854499#M20839</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-10-09T14:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: Component's origin point.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5857724#M20840</link>
      <description>&lt;P&gt;I think there's a misunderstanding somewhere.&amp;nbsp; It might help if rather than talk about how to use certain API functionality if you&amp;nbsp;can instead&amp;nbsp;explain what it is that you're trying to accompish.&amp;nbsp;&amp;nbsp;I might be able to better help with a solution then.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2015 16:36:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5857724#M20840</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2015-10-12T16:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Component's origin point.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5858964#M20841</link>
      <description>&lt;P&gt;My task is to collect the geometry for all bodies and meshes in current design and create the COLLADA&amp;nbsp;file including all them.&amp;nbsp;So I get all bodies and meshes from every component, then calculate triangle mesh from them, and use the coordinates of vertices to save geometry in COLLADA file. Model from &lt;SPAN&gt;COLLADA&amp;nbsp;&lt;/SPAN&gt;will have only one origin point (0, 0, 0) to be built, on the other hand bodies in different occurrences have different origin points. &amp;nbsp;So I use transform property of the occurrence to change the coordinates&amp;nbsp;of bodies for saving them with one common origin point.&lt;/P&gt;&lt;P&gt;I apply the code above to get transform matrix in case of occurrence contains other occurrences with bodies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that the misunderstanding caused by my bad English.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, thank you for your answers and patience.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2015 12:08:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5858964#M20841</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-10-13T12:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Component's origin point.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5860369#M20842</link>
      <description>&lt;P&gt;According to your description above, it may be similar to the question here: &lt;A href="https://forums.autodesk.com/t5/api-and-scripts/getting-triangulated-mesh-data-in-world-object-space/m-p/5613860#M354" target="_blank"&gt;Getting triangulated mesh data in world/object space&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 01:55:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/component-s-origin-point/m-p/5860369#M20842</guid>
      <dc:creator>liujac</dc:creator>
      <dc:date>2015-10-14T01:55:37Z</dc:date>
    </item>
  </channel>
</rss>

