コード例 #1
0
    def AddAxialRotationJoint(self, static, dynamic):
        existingjoints = 1
        for obj1 in FreeCAD.ActiveDocument.Objects:  #Count the existing joints
            if obj1.Label.startswith('joint'):
                existingjoints = existingjoints + 1

        obj = 'joint_' + static.label + '_' + dynamic.label
        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", obj)
        Axialrotation(a, str(existingjoints), static, dynamic)
        CustomView(a.ViewObject)
        #Move the object to it's container
        FreeCAD.ActiveDocument.getObject('Axial_rotation_joints').addObject(a)
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("x: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("y: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("z: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("jf: " +
                                                     str(existingjoints))[0])
        #Add vectors to animate reaction forces:
        a.Label = 'joint: ' + str(existingjoints)  #rename the joint
コード例 #2
0
    def AddDeformableDisplacementJoint(self, node1, node2):
        existingjoints = 1
        for obj1 in FreeCAD.ActiveDocument.Objects:  #Count the existing joints
            if obj1.Label.startswith('joint'):
                existingjoints = existingjoints + 1

        obj = 'joint_' + node1.label + '_' + node2.label
        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", obj)
        DeformableDisplacement(a, existingjoints, node1, node2)
        a.Label = 'joint: ' + str(existingjoints)
        CustomView(a.ViewObject)
        #Move the object to it's container
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("x: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("y: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("z: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("jf: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("sp: " +
                                                     str(existingjoints))[0])
        FreeCAD.ActiveDocument.getObject(
            "Deformable_displacement_joints").addObject(a)
コード例 #3
0
    def AddClampJoint(self, node):
        #Count the existing joints:
        existingjoints = 1
        for obj1 in FreeCAD.ActiveDocument.Objects:  #Count the existing joints
            if obj1.Label.startswith('joint'):
                existingjoints = existingjoints + 1

        obj = 'joint_' + node.label
        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", obj)
        Clamp(a, str(existingjoints), node)
        CustomView(a.ViewObject)
        #Move objects to their containers:
        FreeCAD.ActiveDocument.getObject('Clamp_joints').addObject(a)
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("x: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("y: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("z: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("jf: " +
                                                     str(existingjoints))[0])
        a.Label = 'joint: ' + str(existingjoints)  #rename the clamp
コード例 #4
0
    def AddPrismaticJoint(self, node1, node2):
        existingjoints = 1
        for obj1 in FreeCAD.ActiveDocument.Objects:  #Count the existing joints
            if obj1.Label.startswith('joint'):
                existingjoints = existingjoints + 1

        obj = 'joint_' + node1.label + '_' + node2.label
        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", obj)
        Prismatic(a, str(existingjoints), node1, node2)
        CustomView(a.ViewObject)
        #Move the object to it's container
        FreeCAD.ActiveDocument.getObject("Prismatic_joints").addObject(a)
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("x: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("y: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("z: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("jf: " +
                                                     str(existingjoints))[0])
        a.Label = 'joint: ' + str(existingjoints)  #rename the joint
コード例 #5
0
    def AddRevoluteHingeJoint(self, node1, node2, cylinder):
        obj = 'joint_' + node1.label + '_' + node2.label
        #Count the existing joints:
        existingjoints = 1
        for obj1 in FreeCAD.ActiveDocument.Objects:  #Count the existing joints
            if obj1.Label.startswith('joint'):
                existingjoints = existingjoints + 1

        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", obj)
        Revolutehinge(a, str(existingjoints), node1, node2, cylinder)
        CustomView(a.ViewObject)
        #ManageAxes.AddAxes(cylinder,'joint',str(existingjoints))
        a.Label = 'joint: ' + str(existingjoints)  #rename the hinge
        #Move objects to their containers:
        FreeCAD.ActiveDocument.getObject('Revolute_hinge_joints').addObject(a)
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("x: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("y: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("z: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("jf: " +
                                                     str(existingjoints))[0])
コード例 #6
0
    def AddRevolutePin(
        self, node, referenceCylinder
    ):  #This method receives a dynamic node and a cylinder and adds a revolute pin to the node, and around the center of mass of the cylinder
        obj = 'joint_' + node.label
        referenceCylinder.ViewObject.Visibility = False  #Hide the reference cylinder
        #Count the existing joints:
        existingjoints = 1
        for obj1 in FreeCAD.ActiveDocument.Objects:  #Count the existing joints
            if obj1.Label.startswith('joint'):
                existingjoints = existingjoints + 1

        a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", obj)
        Revolutepin(a, str(existingjoints), node, referenceCylinder)
        CustomView(a.ViewObject)
        a.ViewObject.Transparency = 85
        a.ViewObject.LineWidth = 1.00
        #a.ViewObject.Selectable = False
        a.Shape = referenceCylinder.Shape
        #a.ViewObject.Selectable = False
        a.Label = 'joint: ' + str(existingjoints)  #rename the hinge
        #Move objects to their containers:
        FreeCAD.ActiveDocument.getObject('Revolute_pin_joints').addObject(a)
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("x: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("y: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("z: joint: " +
                                                     str(existingjoints))[0])
        a.addObject(
            FreeCAD.ActiveDocument.getObjectsByLabel("jf: " +
                                                     str(existingjoints))[0])
コード例 #7
0
    def AddStructuralForce(self, node):
        existingforces = 1
        for obj1 in FreeCAD.ActiveDocument.Objects:  #Count the existing joints
            if obj1.Label.startswith('force'):
                existingforces = existingforces + 1

        obj = 'force_' + node.label
        a = FreeCAD.ActiveDocument.addObject("App::FeaturePython", obj)
        StructuralForce(a, str(existingforces), node)
        CustomView(a.ViewObject)
        #Move the object to it's container
        FreeCAD.ActiveDocument.getObject("Structural_forces").addObject(a)
        a.Label = 'force: ' + str(existingforces)  #rename the joint
コード例 #8
0
 def AddGravity(self):  #This method adds gravity to the simulation:
     if (len(FreeCAD.ActiveDocument.getObjectsByLabel("MBDyn_simulation"))
             == 1):  #Only if a world exists:
         #Add gravity:
         obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",
                                                "gravity")
         Gravity(obj)
         CustomView(obj.ViewObject)
         #Move the gravity object to it's container:
         FreeCAD.ActiveDocument.getObject("Forces").addObject(obj)
     else:
         QtGui.QMessageBox.information(None, 'Error.',
                                       'You have to create a world firts.')
