haplokuon / netDxf

.net dxf Reader-Writer
MIT License
996 stars 404 forks source link

How to split entities #271

Open subGm opened 3 years ago

subGm commented 3 years ago

Hello,

I'm wondering if with netDxf it is possible to split a 2d entity using another entity.

Something like the example below, where the red polyline is used to split the two circles:

entity_split

Thanks

haplokuon commented 3 years ago

No. The focus of this library is reading and writing DXF files not to solve geometric problems, but this is an easy problem. You just need to solve the intersection between a line segment and a circumference, there is plenty of information around the internet on how to do it. Next from the intersection point you can calculate the start and end angles of the arc, and since you already know the center and the radius you can create the new Arc entities.

subGm commented 3 years ago

Thanks for your reply. You are right, my example is an easy to solve, geometric problem. But it was only a simple example to clarify my question. Actually, my final goal is different. If I have a block (made of many different entities), I would like to put a rectangle on the block, and then setting a layer for the part of the block inside of the rectangle, and another layer for the outside.