Skip to content

Commit

Permalink
[TD]correct retrieval of dim text for DXF export
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Feb 11, 2022
1 parent 09a05a9 commit 88004e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/Mod/TechDraw/App/AppTechDrawPy.cpp
Expand Up @@ -709,7 +709,18 @@ class Module : public Py::ExtensionModule<Module>
double parentX = dvp->X.getValue() + grandParentX;
double parentY = dvp->Y.getValue() + grandParentY;
Base::Vector3d parentPos(parentX,parentY,0.0);
std::string sDimText = dvd->getFormattedDimensionValue();
std::string sDimText;
//this is the same code as in QGIViewDimension::updateDim
if (dvd->isMultiValueSchema()) {
sDimText = dvd->getFormattedDimensionValue(0); //don't format multis
} else {
sDimText = dvd->getFormattedDimensionValue(1); //just the number pref/spec/suf
if (dvd->showUnits()) {
std::string unitText = dvd->getFormattedDimensionValue(
2);
sDimText += " " + unitText;
}
}
char* dimText = &sDimText[0u]; //hack for const-ness
float gap = 5.0; //hack. don't know font size here.
layerName = dvd->getNameInDocument();
Expand Down
5 changes: 4 additions & 1 deletion src/Mod/TechDraw/App/DrawViewDimension.cpp
Expand Up @@ -780,7 +780,7 @@ std::string DrawViewDimension::formatValue(qreal value, QString qFormatSpec, int
qMultiValueStr = formatPrefix + qUserString + formatSuffix;
}
return qMultiValueStr.toStdString();
} else {
} else { //not multivalue schema
if (formatSpecifier.isEmpty()) {
Base::Console().Warning("Warning - no numeric format in Format Spec %s - %s\n",
qPrintable(qFormatSpec), getNameInDocument());
Expand Down Expand Up @@ -937,6 +937,9 @@ std::pair<std::string, std::string> DrawViewDimension::getFormattedToleranceValu
return tolerances;
}

//partial = 0 full text for multi-value schemas
//partial = 1 value only
//partial = 2 unit only
std::string DrawViewDimension::getFormattedDimensionValue(int partial)
{
QString qFormatSpec = QString::fromUtf8(FormatSpec.getStrValue().data());
Expand Down

0 comments on commit 88004e8

Please sign in to comment.