Replies: 1 comment 28 replies
-
Thanks for the compliment, that's appreciated!
void MainWindow::createCommands()
{
// ...
this->addCommand<MyCommandCreateBox>();
}
void MainWindow::createMenus()
{
// ...
{ // Tools
auto menu = m_ui->menu_Tools;
fnAddAction(menu, CommandSaveViewImage::Name);
fnAddAction(menu, CommandInspectXde::Name);
menu->addSeparator();
fnAddAction(menu, CommandEditOptions::Name);
menu->addSeparator();
fnAddAction(menu, MyCommandCreateBox::Name); // <-- YOUR COMMAND ACTION INSERTED HERE
}
void MyCommandCreateBox::execute()
{
auto guiDoc = this->context()->currentGuiDocument();
auto doc = guiDoc ? guiDoc->document() : nullptr;
if (doc) {
// Create box BREP shape
const TopoDS_Shape shapeBox = BRepPrimAPI_MakeBox(100, 100, 100).Solid();
// Declare a label in the XDE structure to store the created shape
const TDF_Label labelShape = doc->xcaf().shapeTool()->NewShape();
doc->xcaf().shapeTool()->SetShape(labelShape, shapeBox);
// Set a name associated to the shape
TDataStd_Name::Set(labelShape, "MyBox");
// Add root entity to the document, throws signal Document::signalEntityAdded caught by GuiApplication that
// will automatically create/add 3D graphics in the corresponding GuiDocument object
doc->addEntityTreeNode(labelShape);
}
} |
Beta Was this translation helpful? Give feedback.
28 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First! Thanks for developing the wonderful cad viewer mayo, it it really a very good software!
If possible, coudld you please kindly help to provide some details regarding how geometries can be added / edited in mayo using occ interfaces? This would be helpful for some simple geometry creatations and operations (such as boolen etc).
Beta Was this translation helpful? Give feedback.
All reactions