Skip to content

Commit

Permalink
add toolbar cmd for creating GeomConstraints obj
Browse files Browse the repository at this point in the history
  • Loading branch information
martcram committed Jul 10, 2022
1 parent 7024f38 commit 00b28ee
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gui/Workbench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Gui::ToolBarItem *Workbench::setupToolBars() const
Gui::ToolBarItem *obstructions = new Gui::ToolBarItem(root);
obstructions->setCommand("Obstructions");
*obstructions
<< "APLAN_GeomConstraints"
<< "APLAN_ObstructionDetectorOCCT";

Gui::ToolBarItem* results = new Gui::ToolBarItem(root);
Expand Down
13 changes: 12 additions & 1 deletion ObjectsAplan.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
# @{

import FreeCAD
from aplansolvers.aplan_obstruction_detectors import base_obstruction_detector as base
try:
import typing
except ImportError as ie:
Expand Down Expand Up @@ -86,7 +87,7 @@ def makeConnectionDetectorSwellOCCT(doc, name="ConnectDetector"):


def makeTopoConstraints(analysis, constraints: typing.Set[typing.Tuple[str, str]] = set(), name="TopoConstraints"):
"""makeTopoConstraints(analysis, constraints, [name]):
"""makeTopoConstraints(analysis, [constraints], [name]):
makes an APLAN TopoConstraints object"""
import aplanobjects.topo_constraints
obj = aplanobjects.topo_constraints.create(
Expand All @@ -101,3 +102,13 @@ def makeObstructionDetectorOCCT(doc, name="ObstructDetector"):
from aplansolvers.aplan_obstruction_detectors import occt
obj = occt.create(doc, name)
return obj


def makeGeomConstraints(analysis, motionDirection: base.IMotionDirection = base.UndefMotionDirection.UNDEF,
constraints: typing.Set[typing.Tuple[str, str]] = set(), name="GeomConstraints"):
"""makeGeomConstraints(analysis, [motionDirection], [constraints], [name]):
makes an APLAN GeomConstraints object"""
import aplanobjects.geom_constraints
obj = aplanobjects.geom_constraints.create(
FreeCAD.ActiveDocument, analysis, motionDirection, constraints, name)
return obj
22 changes: 22 additions & 0 deletions aplancommands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,27 @@ def Activated(self) -> None:
aplanutils.purgeConstraints(AplanGui.getActiveAnalysis())


class _GeomConstraints(CommandManager):
"Creates a geometrical constraints object"

def __init__(self):
super(_GeomConstraints, self).__init__()
self.menutext = Qt.QT_TRANSLATE_NOOP(
"APLAN_GeomConstraints",
"Geometrical constraints"
)
self.tooltip = Qt.QT_TRANSLATE_NOOP(
"APLAN_GeomConstraints",
"Creates a geometrical constraints object"
)
self.is_active = "with_analysis"
self.do_activated = "add_obj_on_gui_set_edit"

def Activated(self) -> None:
obj = ObjectsAplan.makeGeomConstraints(AplanGui.getActiveAnalysis())
FreeCAD.ActiveDocument.recompute()


class _ObstructionDetectorOCCT(CommandManager):
"..."

Expand Down Expand Up @@ -220,6 +241,7 @@ def Activated(self) -> None:
FreeCADGui.addCommand("APLAN_CompoundsPurge", _CompoundsPurge())
FreeCADGui.addCommand("APLAN_ConnectionDetectorSwellOCCT", _ConnectionDetectorSwellOCCT())
FreeCADGui.addCommand("APLAN_ConstraintsPurge", _ConstraintsPurge())
FreeCADGui.addCommand("APLAN_GeomConstraints", _GeomConstraints())
FreeCADGui.addCommand("APLAN_ObstructionDetectorOCCT", _ObstructionDetectorOCCT())
FreeCADGui.addCommand("APLAN_PartFilter", _PartFilter())
FreeCADGui.addCommand("APLAN_ToggleTransparency", _ToggleTransparency())
Expand Down

0 comments on commit 00b28ee

Please sign in to comment.