From a099eb3caf10b7ef03ffb3c7d4a94ece0fbfcce5 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 23 Apr 2018 11:09:26 +0200 Subject: [PATCH] Improvements on mesh flattening commands: comment out import of pivy because it's not used and pivy.graphics isn't available on all platforms Add MeshPart_ prefix to command names for consistency reasons and to make Qt help working correctly When adding commands to Mesh workbench make sure the commands could be created beforehand to avoid annoying warnings --- src/Mod/Mesh/Gui/Workbench.cpp | 9 ++++++++- src/Mod/MeshPart/Gui/MeshFlatteningCommand.py | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Mod/Mesh/Gui/Workbench.cpp b/src/Mod/Mesh/Gui/Workbench.cpp index 89eece037a..b34c4e27a7 100644 --- a/src/Mod/Mesh/Gui/Workbench.cpp +++ b/src/Mod/Mesh/Gui/Workbench.cpp @@ -30,6 +30,8 @@ #endif #include "Workbench.h" +#include +#include #include #include #include @@ -193,7 +195,12 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Mesh_Merge" << "Mesh_PolySelect" << "Mesh_PolyCut" << "Mesh_PolySplit" << "Mesh_PolySegm" << "Mesh_PolyTrim" << "Separator" << "Mesh_TrimByPlane" << "Mesh_SectionByPlane" << "Mesh_Segmentation" - << "Mesh_VertexCurvature" << "CreateFlatMesh" << "CreateFlatFace"; + << "Mesh_VertexCurvature"; + Gui::CommandManager& mgr = Gui::Application::Instance->commandManager(); + if (mgr.getCommandByName("MeshPart_CreateFlatMesh")) + *mesh << "MeshPart_CreateFlatMesh"; + if (mgr.getCommandByName("MeshPart_CreateFlatFace")) + *mesh << "MeshPart_CreateFlatFace"; return root; } diff --git a/src/Mod/MeshPart/Gui/MeshFlatteningCommand.py b/src/Mod/MeshPart/Gui/MeshFlatteningCommand.py index 7283d2edd2..a3d44fc9ae 100644 --- a/src/Mod/MeshPart/Gui/MeshFlatteningCommand.py +++ b/src/Mod/MeshPart/Gui/MeshFlatteningCommand.py @@ -3,8 +3,8 @@ import FreeCAD as App import FreeCADGui as Gui import Part import numpy as np -from pivy import graphics as g -from pivy import coin +#from pivy import graphics as g +#from pivy import coin class BaseCommand(object): def __init__(self): @@ -34,7 +34,7 @@ class CreateFlatMesh(BaseCommand): boundaries = flattener.getFlatBoundaryNodes() print('number of nodes: {}'.format(len(flattener.ze_nodes))) print('number of faces: {}'.format(len(flattener.tris))) - + wires = [] for edge in boundaries: pi = Part.makePolygon([App.Vector(*node) for node in edge]) @@ -82,5 +82,5 @@ class CreateFlatFace(BaseCommand): assert(isinstance(Gui.Selection.getSelectionEx()[0].SubObjects[0], Part.Face)) return True -Gui.addCommand('CreateFlatMesh', CreateFlatMesh()) -Gui.addCommand('CreateFlatFace', CreateFlatFace()) +Gui.addCommand('MeshPart_CreateFlatMesh', CreateFlatMesh()) +Gui.addCommand('MeshPart_CreateFlatFace', CreateFlatFace())