Skip to content

Commit

Permalink
[TD]Include CosmeticLines in Dxf
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jun 30, 2022
1 parent 2326186 commit 460d153
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Mod/TechDraw/App/AppTechDrawPy.cpp
Expand Up @@ -612,6 +612,20 @@ class Module : public Py::ExtensionModule<Module>
s = mkTrf.Shape();
writer.exportShape(s);
}
//add the cosmetic edges also
std::vector<TechDraw::BaseGeomPtr> geoms = dvp->getEdgeGeometry();
std::vector<TopoDS_Edge> cosmeticEdges;
for (auto& g: geoms) {
if (g->hlrVisible && g->cosmetic) {
cosmeticEdges.push_back(g->occEdge);
}
}
if (!cosmeticEdges.empty()) {
s = TechDraw::mirrorShape(DrawUtil::vectorToCompound(cosmeticEdges));
mkTrf.Perform(s);
s = mkTrf.Shape();
writer.exportShape(s);
}
}

Py::Object writeDXFView(const Py::Tuple& args)
Expand Down
11 changes: 11 additions & 0 deletions src/Mod/TechDraw/App/DrawUtil.cpp
Expand Up @@ -801,6 +801,17 @@ bool DrawUtil::isCrazy(TopoDS_Edge e)
return result;
}

//construct a compound shape from a list of edges
TopoDS_Shape DrawUtil::vectorToCompound(std::vector<TopoDS_Edge> vecIn)
{
BRep_Builder builder;
TopoDS_Compound compOut;
builder.MakeCompound(compOut);
for (auto& v : vecIn) {
builder.Add(compOut, v);
}
return compOut;
}
//get 3d position of a face's center
Base::Vector3d DrawUtil::getFaceCenter(TopoDS_Face f)
{
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/TechDraw/App/DrawUtil.h
Expand Up @@ -79,6 +79,9 @@ class TechDrawExport DrawUtil {
double xRange,
double yRange) ;
static Base::Vector3d vertex2Vector(const TopoDS_Vertex& v);

static TopoDS_Shape vectorToCompound(std::vector<TopoDS_Edge> vecIn);

static std::string formatVector(const Base::Vector3d& v);
static std::string formatVector(const gp_Dir& v);
static std::string formatVector(const gp_Dir2d& v);
Expand Down

0 comments on commit 460d153

Please sign in to comment.