Skip to content

Commit

Permalink
Assembly: Add 'Angle', 'Perpendicular' and 'Parallel' joints.
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddleStroke committed May 27, 2024
1 parent db48a78 commit 44a25cf
Show file tree
Hide file tree
Showing 10 changed files with 935 additions and 28 deletions.
20 changes: 20 additions & 0 deletions src/Mod/Assembly/App/AssemblyObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@
#include <OndselSolver/ASMTMarker.h>
#include <OndselSolver/ASMTPart.h>
#include <OndselSolver/ASMTJoint.h>
#include <OndselSolver/ASMTAngleJoint.h>
#include <OndselSolver/ASMTFixedJoint.h>
#include <OndselSolver/ASMTGearJoint.h>
#include <OndselSolver/ASMTRevoluteJoint.h>
#include <OndselSolver/ASMTCylindricalJoint.h>
#include <OndselSolver/ASMTTranslationalJoint.h>
#include <OndselSolver/ASMTSphericalJoint.h>
#include <OndselSolver/ASMTParallelAxesJoint.h>
#include <OndselSolver/ASMTPerpendicularJoint.h>
#include <OndselSolver/ASMTPointInPlaneJoint.h>
#include <OndselSolver/ASMTPointInLineJoint.h>
#include <OndselSolver/ASMTLineInPlaneJoint.h>
Expand Down Expand Up @@ -846,6 +849,23 @@ std::shared_ptr<ASMTJoint> AssemblyObject::makeMbdJointOfType(App::DocumentObjec
else if (type == JointType::Distance) {
return makeMbdJointDistance(joint);
}
else if (type == JointType::Parallel) {
return CREATE<ASMTParallelAxesJoint>::With();
}
else if (type == JointType::Perpendicular) {
return CREATE<ASMTPerpendicularJoint>::With();
}
else if (type == JointType::Angle) {
double angle = fabs(Base::toRadians(getJointDistance(joint)));
if (fmod(angle, 2 * M_PI) < Precision::Confusion()) {
return CREATE<ASMTParallelAxesJoint>::With();
}
else {
auto mbdJoint = CREATE<ASMTAngleJoint>::With();
mbdJoint->theIzJz = angle;
return mbdJoint;
}
}
else if (type == JointType::RackPinion) {
auto mbdJoint = CREATE<ASMTRackPinionJoint>::With();
mbdJoint->pitchRadius = getJointDistance(joint);
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Assembly/App/AssemblyObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ enum class JointType
Slider,
Ball,
Distance,
Parallel,
Perpendicular,
Angle,
RackPinion,
Screw,
Gears,
Expand Down
91 changes: 87 additions & 4 deletions src/Mod/Assembly/CommandCreateJoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,86 @@ def Activated(self):
activateJoint(5)


class CommandCreateJointParallel:
def __init__(self):
pass

def GetResources(self):

return {
"Pixmap": "Assembly_CreateJointParallel",
"MenuText": QT_TRANSLATE_NOOP("Assembly_CreateJointParallel", "Create Parallel Joint"),
"Accel": "N",
"ToolTip": "<p>"
+ QT_TRANSLATE_NOOP(
"Assembly_CreateJointParallel",
"Create an Parallel Joint: Make the Z axis of selected coordinate systems parallel.",

Check warning on line 254 in src/Mod/Assembly/CommandCreateJoint.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (101/100) (line-too-long)
)
+ "</p>",
"CmdType": "ForEdit",
}

def IsActive(self):
return isCreateJointActive()

def Activated(self):
activateJoint(6)


class CommandCreateJointPerpendicular:
def __init__(self):
pass

def GetResources(self):

return {
"Pixmap": "Assembly_CreateJointPerpendicular",
"MenuText": QT_TRANSLATE_NOOP(
"Assembly_CreateJointPerpendicular", "Create Perpendicular Joint"
),
"Accel": "M",
"ToolTip": "<p>"
+ QT_TRANSLATE_NOOP(
"Assembly_CreateJointPerpendicular",
"Create an Perpendicular Joint: Make the Z axis of selected coordinate systems perpendicular.",

Check warning on line 282 in src/Mod/Assembly/CommandCreateJoint.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (111/100) (line-too-long)
)
+ "</p>",
"CmdType": "ForEdit",
}

def IsActive(self):
return isCreateJointActive()

def Activated(self):
activateJoint(7)


class CommandCreateJointAngle:
def __init__(self):
pass

def GetResources(self):

return {
"Pixmap": "Assembly_CreateJointAngle",
"MenuText": QT_TRANSLATE_NOOP("Assembly_CreateJointAngle", "Create Angle Joint"),
"Accel": "X",
"ToolTip": "<p>"
+ QT_TRANSLATE_NOOP(
"Assembly_CreateJointAngle",
"Create an Angle Joint: Fix the angle between the Z axis of selected coordinate systems.",

Check warning on line 308 in src/Mod/Assembly/CommandCreateJoint.py

View workflow job for this annotation

GitHub Actions / Lint / Lint

Line too long (106/100) (line-too-long)
)
+ "</p>",
"CmdType": "ForEdit",
}

def IsActive(self):
return isCreateJointActive()

def Activated(self):
activateJoint(8)


class CommandCreateJointRackPinion:
def __init__(self):
pass
Expand Down Expand Up @@ -268,7 +348,7 @@ def IsActive(self):
return isCreateJointActive()

def Activated(self):
activateJoint(6)
activateJoint(9)


class CommandCreateJointScrew:
Expand Down Expand Up @@ -299,7 +379,7 @@ def IsActive(self):
return isCreateJointActive()

def Activated(self):
activateJoint(7)
activateJoint(10)


class CommandCreateJointGears:
Expand Down Expand Up @@ -330,7 +410,7 @@ def IsActive(self):
return isCreateJointActive()

def Activated(self):
activateJoint(8)
activateJoint(11)


class CommandCreateJointBelt:
Expand Down Expand Up @@ -361,7 +441,7 @@ def IsActive(self):
return isCreateJointActive()

def Activated(self):
activateJoint(9)
activateJoint(12)


class CommandGroupGearBelt:
Expand Down Expand Up @@ -483,6 +563,9 @@ def Activated(self):
Gui.addCommand("Assembly_CreateJointSlider", CommandCreateJointSlider())
Gui.addCommand("Assembly_CreateJointBall", CommandCreateJointBall())
Gui.addCommand("Assembly_CreateJointDistance", CommandCreateJointDistance())
Gui.addCommand("Assembly_CreateJointParallel", CommandCreateJointParallel())
Gui.addCommand("Assembly_CreateJointPerpendicular", CommandCreateJointPerpendicular())
Gui.addCommand("Assembly_CreateJointAngle", CommandCreateJointAngle())
Gui.addCommand("Assembly_CreateJointRackPinion", CommandCreateJointRackPinion())
Gui.addCommand("Assembly_CreateJointScrew", CommandCreateJointScrew())
Gui.addCommand("Assembly_CreateJointGears", CommandCreateJointGears())
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Assembly/Gui/Resources/Assembly.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
<file>icons/Assembly_InsertLink.svg</file>
<file>icons/preferences-assembly.svg</file>
<file>icons/Assembly_ToggleGrounded.svg</file>
<file>icons/Assembly_CreateJointAngle.svg</file>
<file>icons/Assembly_CreateJointBall.svg</file>
<file>icons/Assembly_CreateJointCylindrical.svg</file>
<file>icons/Assembly_CreateJointFixed.svg</file>
<file>icons/Assembly_CreateJointParallel.svg</file>
<file>icons/Assembly_CreateJointPerpendicular.svg</file>
<file>icons/Assembly_CreateJointPlanar.svg</file>
<file>icons/Assembly_CreateJointRevolute.svg</file>
<file>icons/Assembly_CreateJointSlider.svg</file>
Expand Down
Loading

0 comments on commit 44a25cf

Please sign in to comment.