コード例 #1
0
ファイル: ModifyPart.py プロジェクト: vexcad/fusion-library
 def show(self, occ):
     comp = occ.component
     parameter = vex_cad.getPartData(comp)['parameters'][self.parameterId]
     self.distanceValue.show(occ)
     self.dropDownInput.listItems.clear()
     self.dropDownInput.listItems.add('Custom', True)
     parameter = vex_cad.getPartData(comp)['parameters'][self.parameterId]
     for item in parameter["expressions"]:
         isSelected = comp.modelParameters.item(parameter['index']).value == unitsMgr.evaluateExpression(item, '')
         self.dropDownInput.listItems.add(item, isSelected)
     
     self.dropDownInput.isVisible = True
     self.distanceValue.isVisible = True
     self.group.isVisible = True
コード例 #2
0
ファイル: ModifyPart.py プロジェクト: vexcad/fusion-library
 def show(self, occ):
     comp = occ.component
     ao = apper.AppObjects()
     parameter = vex_cad.getPartData(comp)['parameters'][self.parameterId]
     
     self.commandInput.expression = comp.modelParameters.item(parameter['index']).expression
     self.commandInput.minimumValue = parameter['min_value']
     self.commandInput.maximumValue = parameter['max_value']
     
     occMatrix3D = occ.transform
     if 'manipulator_point_offset' in parameter:
         pointOffset = parameter['manipulator_point_offset']
         newMatrix3D = adsk.core.Matrix3D.create()
         for i in range(3):
             newMatrix3D.setCell(i, 3, pointOffset[i])
         newMatrix3D.transformBy(occMatrix3D)
         occMatrix3DCoords = newMatrix3D.getAsCoordinateSystem()
     else:
         occMatrix3DCoords = occMatrix3D.getAsCoordinateSystem()
     
     occVector3D = occMatrix3DCoords[coordSys[parameter['manipulator_axis']]]
     if 'manipulator_axis_flipped' in parameter and parameter['manipulator_axis_flipped']:
         occVector3D.scaleBy(-1)
     occPoint3D = occMatrix3DCoords[coordSys['origin']]
     self.commandInput.setManipulator(occPoint3D, occVector3D)
     self.commandInput.isVisible = True
コード例 #3
0
ファイル: ModifyPart.py プロジェクト: vexcad/fusion-library
 def updatePart(self, occ):
     comp = occ.component
     parameter = vex_cad.getPartData(comp)['parameters'][self.parameterId]
     ao = apper.AppObjects()
     unitsMgr = ao.units_manager
     if unitsMgr.isValidExpression(self.commandInput.expression, ''):
         comp.modelParameters.item(parameter['index']).value = self.commandInput.value
コード例 #4
0
ファイル: ModifyPart.py プロジェクト: vexcad/fusion-library
 def iSInsertVisible(comp, insertType):
     for i in range(comp.occurrences.count):
         subComp = comp.occurrences.item(i).component
         if subComp.attributes.itemByName('vex_cad', 'part_data') and 'identifiers' in vex_cad.getPartData(subComp):
             identifiers = vex_cad.getPartData(subComp)['identifiers']
             if 'insert' in identifiers:
                 if insertType in identifiers['insert']:
                     return subComp.isBodiesFolderLightBulbOn
コード例 #5
0
ファイル: ModifyPart.py プロジェクト: vexcad/fusion-library
 def show(self, occ):
     comp = occ.component
     parameter = vex_cad.getPartData(comp)['parameters'][self.parameterId]
     self.distanceValue.show(occ)
     self.intSlider.minimumValue = int(parameter['min_value'] / 1.27)
     self.intSlider.maximumValue = int(parameter['max_value'] / 1.27)
     if self.distanceValue.commandInput.isValidExpression:
         self.intSlider.valueOne = int(self.distanceValue.commandInput.value / 1.27 + 0.99)
     self.intSlider.isVisible = True
     self.group.isVisible = True
コード例 #6
0
ファイル: ModifyPart.py プロジェクト: vexcad/fusion-library
 def command_event_received(self, event_args, command_id, command_definition):
     global importingPart
     if command_id == 'FusionImportCommand':
         importingPart = True
     if command_id == 'FusionMoveCommand':
         if importingPart:
             ao = apper.AppObjects()
             tempPart = ao.ui.activeSelections.item(0).entity
             if tempPart.component.attributes.itemByName('vex_cad', 'part_data') and 'parameters' in vex_cad.getPartData(tempPart.component):
                 global importedPart
                 importedPart = tempPart
             else:
                 importingPart = False
コード例 #7
0
ファイル: ModifyPart.py プロジェクト: vexcad/fusion-library
    def on_input_changed(self, command: adsk.core.Command, inputs: adsk.core.CommandInputs, changed_input, input_values):
        ao = apper.AppObjects()
        app = adsk.core.Application.get()

        selectionInput = inputs.itemById('selection_input_id')
        if selectionInput.selectionCount > 0:
            selectedOcc = selectionInput.selection(0).entity
            # Prevent the root component from being selected
            if selectedOcc.objectType != 'adsk::fusion::Occurrence':
                selectionInput.clearSelection()
                return
            selectedComp = selectedOcc.component
            # Check if the part is parametric, if not check it's parent occurrence
            for i in range(2):
                if selectedComp.attributes.itemByName('vex_cad', 'part_data') and 'parameters' in vex_cad.getPartData(selectedComp):
                    if changed_input.id == 'selection_input_id':
                        # This is needed if the user selects a differant part without deselecting first
                        hideAllCommandInputs()
                        # Show the the controls for the parameters the part has
                        showSomeCommandInputs(selectedOcc)
                        if selectionInput.selectionCount == 0:
                            selectionInput.addSelection(selectedOcc)
                    else:
                        # ao.ui.messageBox('before updateInputs: ' + str(selectedOcc))
                        updateInputs(selectedOcc, changed_input)
                else:
                    selectionInput.clearSelection()
                    # If the selected part is an occurrence and has a parent occurrence
                    if '+' in selectedOcc.fullPathName:
                        # Get the sellected part's parent Occurrence
                        selectedOcc = selectedOcc.assemblyContext
                        selectedComp = selectedOcc.component
        else:
            # Hide the commands for the parameters from the last selected part
            hideAllCommandInputs()
コード例 #8
0
ファイル: ModifyPart.py プロジェクト: vexcad/fusion-library
def parameterManagersInParameters(comp):
    parameters = vex_cad.getPartData(comp)['parameters']
    return [allParameterManagers[parameter] for parameter in parameters if parameter in allParameterManagers]