basic infrastructure
This commit is contained in:
committed by
Stefan Tröger
parent
395557b096
commit
d50f7f1787
@@ -6,6 +6,7 @@ endif(MSVC)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/src/Mod/Assembly/App
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${COIN_INCLUDE_DIR}
|
||||
@@ -15,7 +16,7 @@ include_directories(
|
||||
${PYTHON_INCLUDE_DIRS}
|
||||
${COIN3D_INCLUDE_DIRS}
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
#${ODE_INCLUDE_DIRS}
|
||||
${EIGEN3_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(AssemblyGui_LIBS
|
||||
|
||||
@@ -77,7 +77,7 @@ void CmdAssemblyAddNewPart::activated(int iMsg)
|
||||
doCommand(Doc,"App.activeDocument().addObject('Assembly::ItemPart','%s')",PartName.c_str());
|
||||
if(dest){
|
||||
std::string fatherName = dest->getNameInDocument();
|
||||
doCommand(Doc,"App.activeDocument().%s.Items = App.activeDocument().%s.Items + [App.activeDocument().%s] ",fatherName.c_str(),fatherName.c_str(),PartName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.addPart(App.activeDocument().%s) ",fatherName.c_str(),PartName.c_str());
|
||||
}
|
||||
Command::addModule(App,"PartDesign");
|
||||
Command::addModule(Gui,"PartDesignGui");
|
||||
@@ -139,7 +139,7 @@ void CmdAssemblyAddNewComponent::activated(int iMsg)
|
||||
doCommand(Doc,"App.activeDocument().addObject('Assembly::ItemAssembly','%s')",CompName.c_str());
|
||||
if(dest){
|
||||
std::string fatherName = dest->getNameInDocument();
|
||||
doCommand(Doc,"App.activeDocument().%s.Items = App.activeDocument().%s.Items + [App.activeDocument().%s] ",fatherName.c_str(),fatherName.c_str(),CompName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.addComponent(App.activeDocument().%s) ",fatherName.c_str(), CompName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/FileDialog.h>
|
||||
#include <Gui/Selection.h>
|
||||
|
||||
#include <Mod/Assembly/App/ItemAssembly.h>
|
||||
#include <Mod/Assembly/App/ConstraintGroup.h>
|
||||
@@ -83,6 +84,17 @@ bool getConstraintPrerequisits(Assembly::ItemAssembly **Asm,Assembly::Constraint
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
std::string asSubLinkString(Assembly::ItemPart* part, std::string element) {
|
||||
std::string buf;
|
||||
buf += "(App.ActiveDocument.";
|
||||
buf += part->getNameInDocument();
|
||||
buf += ",['";
|
||||
buf += element;
|
||||
buf += "'])";
|
||||
return buf;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD(CmdAssemblyConstraintAxle);
|
||||
@@ -108,11 +120,26 @@ void CmdAssemblyConstraintAxle::activated(int iMsg)
|
||||
// retrive the standard objects needed
|
||||
if(getConstraintPrerequisits(&Asm,&ConstGrp))
|
||||
return;
|
||||
|
||||
std::vector<Gui::SelectionObject> objs = Gui::Selection().getSelectionEx();
|
||||
if(objs.size() != 2) {
|
||||
Base::Console().Message("you must select two geometries on two diffrent parts\n");
|
||||
return;
|
||||
};
|
||||
|
||||
Assembly::ItemPart* part1 = Asm->getContainingPart(objs[0].getObject());
|
||||
Assembly::ItemPart* part2 = Asm->getContainingPart(objs[1].getObject());
|
||||
if(!part1 || !part2) {
|
||||
Base::Console().Message("The selected objects need to belong to the active assembly\n");
|
||||
return;
|
||||
};
|
||||
|
||||
openCommand("Insert Constraint Axle");
|
||||
std::string ConstrName = getUniqueObjectName("Axle");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Assembly::ItemPart','%s')",ConstrName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Constraints = App.activeDocument().%s.Constraints + [App.activeDocument().ActiveObject]",ConstGrp->getNameInDocument(),ConstGrp->getNameInDocument());
|
||||
doCommand(Doc,"App.activeDocument().addObject('Assembly::ConstraintAxis','%s')",ConstrName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().ActiveObject.First = %s", asSubLinkString(part1, objs[0].getSubNames()[0]).c_str());
|
||||
doCommand(Doc,"App.activeDocument().ActiveObject.Second = %s", asSubLinkString(part2, objs[1].getSubNames()[0]).c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.addConstraint(App.activeDocument().ActiveObject)",ConstGrp->getNameInDocument());
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user