-
circle_filled.zip from ezdxf import recover
from ezdxf.entities import Insert, Hatch
def process_hatch(entity: Hatch):
print('hatch: ', entity)
def process_insert(entity: Insert):
for e in entity.virtual_entities():
entity_type = e.dxftype()
if entity_type == 'INSERT':
process_insert(e)
elif entity_type == 'HATCH':
process_hatch(e)
else:
print('this is', e.dxftype())
dxf_doc, dxf_auditor= recover.readfile('test.dxf')
for e in dxf_doc.modelspace():
if e.dxf.invisible == 0:
entity_type = e.dxftype()
if entity_type == 'HATCH':
process_hatch(e)
elif entity_type == 'INSERT':
process_insert(e) EZDXF drawing |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
This is a really good question! This is not a circle, this is a closed LWPOLYLINE of two segments, where each segment is a semi-circle. To fill the circle the const-width of the LWPOLYLINE is set to outer radius of the filled circle. The LWPOLYLINE has only two points, the start point (S) is in the middle between center point and outer radius, this also applies to the end point (E) on the opposite side. Both points have a bulge value of 1.0 and the second segment is given by the This works also for the 2D POLYLINE entity and is used forever by AutoCAD to create filled dots for all kind of dimensions. |
Beta Was this translation helpful? Give feedback.
-
Code example to create such a filled circle by ezdxf: from pathlib import Path
import ezdxf
DIR = Path("~/Desktop/Outbox").expanduser()
doc = ezdxf.new()
msp = doc.modelspace()
# create a filled circle with radius 1.0 by a LWPOLYLINE:
# format "xyb" stands for x, y, bulge
polyline = msp.add_lwpolyline(
[(0.5, 0, 1.0), (-0.5, 0, 1.0)], format="xyb", close=True
)
polyline.dxf.const_width = 1.0
doc.saveas(DIR / "filled_circle.dxf") |
Beta Was this translation helpful? Give feedback.
-
So it's actually a arc segment with large thickness which makes a filled circle~~Well, I'm looking for HATCH similar area(hatch, solid, trace) to detect pillars(columns), this make it really tough. |
Beta Was this translation helpful? Give feedback.
This is a really good question!
This is not a circle, this is a closed LWPOLYLINE of two segments, where each segment is a semi-circle. To fill the circle the const-width of the LWPOLYLINE is set to outer radius of the filled circle.
The LWPOLYLINE has only two points, the start point (S) is in the middle between center point and outer radius, this also applies to the end point (E) on the opposite side. Both points have a bulge value of 1.0 and the second segment is given by the
closed
flag, which adds a closing segment from (E) to (S). The bulge value of the end point determines that the closing segment is a semi-circle.This works also for the 2D POLYLINE entity and is used forever by …