def linedrawer(painter, scaler, boardlen, boardwid): # Right now this is disabled as I am just testing the Hatch drawing """for e in msp: print(e.dxftype())""" """for e in msp.query("CIRCLE"): ocs = e.ocs() radius = e.dxf.radius wcs_center = ocs.to_wcs(e.dxf.center) painter.drawEllipse(wcs_center[0] * scaler, wcs_center[1] * scaler, (radius / 2) * scaler, (radius / 2) * scaler)""" for e in msp.query('LINE'): if e.dxf.layer in render_layers: start = e.dxf.start end = e.dxf.end startx = start[0] * scaler starty = start[1] * scaler endx = end[0] * scaler endy = end[1] * scaler # Right now this is disabled as I am just testing the Hatch drawing # painter.drawLine(startx, starty, endx, endy) for hatch in msp: try: if hatch.dxftype() == "HATCH" and hatch.dxf.layer in render_layers: ocs = hatch.ocs() for p in hatch.paths: # For each path of a hatch if p.PATH_TYPE == 'EdgePath': path = Path.from_hatch_edge_path(p, ocs, 0) for counter, vector in enumerate(path.approximate()): if counter == 0: oldvector = vector sxs = vector[0] * scaler sys = (boardlen - vector[1]) * scaler sxe = oldvector[0] * scaler sye = (boardlen - oldvector[1]) * scaler oldvector = vector painter.drawLine(sxs, sys, sxe, sye) except: print("Error!") continue for region in msp: try: if region.dxftype( ) == "REGION" and region.dxf.layer in render_layers: print("REGION found") except: print("Error!") continue
def draw_hatch_entity(self, entity: DXFGraphic, properties: Properties) -> None: hatch = cast(Hatch, entity) ocs = hatch.ocs() # all OCS coordinates have the same z-axis stored as vector (0, 0, z), # default (0, 0, 0) elevation = entity.dxf.elevation.z for p in hatch.paths: if p.path_type_flags & const.BOUNDARY_PATH_EXTERNAL: # todo: implement support for inner paths if p.PATH_TYPE == 'EdgePath': path = Path.from_hatch_edge_path(p, ocs, elevation) else: path = Path.from_hatch_polyline_path(p, ocs, elevation) path.close() self.out.draw_path(path, properties)