dxf->writeHatch, but how ?
Moderator: andrew
dxf->writeHatch, but how ?
I havent found how to write a hatch into dxf
We have:
void DL_Dxf::writeHatch1 ( DL_WriterA & dw,
const DL_HatchData & data,
const DL_Attributes & attrib
)
where DL_HatchData (int hNumLoops, bool hSolid, double hScale, double hAngle, const string &hPattern)
First question: what shoud hPattern be and whats this hNumLoops all about?
Second question:
If I call :
void DL_Dxf::writeHatchLoop1 ( DL_WriterA & dw,
const DL_HatchLoopData & data
)
should I call the writeHatchEdge functions after this or before the writeHatchLoop?
Third question,why must I call writeHatch2 and how to use it ????
An example would be nice,since its impossible to decode it from the ribbonsofts class reference. Thank you!
We have:
void DL_Dxf::writeHatch1 ( DL_WriterA & dw,
const DL_HatchData & data,
const DL_Attributes & attrib
)
where DL_HatchData (int hNumLoops, bool hSolid, double hScale, double hAngle, const string &hPattern)
First question: what shoud hPattern be and whats this hNumLoops all about?
Second question:
If I call :
void DL_Dxf::writeHatchLoop1 ( DL_WriterA & dw,
const DL_HatchLoopData & data
)
should I call the writeHatchEdge functions after this or before the writeHatchLoop?
Third question,why must I call writeHatch2 and how to use it ????
An example would be nice,since its impossible to decode it from the ribbonsofts class reference. Thank you!
works, but not everything...
Thanks I managed to use it. I inserted a single loop with 3 edges(a triangle
) and succeded to make a triangle with hatch.
But pattern name is still a mistery.
I tried "EARTH", "ANSI31",... default pattern names,but nothing happens. However I can see that names in autocad when I click on my hatchobject, but it doesnt change the hatch style?!
I tried rotate and scale property too,they doesnt work either. Its always a 45 degree hatch.The solid property works fine.
![Smile :)](./images/smilies/icon_smile.gif)
But pattern name is still a mistery.
I tried "EARTH", "ANSI31",... default pattern names,but nothing happens. However I can see that names in autocad when I click on my hatchobject, but it doesnt change the hatch style?!
I tried rotate and scale property too,they doesnt work either. Its always a 45 degree hatch.The solid property works fine.
-
- Junior Member
- Posts: 11
- Joined: Tue Oct 08, 2013 11:55 pm
Re: dxf->writeHatch, but how ?
Im having some troubles in writing a solid arc hatch, i wrote a single hatch, with a single loop with a single edge all of em with the same attributes and it just doesnt work, any advice?
-
- Junior Member
- Posts: 11
- Joined: Tue Oct 08, 2013 11:55 pm
Re: dxf->writeHatch, but how ?
Anyone?
Re: dxf->writeHatch, but how ?
wolfhergang: Can you post your code or the exact example data?
I don't see how a hatch with one loop which contains one arc can form a closed, hatchable contour (unless the arc is in fact a full circle?).
I don't see how a hatch with one loop which contains one arc can form a closed, hatchable contour (unless the arc is in fact a full circle?).
-
- Junior Member
- Posts: 11
- Joined: Tue Oct 08, 2013 11:55 pm
Re: dxf->writeHatch, but how ?
My code is this:
DxfExporter exportador("testingWriting.dxf");
exportador.addEntity(new DxfCircle(0,0,0,100,DL_Attributes()));
DL_Attributes generalAttrib = DL_Attributes("0",2,16776960, -1, "BYLAYER");
exportador.addEntity((new DxfHatch(1,true,1,0,"SOLID",generalAttrib)));
exportador.addEntity(new DxfHatchLoop(1,generalAttrib));
exportador.addEntity(new DxfHatchEdge(0,0,100,0,6.75,true,generalAttrib));
if(exportador.writeToDxfFile()){
std::cout<<"File wrote correctly"<<std::endl;
}else{
std::cout<<"Error at writing"<<std::endl;
}
in my implementation you "add" the entities to a container then you write the container to the file.
the entity constructors are basically the same as the DL_Entity ones, but mine store the attributes, thats it.
the arc is supposed to be a full circle from 0 to 6.74 degrees but it doesnt render.
pd: sorry about my english, if something doesnt make sense let me know and ill try to explain myself.
DxfExporter exportador("testingWriting.dxf");
exportador.addEntity(new DxfCircle(0,0,0,100,DL_Attributes()));
DL_Attributes generalAttrib = DL_Attributes("0",2,16776960, -1, "BYLAYER");
exportador.addEntity((new DxfHatch(1,true,1,0,"SOLID",generalAttrib)));
exportador.addEntity(new DxfHatchLoop(1,generalAttrib));
exportador.addEntity(new DxfHatchEdge(0,0,100,0,6.75,true,generalAttrib));
if(exportador.writeToDxfFile()){
std::cout<<"File wrote correctly"<<std::endl;
}else{
std::cout<<"Error at writing"<<std::endl;
}
in my implementation you "add" the entities to a container then you write the container to the file.
the entity constructors are basically the same as the DL_Entity ones, but mine store the attributes, thats it.
the arc is supposed to be a full circle from 0 to 6.74 degrees but it doesnt render.
pd: sorry about my english, if something doesnt make sense let me know and ill try to explain myself.
-
- Junior Member
- Posts: 11
- Joined: Tue Oct 08, 2013 11:55 pm
Re: dxf->writeHatch, but how ?
Maybe im just confused about how im supposed to hatch things....
Re: dxf->writeHatch, but how ?
wolfhergang: this code does not look familiar to me. dxflib does not provide the classes named "DxfExporter", "DxfHatch", "DxfCircle", etc.
Here's a minimal but complete example that writes a DXF file with one hatch entity using dxflib 3.3.4:
Here's a minimal but complete example that writes a DXF file with one hatch entity using dxflib 3.3.4:
#include "dl_dxf.h" int main() { DL_Dxf dxf; DL_WriterA* dw = dxf.out("hatch.dxf", DL_Codes::AC1015); // section header: dxf.writeHeader(*dw); dw->sectionEnd(); // section tables: { dw->sectionTables(); // VPORT: dxf.writeVPort(*dw); // LTYPE: dw->tableLinetypes(1); dxf.writeLinetype(*dw, DL_LinetypeData("CONTINUOUS", "Continuous", 0, 0, 0.0)); dxf.writeLinetype(*dw, DL_LinetypeData("BYLAYER", "", 0, 0, 0.0)); dxf.writeLinetype(*dw, DL_LinetypeData("BYBLOCK", "", 0, 0, 0.0)); dw->tableEnd(); // LAYER: dw->tableLayers(1); dxf.writeLayer( *dw, DL_LayerData("0", 0), DL_Attributes("", 2, 0, 100, "CONTINUOUS") ); dw->tableEnd(); // STYLE: dw->tableStyle(1); DL_StyleData style("Standard", 0, 0.0, 1.0, 0.0, 0, 2.5, "txt", ""); style.bold = false; style.italic = false; dxf.writeStyle(*dw, style); dw->tableEnd(); // VIEW: dxf.writeView(*dw); // UCS: dxf.writeUcs(*dw); // APPID: dw->tableAppid(1); dxf.writeAppid(*dw, "ACAD"); dw->tableEnd(); // DIMSTYLE: dxf.writeDimStyle(*dw, 2.5, 0.625, 0.625, 0.625, 2.5); // BLOCK_RECORD: dxf.writeBlockRecord(*dw); dw->tableEnd(); dw->sectionEnd(); } // BLOCK: dw->sectionBlocks(); dxf.writeBlock(*dw, DL_BlockData("*Model_Space", 0, 0.0, 0.0, 0.0)); dxf.writeEndBlock(*dw, "*Model_Space"); dxf.writeBlock(*dw, DL_BlockData("*Paper_Space", 0, 0.0, 0.0, 0.0)); dxf.writeEndBlock(*dw, "*Paper_Space"); dxf.writeBlock(*dw, DL_BlockData("*Paper_Space0", 0, 0.0, 0.0, 0.0)); dxf.writeEndBlock(*dw, "*Paper_Space0"); dw->sectionEnd(); // ENTITIES: dw->sectionEntities(); DL_Attributes attributes("0", 2, 0, -1, "BYLAYER"); // start hatch with one loop: DL_HatchData data(1, false, 100.0, 0.0, "ESCHER", 0.0, 0.0); dxf.writeHatch1(*dw, data, attributes); // start loop: DL_HatchLoopData lData(1); dxf.writeHatchLoop1(*dw, lData); // write edge: DL_HatchEdgeData eData( 0.0, 0.0, 100.0, 0.0, M_PI*2, true ); dxf.writeHatchEdge(*dw, eData); // end loop: dxf.writeHatchLoop2(*dw, lData); // end hatch: dxf.writeHatch2(*dw, data, attributes); // end section ENTITIES: dw->sectionEnd(); dxf.writeObjects(*dw, "MY_OBJECTS"); dxf.writeObjectsEnd(*dw); dw->dxfEOF(); dw->close(); delete dw; return 0; }
-
- Junior Member
- Posts: 11
- Joined: Tue Oct 08, 2013 11:55 pm
Re: dxf->writeHatch, but how ?
My problem was that i was writing the hatch edge using degrees when im supposed to use radians.
DL_HatchEdgeData eData(0.0, 0.0, 100.0, 0.0, M_PI*2, true);
that single line solved my problem, than you very much Andrew.
DL_HatchEdgeData eData(0.0, 0.0, 100.0, 0.0, M_PI*2, true);
that single line solved my problem, than you very much Andrew.