コード例 #9
0
 def CreateWorld(
     self
 ):  #This method creates all the containers in the tree view and moves all the exiting objects into the "Bodies" container.
     if (len(FreeCAD.ActiveDocument.getObjectsByLabel("MBDyn_simulation"))
             == 0):  #Only if a world does not exist:
         if (len(FreeCAD.ActiveDocument.Objects) > 0):
             Createworld(
             )  #Adds all the goups and the global reference frame
             #Create a simulation and move it into the container:
             a = FreeCAD.ActiveDocument.addObject("App::FeaturePython",
                                                  "MBDyn")
             MBDyn(a)
             CustomView(a.ViewObject)
             FreeCAD.ActiveDocument.getObject("MBDyn_simulation").addObject(
                 a)
             #Create a simulation parameters object and move it to its container:
             b = FreeCAD.ActiveDocument.addObject("App::FeaturePython",
                                                  "Animation")
             Animation_parameters(b)
             CustomView(b.ViewObject)
             FreeCAD.ActiveDocument.getObject("MBDyn_simulation").addObject(
                 b)
             #Create control data parameters object and move it to its container:
             c = FreeCAD.ActiveDocument.addObject("App::FeaturePython",
                                                  "ControlData")
             ControlData(c)
             CustomView(c.ViewObject)
             FreeCAD.ActiveDocument.getObject("MBDyn_simulation").addObject(
                 c)
         else:
             QtGui.QMessageBox.information(
                 None, 'Error.',
                 'You need at least one solid object to create a simulation.'
             )
     else:
         QtGui.QMessageBox.information(None, 'Error.',
                                       'A world has already been created.')
コード例 #10
0
 def AddStructuralDumyNode(self, node, baseBody):
     obj = 'structural_' + baseBody.Label
     a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", obj)
     Dummynode(a, node, baseBody)
     CustomView(a.ViewObject)
     a.Label = 'structural: ' + baseBody.Label
     #Move objects to their container
     FreeCAD.ActiveDocument.getObject("Dummy_nodes").addObject(a)
     a.addObject(
         FreeCAD.ActiveDocument.getObjectsByLabel("x: structural: " +
                                                  baseBody.Label)[0])
     a.addObject(
         FreeCAD.ActiveDocument.getObjectsByLabel("y: structural: " +
                                                  baseBody.Label)[0])
     a.addObject(
         FreeCAD.ActiveDocument.getObjectsByLabel("z: structural: " +
                                                  baseBody.Label)[0])
コード例 #11
0
 def AddStructuralStaticNode(self, baseBody):
     obj = 'structural_' + baseBody.Label
     a = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", obj)
     Structuralstaticnode(a, baseBody)
     CustomView(a.ViewObject)
     a.Label = "structural: " + baseBody.Label
     #Move objects to their container:
     FreeCAD.ActiveDocument.getObject("Static_nodes").addObject(a)
     a.addObject(
         FreeCAD.ActiveDocument.getObjectsByLabel("x: structural: " +
                                                  baseBody.Label)[0])
     a.addObject(
         FreeCAD.ActiveDocument.getObjectsByLabel("y: structural: " +
                                                  baseBody.Label)[0])
     a.addObject(
         FreeCAD.ActiveDocument.getObjectsByLabel("z: structural: " +
                                                  baseBody.Label)[0])
コード例 #12
0
 def AddStructuralDynamicNode(self, baseBody):
     obj = 'structural_' + baseBody.Label
     node = FreeCAD.ActiveDocument.addObject("Part::FeaturePython", obj)
     Structuraldynamicnode(node, baseBody)
     CustomView(node.ViewObject)
     node.Label = 'structural: ' + baseBody.Label
     #Move objects to their container
     FreeCAD.ActiveDocument.getObject("Dynamic_nodes").addObject(node)
     node.addObject(
         FreeCAD.ActiveDocument.getObjectsByLabel('x: structural: ' +
                                                  baseBody.Label)[0])
     node.addObject(
         FreeCAD.ActiveDocument.getObjectsByLabel('y: structural: ' +
                                                  baseBody.Label)[0])
     node.addObject(
         FreeCAD.ActiveDocument.getObjectsByLabel('z: structural: ' +
                                                  baseBody.Label)[0])