PartDesign: Prevent problems with link scopes during feature creation

This commit is contained in:
Stefan Tröger
2017-08-06 10:00:56 +02:00
committed by wmayer
parent 7829849104
commit 3e12f4b8c0
4 changed files with 457 additions and 53 deletions

225
src/Gui/Icons/Std_Axis.svg Normal file
View File

@@ -0,0 +1,225 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg5821"
sodipodi:version="0.32"
inkscape:version="0.91 r13725"
sodipodi:docname="PartDesign_Std_Axis_nc1.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1"
inkscape:export-filename="/home/normand/Images/Icônes/PartDesign_Std_Plane_nc1.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs5823">
<linearGradient
inkscape:collect="always"
id="linearGradient6349">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop6351" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop6353" />
</linearGradient>
<linearGradient
id="linearGradient3377">
<stop
style="stop-color:#0019a3;stop-opacity:1;"
offset="0"
id="stop3379" />
<stop
style="stop-color:#0069ff;stop-opacity:1;"
offset="1"
id="stop3381" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3377"
id="linearGradient3383"
x1="901.1875"
y1="1190.875"
x2="1267.9062"
y2="1190.875"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-1,0,0,1,2199.356,0)" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective5829" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient6349"
id="radialGradient6355"
cx="1103.6399"
cy="1424.4465"
fx="1103.6399"
fy="1424.4465"
r="194.40614"
gradientTransform="matrix(-1.4307499,-1.3605156e-7,-1.202713e-8,0.1264801,2674.7488,1244.2826)"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3776"
id="linearGradient3782"
x1="33.052631"
y1="73.676765"
x2="23.483253"
y2="19.131313"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
id="linearGradient3776">
<stop
style="stop-color:#cc0000;stop-opacity:1"
offset="0"
id="stop3778" />
<stop
style="stop-color:#ef2929;stop-opacity:1"
offset="1"
id="stop3780" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="12.721444"
inkscape:cx="23.081174"
inkscape:cy="31.434893"
inkscape:current-layer="g3360-3"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1863"
inkscape:window-height="1176"
inkscape:window-x="57"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:snap-bbox="false"
inkscape:snap-nodes="true"
inkscape:snap-global="false">
<inkscape:grid
type="xygrid"
id="grid2997"
empspacing="2"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<metadata
id="metadata5826">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:creator>
<cc:Agent>
<dc:title>[wmayer]</dc:title>
</cc:Agent>
</dc:creator>
<dc:title>Sketcher_Sketch</dc:title>
<dc:date>2011-10-10</dc:date>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier>FreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Sketcher_Sketch.svg</dc:identifier>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<cc:license>https://www.gnu.org/copyleft/lesser.html</cc:license>
<dc:contributor>
<cc:Agent>
<dc:title>[agryson] Alexander Gryson</dc:title>
</cc:Agent>
</dc:contributor>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
id="g3360"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/draft.png"
inkscape:export-xdpi="3.2478156"
inkscape:export-ydpi="3.2478156"
transform="matrix(0.1367863,0,0,0.1367863,-119.15519,-134.86962)">
<g
id="g3360-3"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/draft.png"
inkscape:export-xdpi="3.2478156"
inkscape:export-ydpi="3.2478156"
transform="translate(-2.96179e-7,2.9614273e-6)">
<rect
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#a79b9e;stroke-width:36.89744032;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
id="rect3860-36"
width="266.52176"
height="266.99686"
x="1138.8126"
y="-720.62769"
transform="matrix(0.86793573,0.49667653,0,-1,0,0)" />
<rect
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#d6d6d6;stroke-width:15.71166039;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
id="rect3860-3"
width="267.47815"
height="265.90598"
x="1141.3009"
y="-714.81689"
transform="matrix(0.8660254,0.5,0,-1,0,0)"
ry="2.5860298" />
<g
id="g4162"
transform="translate(0,47.123207)">
<rect
transform="matrix(0.8660254,0.5,0,1,0,0)"
rx="0"
ry="0"
y="528.82843"
x="1130.2279"
height="22.203979"
width="289.10248"
id="rect4154"
style="fill:none;fill-opacity:1;stroke:#2d2d2d;stroke-width:13.68027687;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<rect
transform="matrix(0.8660254,0.5,0,1,0,0)"
ry="0"
y="530.86877"
x="1132.2762"
height="18.677057"
width="285.00568"
id="rect4156"
style="fill:#473f3f;fill-opacity:1;stroke:none;stroke-width:14.62134743;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.5 KiB

