Closed ThomUK closed 4 years ago
Hey Thom,
thank you for the nice words. I would love to see your contributions to the project.
At the moment the library is not returning the object itself after method execution which means method chaining will not work (even tough this seems to be a good idea to add to the code). So I guess the first part needs to look like this:
$polygon = new \DXFighter\lib\Polyline();
$polygon->setFlag(0,1);
$polygon->setColor(98);
$polygon->addPoint([0,0,0]);
$polygon->addPoint([150,0,0]);
$polygon->addPoint([100,100,0]);
$polygon->addPoint([0,50,0]);
Adding the layer entity by yourself is not necessary. Just setting it by string is enough, everything else is handled by the library. So the full code should look something like this:
$dxf = new \DXFighter\DXFighter();
$polygon = new \DXFighter\lib\Polyline();
$polygon->setFlag(0,1);
$polygon->setColor(98);
$polygon->addPoint([0,0,0]);
$polygon->addPoint([150,0,0]);
$polygon->addPoint([100,100,0]);
$polygon->addPoint([0,50,0]);
$polygon->setLayer('TEST_LAYER');
$dxf->addEntity($polygon);
$dxf->saveAs('dxfighter.dxf');
Could you check if that works in your program? I've added a test file using this code to the autodesk online viewer on https://autode.sk/2TGzCxR and the layer is correctly set.
I hope this helps.
Greetings Joe
Hi Joe,
Many thanks, you've moved me forwards. Your layer code works great, and the autodesk online viewer shows everything as it should be.
My confusion was caused by QCAD's free (community edition) software, which only opens R15(2000) dxf files. In that software the TEST_LAYER is missing, and the polygon appears on layer 0.
When I open the same file in QCAD's professional edition (3.24.3) the layer appears correctly. QCAD Pro logs that it is opening the file as an R13 version.
So problem solved for now. I really need to dig in and understand the file structure differences between R13 and R15 to further understand what was happening.
Many thanks again...! I've added a screenshot of QCAD's version info, just in case it's useful for anyone in the future.
Hi there. Thanks very much for this work - it think it's going to do what I need (and maybe I can learn to contribute to it later).
Please could you give me some help on the usage of layers? With the code below the DXF is created, the 'TEST_LAYER' exists, and the polygon exists, but is drawn on layer '0'. When I inspect the $polygon entity, I can see that the layer name is 'TEST_LAYER', but for some reason it's appearing on layer '0'. I suspect something to do with the dxf spec that I don't know about.
Could you give me any pointers in the right direction?
Thanks!