<?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: Flipping Joint in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/flipping-joint/m-p/12173801#M3065</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3623640"&gt;@brad.bylls&lt;/a&gt;&amp;nbsp;, Can you please share your file or at least the part in which the 2 components are contained so that we can have a closer look?&lt;/P&gt;</description>
    <pubDate>Wed, 16 Aug 2023 05:50:36 GMT</pubDate>
    <dc:creator>mayank.malukani</dc:creator>
    <dc:date>2023-08-16T05:50:36Z</dc:date>
    <item>
      <title>Flipping Joint</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/flipping-joint/m-p/12158111#M3064</link>
      <description>&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6332628029112w960h540r167" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6332628029112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6332628029112w960h540r167');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6332628029112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;# Copyright (c) 2023 Brad Bylls
# Used to create multiple simple rigid joints

import adsk.core
import adsk.fusion
import adsk.cam

# Import the entire apper package
from ..apper import apper

# Globals
_app = adsk.core.Application.get()
_ui = _app.userInterface
tools = adsk.core.ObjectCollection.create()
targets = adsk.core.ObjectCollection.create()

class QuickJoints(apper.Fusion360CommandBase):
    
    def validate_inputs(self, command, inputs, args, input_values) -&amp;gt; bool:

        global tools, targets

        if tools.count == targets.count:
            return True
        else:
            return False
        
    # =========================================================================== #
    
    def on_input_changed(self, command, inputs, changed_input, input_values):

        global tools, targets

        if changed_input.id == 'component':
            toolSelectionInput = inputs.itemById('component')
            tool = tools.add(toolSelectionInput)
            inputs.itemById('target').isEnabled = True
        elif changed_input.id == 'target':
            targetSelectionInput = inputs.itemById('target')
            target = targets.add(targetSelectionInput)
            inputs.itemById('component').isEnabled = True

    # =========================================================================== #

    def on_create(self, command, inputs):

        global root, comp

        design = _app.activeProduct
        root = design.rootComponent
        comp = design.activeComponent

        # Verify that a Fusion design is active.
        if not design:
            _ui.messageBox('A Fusion design must be active when invoking this command.')
            return()

        command.okButtonText = ("Create the Joints") # text in "OK" button
        command.isExecutedWhenPreEmpted = False

        # Create the command dialog
        _inputSelectTargets = inputs.addSelectionInput('component', 'Component Snap', 'Select the First Component Edge')
        _inputSelectTargets.addSelectionFilter(adsk.core.SelectionCommandInput.Edges)
        _inputSelectTargets.setSelectionLimits(0)

        _inputSelectTools = inputs.addSelectionInput('target', 'Target Snap', 'Select the Second Component Target')
        _inputSelectTools.addSelectionFilter(adsk.core.SelectionCommandInput.SketchPoints)
        _inputSelectTools.addSelectionFilter(adsk.core.SelectionCommandInput.CircularEdges)
        _inputSelectTools.setSelectionLimits(0)

        _inputErrMessage = inputs.addTextBoxCommandInput('errMessage', '', 'Component and Target\nMust be equal count.', 2, True)
        _inputErrMessage.isFullWidth = True

    # =========================================================================== #

    def on_execute(self, command, inputs, args, input_values):

        componentList = []
        component_input: adsk.core.SelectionCommandInput = inputs.itemById('component')

        for idx in range(0, component_input.selectionCount):
            componentList.append(component_input.selection(idx).entity)

        target_input: adsk.core.SelectionCommandInput = inputs.itemById('target')
        for idx in range(0, target_input.selectionCount):
            targets = target_input.selection(idx).entity
            components = componentList[idx]

            if targets.objectType == 'adsk::fusion::BRepEdge':
                component = adsk.fusion.JointGeometry.createByCurve(components, adsk.fusion.JointKeyPointTypes.CenterKeyPoint)
                target = adsk.fusion.JointGeometry.createByCurve(targets, adsk.fusion.JointKeyPointTypes.CenterKeyPoint)
                joints = comp.joints
                jointInput = joints.createInput(component, target)
                joint = joints.add(jointInput)
                
            else:
                component = adsk.fusion.JointGeometry.createByCurve(components, adsk.fusion.JointKeyPointTypes.CenterKeyPoint)
                target = adsk.fusion.JointGeometry.createByPoint(targets)
                joints = comp.joints
                jointInput = joints.createInput(component, target)
                joint = joints.add(jointInput)

        comp.isJointsFolderLightBulbOn = False   

    # =========================================================================== #

    # This function will be called when the user completes the command.

    def command_destroy(args: adsk.core.CommandEventArgs):
        global local_handlers
        local_handlers = []

    # =========================================================================== #&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 08 Aug 2023 21:20:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/flipping-joint/m-p/12158111#M3064</guid>
      <dc:creator>brad.bylls</dc:creator>
      <dc:date>2023-08-08T21:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Flipping Joint</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/flipping-joint/m-p/12173801#M3065</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3623640"&gt;@brad.bylls&lt;/a&gt;&amp;nbsp;, Can you please share your file or at least the part in which the 2 components are contained so that we can have a closer look?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 05:50:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/flipping-joint/m-p/12173801#M3065</guid>
      <dc:creator>mayank.malukani</dc:creator>
      <dc:date>2023-08-16T05:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Flipping Joint</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/flipping-joint/m-p/12173803#M3066</link>
      <description>&lt;P&gt;&lt;SPAN&gt;To attach your model :&amp;nbsp; Open it in Fusion 360, select the File menu, then Export and save to you hard drive. &amp;nbsp;Attach to a reply post using the Attachment section.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 05:54:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/flipping-joint/m-p/12173803#M3066</guid>
      <dc:creator>mayank.malukani</dc:creator>
      <dc:date>2023-08-16T05:54:08Z</dc:date>
    </item>
  </channel>
</rss>