206
src/Gui/Icons/Std_Plane.svg Normal file
View File

@@ -0,0 +1,206 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg5821"
sodipodi:version="0.32"
inkscape:version="0.91 r13725"
sodipodi:docname="PartDesign_XZ_Plane_nc1.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1"
inkscape:export-filename="/media/data/Yorik/FreeCAD/icons/Sketcher.png"
inkscape:export-xdpi="45"
inkscape:export-ydpi="45">
<defs
id="defs5823">
<linearGradient
inkscape:collect="always"
id="linearGradient6349">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop6351" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop6353" />
</linearGradient>
<linearGradient
id="linearGradient3377">
<stop
style="stop-color:#0019a3;stop-opacity:1;"
offset="0"
id="stop3379" />
<stop
style="stop-color:#0069ff;stop-opacity:1;"
offset="1"
id="stop3381" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3377"
id="linearGradient3383"
x1="901.1875"
y1="1190.875"
x2="1267.9062"
y2="1190.875"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-1,0,0,1,2199.356,0)" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective5829" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient6349"
id="radialGradient6355"
cx="1103.6399"
cy="1424.4465"
fx="1103.6399"
fy="1424.4465"
r="194.40614"
gradientTransform="matrix(-1.4307499,-1.3605156e-7,-1.202713e-8,0.1264801,2674.7488,1244.2826)"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3776"
id="linearGradient3782"
x1="33.052631"
y1="73.676765"
x2="23.483253"
y2="19.131313"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
id="linearGradient3776">
<stop
style="stop-color:#cc0000;stop-opacity:1"
offset="0"
id="stop3778" />
<stop
style="stop-color:#ef2929;stop-opacity:1"
offset="1"
id="stop3780" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="12.721444"
inkscape:cx="23.431899"
inkscape:cy="30.757211"
inkscape:current-layer="g3360-3"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1863"
inkscape:window-height="1176"
inkscape:window-x="57"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:snap-bbox="false"
inkscape:snap-nodes="true"
inkscape:snap-global="false">
<inkscape:grid
type="xygrid"
id="grid2997"
empspacing="2"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<metadata
id="metadata5826">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:creator>
<cc:Agent>
<dc:title>[wmayer]</dc:title>
</cc:Agent>
</dc:creator>
<dc:title>Sketcher_Sketch</dc:title>
<dc:date>2011-10-10</dc:date>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier>FreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Sketcher_Sketch.svg</dc:identifier>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<cc:license>https://www.gnu.org/copyleft/lesser.html</cc:license>
<dc:contributor>
<cc:Agent>
<dc:title>[agryson] Alexander Gryson</dc:title>
</cc:Agent>
</dc:contributor>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
id="g3360"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/draft.png"
inkscape:export-xdpi="3.2478156"
inkscape:export-ydpi="3.2478156"
transform="matrix(0.1367863,0,0,0.1367863,-119.15519,-134.86962)">
<g
id="g3360-3"
inkscape:export-filename="/home/yorik/Documents/Lab/Draft/icons/draft.png"
inkscape:export-xdpi="3.2478156"
inkscape:export-ydpi="3.2478156"
transform="translate(-2.96179e-7,2.9614273e-6)">
<g
id="g4172"
transform="matrix(1,0,0,-1,0,2437.8766)">
<rect
transform="matrix(0.86793573,-0.49667653,0,1,0,0)"
y="1717.2489"
x="1138.8126"
height="266.99686"
width="266.52176"
id="rect3860-36"
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#403c3d;stroke-width:36.89362717;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
<rect
ry="2.5860298"
transform="matrix(0.8660254,-0.5,0,1,0,0)"
y="1723.0597"
x="1141.3009"
height="265.90598"
width="267.47815"
id="rect3860-3"
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:none;stroke:#897e7e;stroke-width:15.71166039;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate" />
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@@ -111,7 +111,8 @@ void UnifiedDatumCommand(Gui::Command &cmd, Base::Type type, std::string name)
std::string tmp = std::string("Create ")+name;
cmd.openCommand(tmp.c_str());
cmd.doCommand(Gui::Command::Doc,"App.activeDocument().addObject('%s','%s')",fullTypeName.c_str(),FeatName.c_str());
cmd.doCommand(Gui::Command::Doc,"App.activeDocument().%s.newObject('%s','%s')", pcActiveBody->getNameInDocument(),
fullTypeName.c_str(),FeatName.c_str());
//test if current selection fits a mode.
if (support.getSize() > 0) {
@@ -127,10 +128,6 @@ void UnifiedDatumCommand(Gui::Command &cmd, Base::Type type, std::string name)
QMessageBox::information(Gui::getMainWindow(),QObject::tr("Invalid selection"), QObject::tr("There are no attachment modes that fit selected objects. Select something else."));
}
}
if (pcActiveBody) {
cmd.doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",
pcActiveBody->getNameInDocument(), FeatName.c_str());
}
cmd.doCommand(Gui::Command::Doc,"App.activeDocument().recompute()"); // recompute the feature based on its references
cmd.doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
} else {
@@ -275,17 +272,15 @@ void CmdPartDesignShapeBinder::activated(int iMsg)
openCommand(tmp.c_str());
doCommand(Gui::Command::Doc,"App.activeDocument().addObject('%s','%s')",
"PartDesign::ShapeBinder",FeatName.c_str());
doCommand(Gui::Command::Doc,"App.activeDocument().%s.newObject('%s','%s')",
pcActiveBody->getNameInDocument(), "PartDesign::ShapeBinder",FeatName.c_str());
//test if current selection fits a mode.
if (support.getSize() > 0) {
doCommand(Gui::Command::Doc,"App.activeDocument().%s.Support = %s",
FeatName.c_str(), support.getPyReprString().c_str());
}
doCommand(Gui::Command::Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",
pcActiveBody->getNameInDocument(), FeatName.c_str());
doCommand(Gui::Command::Doc,"App.activeDocument().recompute()"); // recompute the feature based on its references
updateActive();
doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
}
// TODO do a proper error processing (2015-09-11, Fat-Zer)
@@ -453,13 +448,10 @@ void CmdPartDesignNewSketch::activated(int iMsg)
std::string FeatName = getUniqueObjectName("Sketch");
openCommand("Create a Sketch on Face");
doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.newObject('Sketcher::SketchObject','%s')",pcActiveBody->getNameInDocument(), FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Support = %s",FeatName.c_str(),supportString.c_str());
doCommand(Doc,"App.activeDocument().%s.MapMode = '%s'",FeatName.c_str(),Attacher::AttachEngine::getModeName(Attacher::mmFlatFace).c_str());
doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",
pcActiveBody->getNameInDocument(), FeatName.c_str());
doCommand(Gui,"App.activeDocument().recompute()"); // recompute the sketch placement based on its support
//doCommand(Gui,"Gui.activeDocument().activeView().setCamera('%s')",cam.c_str());
updateActive();
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
}
else {
@@ -567,13 +559,10 @@ void CmdPartDesignNewSketch::activated(int iMsg)
std::string supportString = std::string("(App.activeDocument().") + plane->getNameInDocument() +
", [''])";
Gui::Command::doCommand(Doc,"App.activeDocument().addObject('Sketcher::SketchObject','%s')",FeatName.c_str());
Gui::Command::doCommand(Doc,"App.activeDocument().%s.newObject('Sketcher::SketchObject','%s')", pcActiveBody->getNameInDocument(), FeatName.c_str());
Gui::Command::doCommand(Doc,"App.activeDocument().%s.Support = %s",FeatName.c_str(),supportString.c_str());
Gui::Command::doCommand(Doc,"App.activeDocument().%s.MapMode = '%s'",FeatName.c_str(),Attacher::AttachEngine::getModeName(Attacher::mmFlatFace).c_str());
Gui::Command::updateActive(); // Make sure the Support's Placement property is updated
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",
pcActiveBody->getNameInDocument(), FeatName.c_str());
//doCommand(Gui,"Gui.activeDocument().activeView().setCamera('%s')",cam.c_str());
Gui::Command::doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
};
@@ -645,21 +634,6 @@ void finishFeature(const Gui::Command* cmd, const std::string& FeatName,
pcActiveBody = PartDesignGui::getBody(/*messageIfNot = */false);
}
if (pcActiveBody) {
App::DocumentObject* lastSolidFeature = pcActiveBody->Tip.getValue();
if (!prevSolidFeature || prevSolidFeature == lastSolidFeature) {
// If the previous feature not given or is the Tip add Feature after it.
cmd->doCommand(cmd->Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)",
pcActiveBody->getNameInDocument(), FeatName.c_str());
prevSolidFeature = lastSolidFeature;
} else {
// Insert the feature into the body after the given one.
cmd->doCommand(cmd->Doc,
"App.activeDocument().%s.insertObject(App.activeDocument().%s, App.activeDocument().%s, True)",
pcActiveBody->getNameInDocument(), FeatName.c_str(), prevSolidFeature->getNameInDocument());
}
}
if (hidePrevSolid && prevSolidFeature && (prevSolidFeature != NULL))
cmd->doCommand(cmd->Gui,"Gui.activeDocument().hide(\"%s\")", prevSolidFeature->getNameInDocument());
@@ -789,8 +763,8 @@ void prepareProfileBased(Gui::Command* cmd, const std::string& which,
std::string FeatName = cmd->getUniqueObjectName(which.c_str());
Gui::Command::openCommand((std::string("Make ") + which).c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::%s\",\"%s\")",
which.c_str(), FeatName.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.newObject(\"PartDesign::%s\",\"%s\")",
PartDesignGui::getBody(false)->getNameInDocument(), which.c_str(), FeatName.c_str());
if (feature->isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Profile = App.activeDocument().%s",
@@ -968,14 +942,6 @@ void CmdPartDesignPad::activated(int iMsg)
// specific parameters for Pad
Gui::Command::doCommand(Doc,"App.activeDocument().%s.Length = 10.0",FeatName.c_str());
App::DocumentObjectGroup* grp = profile->getGroup();
if (grp) {
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
,grp->getNameInDocument(),FeatName.c_str());
if(profile->isDerivedFrom(Part::Part2DObject::getClassTypeId()))
Gui::Command::doCommand(Doc,"App.activeDocument().%s.removeObject(App.activeDocument().%s)"
,grp->getNameInDocument(), profile->getNameInDocument());
}
Gui::Command::updateActive();
Part::Part2DObject* sketch = dynamic_cast<Part::Part2DObject*>(profile);
@@ -1488,7 +1454,8 @@ void finishDressupFeature(const Gui::Command* cmd, const std::string& which,
std::string FeatName = cmd->getUniqueObjectName(which.c_str());
cmd->openCommand((std::string("Make ") + which).c_str());
cmd->doCommand(cmd->Doc,"App.activeDocument().addObject(\"PartDesign::%s\",\"%s\")",which.c_str(), FeatName.c_str());
cmd->doCommand(cmd->Doc,"App.activeDocument().%s.newObject(\"PartDesign::%s\",\"%s\")",
PartDesignGui::getBodyFor(base,false)->getNameInDocument(), which.c_str(), FeatName.c_str());
cmd->doCommand(cmd->Doc,"App.activeDocument().%s.Base = %s",FeatName.c_str(),SelString.c_str());
cmd->doCommand(cmd->Gui,"Gui.Selection.clearSelection()");
finishFeature(cmd, FeatName, base);
@@ -1695,7 +1662,8 @@ void prepareTransformed(Gui::Command* cmd, const std::string& which,
str << "]";
Gui::Command::openCommand((std::string("Make ") + which + " feature").c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::%s\",\"%s\")",which.c_str(), FeatName.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.newObject(\"PartDesign::%s\",\"%s\")",
PartDesignGui::getBody(false)->getNameInDocument(), which.c_str(), FeatName.c_str());
// FIXME: There seems to be kind of a race condition here, leading to sporadic errors like
// Exception (Thu Sep 6 11:52:01 2012): 'App.Document' object has no attribute 'Mirrored'
Gui::Command::updateActive(); // Helps to ensure that the object already exists when the next command comes up
@@ -2068,7 +2036,7 @@ void CmdPartDesignMultiTransform::activated(int iMsg)
// Create a MultiTransform feature and move the Transformed feature inside it
std::string FeatName = getUniqueObjectName("MultiTransform");
doCommand(Doc, "App.activeDocument().addObject(\"PartDesign::MultiTransform\",\"%s\")", FeatName.c_str());
doCommand(Doc, "App.activeDocument().%s.newObject(\"PartDesign::MultiTransform\",\"%s\")", pcActiveBody->getNameInDocument(), FeatName.c_str());
doCommand(Doc, "App.activeDocument().%s.Originals = App.activeDocument().%s.Originals", FeatName.c_str(), trFeat->getNameInDocument());
doCommand(Doc, "App.activeDocument().%s.Originals = []", trFeat->getNameInDocument());
doCommand(Doc, "App.activeDocument().%s.Transformations = [App.activeDocument().%s]", FeatName.c_str(), trFeat->getNameInDocument());
@@ -2140,7 +2108,7 @@ void CmdPartDesignBoolean::activated(int iMsg)
openCommand("Create Boolean");
std::string FeatName = getUniqueObjectName("Boolean");
doCommand(Doc,"App.activeDocument().addObject('PartDesign::Boolean','%s')",FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.newObject('PartDesign::Boolean','%s')", pcActiveBody->getNameInDocument(), FeatName.c_str());
if (BodyFilter.match() && !BodyFilter.Result.empty()) {
std::vector<App::DocumentObject*> bodies;

View File

@@ -33,6 +33,7 @@
#include "TaskLinearPatternParameters.h"
#include "TaskPolarPatternParameters.h"
#include "TaskScaledParameters.h"
#include "Utils.h"
#include <App/Application.h>
#include <App/Document.h>
#include <Gui/Application.h>
@@ -49,9 +50,9 @@
#include <Mod/PartDesign/App/FeatureLinearPattern.h>
#include <Mod/PartDesign/App/FeaturePolarPattern.h>
#include <Mod/PartDesign/App/FeatureScaled.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/Sketcher/App/SketchObject.h>
using namespace PartDesignGui;
using namespace Gui;
@@ -258,7 +259,8 @@ void TaskMultiTransformParameters::onTransformAddMirrored()
std::string newFeatName = TransformedView->getObject()->getDocument()->getUniqueObjectName("Mirrored");
Gui::Command::openCommand("Mirrored");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::Mirrored\",\"%s\")",newFeatName.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.newObject(\"PartDesign::Mirrored\",\"%s\")",
PartDesignGui::getBody(false)->getNameInDocument(), newFeatName.c_str());
//Gui::Command::updateActive();
App::DocumentObject* sketch = getSketchObject();
if (sketch)
@@ -274,7 +276,8 @@ void TaskMultiTransformParameters::onTransformAddLinearPattern()
std::string newFeatName = TransformedView->getObject()->getDocument()->getUniqueObjectName("LinearPattern");
Gui::Command::openCommand("LinearPattern");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::LinearPattern\",\"%s\")",newFeatName.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.newObject(\"PartDesign::LinearPattern\",\"%s\")",
PartDesignGui::getBody(false), newFeatName.c_str());
//Gui::Command::updateActive();
App::DocumentObject* sketch = getSketchObject();
if (sketch)
@@ -292,7 +295,8 @@ void TaskMultiTransformParameters::onTransformAddPolarPattern()
std::string newFeatName = TransformedView->getObject()->getDocument()->getUniqueObjectName("PolarPattern");
Gui::Command::openCommand("PolarPattern");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::PolarPattern\",\"%s\")",newFeatName.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.newObject(\"PartDesign::PolarPattern\",\"%s\")",
PartDesignGui::getBody(false)->getNameInDocument(), newFeatName.c_str());
//Gui::Command::updateActive();
App::DocumentObject* sketch = getSketchObject();
if (sketch)
@@ -310,7 +314,8 @@ void TaskMultiTransformParameters::onTransformAddScaled()
std::string newFeatName = TransformedView->getObject()->getDocument()->getUniqueObjectName("Scaled");
Gui::Command::openCommand("Scaled");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::Scaled\",\"%s\")",newFeatName.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.newObject(\"PartDesign::Scaled\",\"%s\")",
PartDesignGui::getBody(false)->getNameInDocument(), newFeatName.c_str());
//Gui::Command::updateActive();
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Factor = 2", newFeatName.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Occurrences = 2", newFeatName.c_str());