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
This commit is contained in:
wmayer
2018-04-23 11:09:26 +02:00
parent c518744e39
commit a099eb3caf
2 changed files with 13 additions and 6 deletions

View File

@@ -30,6 +30,8 @@
#endif
#include "Workbench.h"
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/MenuManager.h>
#include <Gui/ToolBarManager.h>
#include <Gui/Selection.h>
@@ -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;
}

View File

@@ -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())