Assembly: Introduce Belt joint.
This commit is contained in:
committed by
Yorik van Havre
parent
b4168c95ee
commit
13c0ba1902
@@ -691,7 +691,7 @@ bool AssemblyObject::isJointTypeConnecting(App::DocumentObject* joint)
|
||||
{
|
||||
JointType jointType = getJointType(joint);
|
||||
return jointType != JointType::RackPinion && jointType != JointType::Screw
|
||||
&& jointType != JointType::Gears && jointType != JointType::Pulleys;
|
||||
&& jointType != JointType::Gears && jointType != JointType::Belt;
|
||||
}
|
||||
|
||||
void AssemblyObject::removeUnconnectedJoints(std::vector<App::DocumentObject*>& joints,
|
||||
@@ -855,6 +855,12 @@ std::shared_ptr<ASMTJoint> AssemblyObject::makeMbdJointOfType(App::DocumentObjec
|
||||
mbdJoint->radiusJ = getJointDistance2(joint);
|
||||
return mbdJoint;
|
||||
}
|
||||
else if (type == JointType::Belt) {
|
||||
auto mbdJoint = CREATE<ASMTGearJoint>::With();
|
||||
mbdJoint->radiusI = getJointDistance(joint);
|
||||
mbdJoint->radiusJ = -getJointDistance2(joint);
|
||||
return mbdJoint;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ enum class JointType
|
||||
RackPinion,
|
||||
Screw,
|
||||
Gears,
|
||||
Pulleys,
|
||||
Belt,
|
||||
};
|
||||
|
||||
enum class DistanceType
|
||||
|
||||
@@ -249,7 +249,7 @@ class CommandCreateJointRackPinion:
|
||||
"MenuText": QT_TRANSLATE_NOOP(
|
||||
"Assembly_CreateJointRackPinion", "Create Rack and Pinion Joint"
|
||||
),
|
||||
"Accel": "P",
|
||||
"Accel": "Q",
|
||||
"ToolTip": "<p>"
|
||||
+ QT_TRANSLATE_NOOP(
|
||||
"Assembly_CreateJointRackPinion",
|
||||
@@ -315,7 +315,7 @@ class CommandCreateJointGears:
|
||||
"ToolTip": "<p>"
|
||||
+ QT_TRANSLATE_NOOP(
|
||||
"Assembly_CreateJointGears",
|
||||
"Create a Gears Joint: Links two rotating gears together.",
|
||||
"Create a Gears Joint: Links two rotating gears together. They will have inverse rotation direction.",
|
||||
)
|
||||
+ "</p>",
|
||||
"CmdType": "ForEdit",
|
||||
@@ -328,6 +328,55 @@ class CommandCreateJointGears:
|
||||
activateJoint(8)
|
||||
|
||||
|
||||
class CommandCreateJointBelt:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def GetResources(self):
|
||||
|
||||
return {
|
||||
"Pixmap": "Assembly_CreateJointPulleys",
|
||||
"MenuText": QT_TRANSLATE_NOOP("Assembly_CreateJointBelt", "Create Belt Joint"),
|
||||
"Accel": "P",
|
||||
"ToolTip": "<p>"
|
||||
+ QT_TRANSLATE_NOOP(
|
||||
"Assembly_CreateJointBelt",
|
||||
"Create a Belt Joint: Links two rotating objects together. They will have the same rotation direction.",
|
||||
)
|
||||
+ "</p>",
|
||||
"CmdType": "ForEdit",
|
||||
}
|
||||
|
||||
def IsActive(self):
|
||||
return isCreateJointActive()
|
||||
|
||||
def Activated(self):
|
||||
activateJoint(9)
|
||||
|
||||
|
||||
class CommandGroupGearBelt:
|
||||
def GetCommands(self):
|
||||
return ("Assembly_CreateJointGears", "Assembly_CreateJointBelt")
|
||||
|
||||
def GetResources(self):
|
||||
"""Set icon, menu and tooltip."""
|
||||
|
||||
return {
|
||||
"Pixmap": "Assembly_CreateJointGears",
|
||||
"MenuText": QT_TRANSLATE_NOOP("Assembly_CreateJointGears", "Create Gear/Belt Joint"),
|
||||
"ToolTip": "<p>"
|
||||
+ QT_TRANSLATE_NOOP(
|
||||
"Assembly_CreateJointGears",
|
||||
"Create a Gears/Belt Joint: Links two rotating gears together.",
|
||||
)
|
||||
+ "</p>",
|
||||
"CmdType": "ForEdit",
|
||||
}
|
||||
|
||||
def IsActive(self):
|
||||
return isCreateJointActive()
|
||||
|
||||
|
||||
def createGroundedJoint(obj):
|
||||
assembly = UtilsAssembly.activeAssembly()
|
||||
if not assembly:
|
||||
@@ -422,3 +471,5 @@ if App.GuiUp:
|
||||
Gui.addCommand("Assembly_CreateJointRackPinion", CommandCreateJointRackPinion())
|
||||
Gui.addCommand("Assembly_CreateJointScrew", CommandCreateJointScrew())
|
||||
Gui.addCommand("Assembly_CreateJointGears", CommandCreateJointGears())
|
||||
Gui.addCommand("Assembly_CreateJointBelt", CommandCreateJointBelt())
|
||||
Gui.addCommand("Assembly_CreateJointGearBelt", CommandGroupGearBelt())
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<file>icons/Assembly_CreateJointSlider.svg</file>
|
||||
<file>icons/Assembly_CreateJointTangent.svg</file>
|
||||
<file>icons/Assembly_CreateJointGears.svg</file>
|
||||
<file>icons/Assembly_CreateJointPulley.svg</file>
|
||||
<file>icons/Assembly_CreateJointPulleys.svg</file>
|
||||
<file>icons/Assembly_CreateJointRackPinion.svg</file>
|
||||
<file>icons/Assembly_CreateJointScrew.svg</file>
|
||||
<file>icons/Assembly_ExportASMT.svg</file>
|
||||
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
@@ -226,6 +226,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QCheckBox" name="reverseRotCheckbox">
|
||||
<property name="text">
|
||||
<string>Reverse rotation</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
||||
@@ -97,7 +97,7 @@ class AssemblyWorkbench(Workbench):
|
||||
"Separator",
|
||||
"Assembly_CreateJointRackPinion",
|
||||
"Assembly_CreateJointScrew",
|
||||
"Assembly_CreateJointGears",
|
||||
"Assembly_CreateJointGearBelt",
|
||||
]
|
||||
|
||||
self.appendToolbar(QT_TRANSLATE_NOOP("Workbench", "Assembly"), cmdList)
|
||||
|
||||
@@ -54,7 +54,7 @@ TranslatedJointTypes = [
|
||||
translate("Assembly", "RackPinion"),
|
||||
translate("Assembly", "Screw"),
|
||||
translate("Assembly", "Gears"),
|
||||
# translate("Assembly", "Pulleys"),
|
||||
translate("Assembly", "Belt"),
|
||||
]
|
||||
|
||||
JointTypes = [
|
||||
@@ -67,7 +67,7 @@ JointTypes = [
|
||||
"RackPinion",
|
||||
"Screw",
|
||||
"Gears",
|
||||
# "Pulleys",
|
||||
"Belt",
|
||||
]
|
||||
|
||||
JointUsingDistance = [
|
||||
@@ -75,10 +75,19 @@ JointUsingDistance = [
|
||||
"RackPinion",
|
||||
"Screw",
|
||||
"Gears",
|
||||
"Belt",
|
||||
]
|
||||
|
||||
JointUsingDistance2 = [
|
||||
"Gears",
|
||||
"Belt",
|
||||
]
|
||||
|
||||
JointNoNegativeDistance = [
|
||||
"RackPinion",
|
||||
"Screw",
|
||||
"Gears",
|
||||
"Belt",
|
||||
]
|
||||
|
||||
JointUsingOffset = [
|
||||
@@ -281,7 +290,7 @@ class Joint:
|
||||
"Joint",
|
||||
QT_TRANSLATE_NOOP(
|
||||
"App::Property",
|
||||
"This is the distance of the joint. It is used only by the distance joint and by RackPinion (pitch radius), Screw and Gears(radius1)",
|
||||
"This is the distance of the joint. It is used only by the distance joint and by RackPinion (pitch radius), Screw and Gears and Belt(radius1)",
|
||||
),
|
||||
)
|
||||
|
||||
@@ -844,6 +853,8 @@ class ViewProviderJoint:
|
||||
return ":/icons/Assembly_CreateJointScrew.svg"
|
||||
elif self.app_obj.JointType == "Gears":
|
||||
return ":/icons/Assembly_CreateJointGears.svg"
|
||||
elif self.app_obj.JointType == "Belt":
|
||||
return ":/icons/Assembly_CreateJointPulleys.svg"
|
||||
|
||||
return ":/icons/Assembly_CreateJoint.svg"
|
||||
|
||||
@@ -1164,6 +1175,7 @@ class TaskAssemblyCreateJoint(QtCore.QObject):
|
||||
self.form.jointType.currentIndexChanged.connect(self.onJointTypeChanged)
|
||||
|
||||
self.form.distanceSpinbox.valueChanged.connect(self.onDistanceChanged)
|
||||
self.form.distanceSpinbox2.valueChanged.connect(self.onDistance2Changed)
|
||||
self.form.offsetSpinbox.valueChanged.connect(self.onOffsetChanged)
|
||||
self.form.rotationSpinbox.valueChanged.connect(self.onRotationChanged)
|
||||
self.form.PushButtonReverse.clicked.connect(self.onReverseClicked)
|
||||
@@ -1173,6 +1185,10 @@ class TaskAssemblyCreateJoint(QtCore.QObject):
|
||||
self.form.limitRotMinSpinbox.valueChanged.connect(self.onLimitRotMinChanged)
|
||||
self.form.limitRotMaxSpinbox.valueChanged.connect(self.onLimitRotMaxChanged)
|
||||
|
||||
jType = JointTypes[self.form.jointType.currentIndex()]
|
||||
self.form.reverseRotCheckbox.setChecked(jType == "Gears")
|
||||
self.form.reverseRotCheckbox.stateChanged.connect(self.reverseRotToggled)
|
||||
|
||||
if jointObj:
|
||||
Gui.Selection.clearSelection()
|
||||
self.creating = False
|
||||
@@ -1332,13 +1348,15 @@ class TaskAssemblyCreateJoint(QtCore.QObject):
|
||||
ViewProviderJoint(self.joint.ViewObject)
|
||||
|
||||
def onJointTypeChanged(self, index):
|
||||
|
||||
self.joint.Proxy.setJointType(self.joint, JointTypes[self.form.jointType.currentIndex()])
|
||||
self.adaptUi()
|
||||
|
||||
def onDistanceChanged(self, quantity):
|
||||
self.joint.Distance = self.form.distanceSpinbox.property("rawValue")
|
||||
|
||||
def onDistance2Changed(self, quantity):
|
||||
self.joint.Distance2 = self.form.distanceSpinbox2.property("rawValue")
|
||||
|
||||
def onOffsetChanged(self, quantity):
|
||||
self.joint.Offset = App.Vector(0, 0, self.form.offsetSpinbox.property("rawValue"))
|
||||
|
||||
@@ -1360,6 +1378,12 @@ class TaskAssemblyCreateJoint(QtCore.QObject):
|
||||
def onReverseClicked(self):
|
||||
self.joint.Proxy.flipOnePart(self.joint)
|
||||
|
||||
def reverseRotToggled(self, val):
|
||||
if val:
|
||||
self.form.jointType.setCurrentIndex(8)
|
||||
else:
|
||||
self.form.jointType.setCurrentIndex(9)
|
||||
|
||||
def adaptUi(self):
|
||||
jType = JointTypes[self.form.jointType.currentIndex()]
|
||||
|
||||
@@ -1368,7 +1392,7 @@ class TaskAssemblyCreateJoint(QtCore.QObject):
|
||||
self.form.distanceSpinbox.show()
|
||||
if jType == "Distance":
|
||||
self.form.distanceLabel.setText("Distance")
|
||||
elif jType == "Gears":
|
||||
elif jType == "Gears" or jType == "Belt":
|
||||
self.form.distanceLabel.setText("Radius 1")
|
||||
else:
|
||||
self.form.distanceLabel.setText("Pitch radius")
|
||||
@@ -1379,9 +1403,26 @@ class TaskAssemblyCreateJoint(QtCore.QObject):
|
||||
if jType in JointUsingDistance2:
|
||||
self.form.distanceLabel2.show()
|
||||
self.form.distanceSpinbox2.show()
|
||||
self.form.reverseRotCheckbox.show()
|
||||
|
||||
else:
|
||||
self.form.distanceLabel2.hide()
|
||||
self.form.distanceSpinbox2.hide()
|
||||
self.form.reverseRotCheckbox.hide()
|
||||
|
||||
if jType in JointNoNegativeDistance:
|
||||
# Setting minimum to 0.01 to prevent 0 and negative values
|
||||
self.form.distanceSpinbox.setProperty("minimum", 1e-7)
|
||||
if self.form.distanceSpinbox.property("rawValue") == 0.0:
|
||||
self.form.distanceSpinbox.setProperty("rawValue", 1.0)
|
||||
|
||||
if jType == "Gears" or jType == "Belt":
|
||||
self.form.distanceSpinbox2.setProperty("minimum", 1e-7)
|
||||
if self.form.distanceSpinbox2.property("rawValue") == 0.0:
|
||||
self.form.distanceSpinbox2.setProperty("rawValue", 1.0)
|
||||
else:
|
||||
self.form.distanceSpinbox.setProperty("minimum", float("-inf"))
|
||||
self.form.distanceSpinbox2.setProperty("minimum", float("-inf"))
|
||||
|
||||
if jType in JointUsingOffset:
|
||||
self.form.offsetLabel.show()
|
||||
|
||||
Reference in New Issue
Block a user