enjoping / DXFighter

A new DXF writer and reader in PHP which outputs AC1012 (R15) DXF files
BSD 3-Clause "New" or "Revised" License
42 stars 22 forks source link

How to insert and use blocks? #5

Closed ThomUK closed 4 years ago

ThomUK commented 4 years ago

Hi,

Do you have any examples of how to insert a block into a drawing? The classes seem to be written, but I can't use them to produce a valid dxf file.

I think: Tables section needs a block record. Blocks section needs the block, drawn block entities, and an endblk. Finally the Entities section needs an insert entity to define the position of the block.

Have you got this working, and could you share example code?

Many thanks!

ThomUK commented 4 years ago

I believe I have found the problem.
I needed to add a return to the addBlock() method, so that the newly created block is returned, allowing an entity to be added to it:

$dxf = new \DXFighter\DXFighter();

$circle = new Circle([10, 10, 0], 7.5);

$block = $dxf->addBlock('testBlock');
$block->addEntity($circle);

$insert = new Insert('testBlock');
$dxf->addEntity($insert);

I am going to keep making some other changes. I have never done a PR before, but would you be interested in a PR for this and other small improvements that I make?

enjoping commented 4 years ago

Hey Thom,

nice that you got it working and I would love to see a PR for this and other small contributions to the project. I've created this Project some years ago for a startup I've worked in but had nothing to do with DXF (besides to small requests here in the project). Therefore I love seeing people using and contributing to the library. So if you have adjustments feel free to open a PR. If you need help in any way feel free to contact me.

Greetings Joe

ThomUK commented 4 years ago

Hi Joe,

My adjustments are over several commits to my fork, starting from this one... f36d930e686d8fd243110636324dcfaf72a4c6d4

I'm new to this, and my formatter has made lots of other changes in the commit. Is there a good way to overcome that, or shall I make a new branch with the changes but without the changes to the code-style formatting? Sorry, I'm new to this.

Also, what is the best way to run the tests so that I can check / update / add to them?

Sorry for the Qs! Thom

(I'm closing because the original question is answered now)