diff --git a/src/Mod/Draft/App/DraftDxf.cpp b/src/Mod/Draft/App/DraftDxf.cpp
index 4a3558ae2d..b8a63ed684 100644
--- a/src/Mod/Draft/App/DraftDxf.cpp
+++ b/src/Mod/Draft/App/DraftDxf.cpp
@@ -42,8 +42,10 @@
#include
#include
+#include
#include
#include
+#include
#include
using namespace DraftUtils;
@@ -127,7 +129,13 @@ void DraftDxfRead::OnReadEllipse(const double* c, double major_radius, double mi
void DraftDxfRead::OnReadText(const double *point, const double height, const char* text)
{
- // not yet implemented
+ Base::Vector3d pt(point[0],point[1],point[2]);
+ if(LayerName().substr(0, 6) != "BLOCKS") {
+ App::Annotation *pcFeature = (App::Annotation *)document->addObject("App::Annotation", "Text");
+ pcFeature->LabelText.setValue(Deformat(text));
+ pcFeature->Position.setValue(pt);
+ }
+ else std::cout << "skipped text in block: " << LayerName() << std::endl;
}
@@ -178,9 +186,39 @@ void DraftDxfRead::AddObject(Part::TopoShape *shape)
}
+const char* DraftDxfRead::Deformat(const char* text)
+{
+ // this function removes DXF formatting from texts
+ std::stringstream ss;
+ bool escape = false; // turned on when finding an escape character
+ bool longescape = false; // turned on for certain escape codes that expect additional chars
+ for(unsigned int i = 0; i > ::const_iterator i = layers.begin(); i != layers.end(); ++i) {
BRep_Builder builder;
@@ -189,18 +227,15 @@ void DraftDxfRead::AddGraphics() const
std::string k = i->first;
std::vector v = i->second;
if(k.substr(0, 6) != "BLOCKS") {
- std::cout << "joining:" << k << " size " << v.size() << std::endl;
for(std::vector::const_iterator j = v.begin(); j != v.end(); ++j) {
const TopoDS_Shape& sh = (*j)->_Shape;
if (!sh.IsNull())
builder.Add(comp, sh);
}
if (!comp.IsNull()) {
- std::cout << "valid shape" << std::endl;
Part::Feature *pcFeature = (Part::Feature *)document->addObject("Part::Feature", k.c_str());
pcFeature->Shape.setValue(comp);
}
- else std::cout << "invalid shape" << std::endl;
}
}
}
diff --git a/src/Mod/Draft/App/DraftDxf.h b/src/Mod/Draft/App/DraftDxf.h
index c9ab0f834e..c289d45e54 100644
--- a/src/Mod/Draft/App/DraftDxf.h
+++ b/src/Mod/Draft/App/DraftDxf.h
@@ -46,7 +46,8 @@ namespace DraftUtils
void AddGraphics() const;
// FreeCAD-specific functions
- void AddObject(Part::TopoShape *shape);
+ void AddObject(Part::TopoShape *shape); //Called by OnRead functions to add Part objects
+ const char* Deformat(const char* text); // Removes DXF formating from texts
protected:
App::Document *document;