class Linetype(DXFEntity): __slots__ = () TEMPLATE = ExtendedTags.from_text(_LTYPETEMPLATE) DXFATTRIBS = DXFAttributes( DefSubclass( None, { 'handle': DXFAttr(5), 'name': DXFAttr(2), 'description': DXFAttr(3), 'length': DXFAttr(40), 'items': DXFAttr(73), })) @classmethod def new(cls, handle: str, dxfattribs: dict = None, dxffactory: 'DXFFactoryType' = None) -> DXFEntity: if dxfattribs is not None: pattern = dxfattribs.pop('pattern', [0.0]) length = dxfattribs.pop('length', 0.) else: pattern = [0.0] length = 0. entity = super(Linetype, cls).new(handle, dxfattribs, dxffactory) entity._setup_pattern(pattern, length) return entity def _setup_pattern(self, pattern: Sequence[float], length: float) -> None: # length parameter is required for complex line types # pattern: [2.0, 1.25, -0.25, 0.25, -0.25] - 1. element is total pattern length # pattern elements: >0 line, <0 gap, =0 point self.tags.noclass.append(DXFTag(73, len(pattern) - 1)) self.tags.noclass.append(DXFTag(40, float(pattern[0]))) self.tags.noclass.extend((DXFTag(49, float(p)) for p in pattern[1:]))
class PointAccessor(DXFEntity): DXFATTRIBS = DXFAttributes( DefSubclass( None, { 'point': DXFAttr(10, xtype='Point3D'), 'flat': DXFAttr(11, xtype='Point2D'), 'xp': DXFAttr(12, xtype='Point3D'), 'flex': DXFAttr(13, xtype='Point2D/3D'), 'flags': DXFAttr(70), 'counter': DXFAttr(xtype='Callback', getter='get_counter', setter='set_counter'), 'just_AC1015': DXFAttr(71, default=777, dxfversion='AC1015'), })) def __init__(self, tags): super(PointAccessor, self).__init__(tags, drawing=DWG) self._counter = 0 def get_counter(self): return self._counter def set_counter(self, value): self._counter = value
class Layer(DXFEntity): __slots__ = () TEMPLATE = ExtendedTags.from_text(_LAYERTEMPLATE) DXFATTRIBS = DXFAttributes( DefSubclass( None, { 'handle': DXFAttr(5), 'name': DXFAttr(2), 'flags': DXFAttr(70), 'color': DXFAttr(62), # dxf color index, if < 0 layer is off 'linetype': DXFAttr(6), })) FROZEN = 0b00000001 THAW = 0b11111110 LOCK = 0b00000100 UNLOCK = 0b11111011 def post_new_hook(self) -> None: if not is_valid_layer_name(self.dxf.name): raise DXFInvalidLayerName("Invalid layer name '{}'".format( self.dxf.name)) def is_frozen(self) -> bool: return self.dxf.flags & Layer.FROZEN > 0 def freeze(self) -> None: self.dxf.flags = self.dxf.flags | Layer.FROZEN def thaw(self) -> None: self.dxf.flags = self.dxf.flags & Layer.THAW def is_locked(self) -> bool: return self.dxf.flags & Layer.LOCK > 0 def lock(self) -> None: self.dxf.flags = self.dxf.flags | Layer.LOCK def unlock(self) -> None: self.dxf.flags = self.dxf.flags & Layer.UNLOCK def is_off(self) -> bool: return self.dxf.color < 0 def is_on(self) -> bool: return not self.is_off() def on(self) -> None: self.dxf.color = abs(self.dxf.color) def off(self) -> None: self.dxf.color = -abs(self.dxf.color) def get_color(self) -> int: return abs(self.dxf.color) def set_color(self, color: int) -> None: color = abs(color) if self.is_on() else -abs(color) self.dxf.color = color
class SeqEnd(GraphicEntity): __slots__ = () TEMPLATE = ExtendedTags.from_text(" 0\nSEQEND\n 5\n0\n") DXFATTRIBS = DXFAttributes( DefSubclass(None, { 'handle': DXFAttr(5), 'paperspace': DXFAttr(67, default=0), }))
def subclass(): return DefSubclass('AcDbTest', { 'test1': DXFAttr(1), 'test2': DXFAttr(2), 'test3': DXFAttr(1), # duplicate group code 'callback': DXFAttr(3, xtype=XType.callback), 'none_callback': DXFAttr(3), # duplicate group code })
class AppID(DXFEntity): __slots__ = () TEMPLATE = ExtendedTags.from_text(_APPIDTEMPLATE) DXFATTRIBS = DXFAttributes( DefSubclass(None, { 'handle': DXFAttr(5), 'name': DXFAttr(2), 'flags': DXFAttr(70), }))
class ImageDefReactor(DXFEntity): TEMPLATE = ExtendedTags.from_text(_IMAGE_DEF_REACTOR_TPL) CLASS = ExtendedTags.from_text(_IMAGE_DEF_REACTOR_CLS) DXFATTRIBS = DXFAttributes( none_subclass, DefSubclass( 'AcDbRasterImageDef', { 'image': DXFAttr(330), # handle to image }))
def subclass(): return DefSubclass( "AcDbTest", { "test1": DXFAttr(1), "test2": DXFAttr(2), "test3": DXFAttr(1), # duplicate group code "callback": DXFAttr(3, xtype=XType.callback), "none_callback": DXFAttr(3), # duplicate group code }, )
class RasterVariables(DXFEntity): TEMPLATE = ExtendedTags.from_text(_RASTER_VARIABLES_TPL) CLASS = ExtendedTags.from_text(_RASTER_VARIABLES_CLS) DXFATTRIBS = DXFAttributes( none_subclass, DefSubclass('AcDbRasterVariables', { 'version': DXFAttr(90, default=0), 'frame': DXFAttr(70, default=0), # 0 = no frame; 1= show frame 'quality': DXFAttr(71, default=1), # 0=draft; 1=high 'units': DXFAttr(72, default=3), # 0 = None; 1 = mm; 2 = cm 3 = m; 4 = km; 5 = in 6 = ft; 7 = yd; 8 = mi }), )
class DXFClass(DXFEntity): __slots__ = () DXFATTRIBS = DXFAttributes( DefSubclass( None, { 'name': DXFAttr(1), 'cpp_class_name': DXFAttr(2), 'app_name': DXFAttr(3), 'flags': DXFAttr(90), 'instance_count': DXFAttr(91, dxfversion='AC1018'), 'was_a_proxy': DXFAttr(280), 'is_an_entity': DXFAttr(281), }), )
class AttributeChecker(DXFEntity): TEMPLATE = XTEMPLATE DXFATTRIBS = DXFAttributes( DefSubclass(None, { 'handle': DXFAttr(5), 'block_record': DXFAttr(330), }), DefSubclass( 'AcDbEntity', { 'paperspace': DXFAttr(67, default=0), 'layer': DXFAttr(8, default='0'), 'linetype': DXFAttr(6, default='BYLAYER'), 'ltscale': DXFAttr(48, default=1.0), 'invisible': DXFAttr(60, default=0), 'color': DXFAttr(62, default=256), }), DefSubclass( 'AcDbLine', { 'start': DXFAttr(10, 'Point2D/3D'), 'end': DXFAttr(11, 'Point2D/3D'), 'thickness': DXFAttr(39), 'extrusion': DXFAttr(210, 'Point3D'), }))
class PointAccessor(DXFEntity): DXFATTRIBS = DXFAttributes( DefSubclass( None, { 'point': DXFAttr(10, 'Point3D'), 'flat': DXFAttr(11, 'Point2D'), 'xp': DXFAttr(12, 'Point3D'), 'flex': DXFAttr(13, 'Point2D/3D'), 'flags': DXFAttr(70), 'just_AC1015': DXFAttr(71, default=777, dxfversion='AC1015'), })) def __init__(self, tags): super(PointAccessor, self).__init__(tags, drawing=DWG)
class Style(DXFEntity): __slots__ = () TEMPLATE = ExtendedTags.from_text(_STYLETEMPLATE) DXFATTRIBS = DXFAttributes( DefSubclass( None, { 'handle': DXFAttr(5), 'name': DXFAttr(2), 'flags': DXFAttr(70), 'height': DXFAttr(40), # fixed height, 0 if not fixed 'width': DXFAttr(41), # width factor 'oblique': DXFAttr(50), # oblique angle in degree, 0 = vertical 'generation_flags': DXFAttr(71), # 2 = backward, 4 = mirrored in Y 'last_height': DXFAttr(42), # last height used 'font': DXFAttr(3), # primary font file name 'bigfont': DXFAttr(4), # big font name, blank if none }))
class View(DXFEntity): __slots__ = () TEMPLATE = ExtendedTags.from_text(_VIEWTEMPLATE) DXFATTRIBS = DXFAttributes( DefSubclass( None, { 'handle': DXFAttr(5), 'name': DXFAttr(2), 'flags': DXFAttr(70), 'height': DXFAttr(40), 'width': DXFAttr(41), 'center_point': DXFAttr(10, xtype=XType.point2d), 'direction_point': DXFAttr(11, xtype=XType.point3d), 'target_point': DXFAttr(12, xtype=XType.point3d), 'lens_length': DXFAttr(42), 'front_clipping': DXFAttr(43), 'back_clipping': DXFAttr(44), 'view_twist': DXFAttr(50), 'view_mode': DXFAttr(71), }))
class UCS(DXFEntity): __slots__ = () TEMPLATE = ExtendedTags.from_text(_UCSTEMPLATE) DXFATTRIBS = DXFAttributes( DefSubclass( None, { 'handle': DXFAttr(5), 'name': DXFAttr(2), 'flags': DXFAttr(70), 'origin': DXFAttr(10, xtype=XType.point3d), 'xaxis': DXFAttr(11, xtype=XType.point3d), 'yaxis': DXFAttr(12, xtype=XType.point3d), })) def ucs(self) -> UserCoordinateSystem: return UserCoordinateSystem( origin=self.get_dxf_attrib('origin', default=(0, 0, 0)), ux=self.get_dxf_attrib('xaxis', default=(1, 0, 0)), uy=self.get_dxf_attrib('yaxis', default=(0, 1, 0)), )
def test_load_doublettes(): from ezdxf.lldxf.attributes import DefSubclass, DXFAttr from ezdxf.lldxf.tags import Tags, DXFTag subclass = DefSubclass('AcDbTest', { 'test1': DXFAttr(1), 'test2': DXFAttr(2), 'test3': DXFAttr(1), # same group code for different attribute }) class TestEntity(DXFEntity): DXFATTRIBS = DXFAttributes(subclass) data = Tags([ DXFTag(1, '1'), DXFTag(2, '2'), DXFTag(1, '3'), ]) ns = DXFNamespace(entity=TestEntity()) SubclassProcessor.load_tags_into_namespace(ns, data, subclass) assert ns.test1 == '1' assert ns.test2 == '2' assert ns.test3 == '3'
def make_attribs(additional=None): dxfattribs = { 'handle': DXFAttr(5), 'layer': DXFAttr( 8, default='0' ), # layer name as string, mandatory according to the DXF Reference 'linetype': DXFAttr(6, default='BYLAYER' ), # linetype as string, special names BYLAYER/BYBLOCK 'color': DXFAttr(62, default=256), # dxf color index, 0 .. BYBLOCK, 256 .. BYLAYER 'thickness': DXFAttr(39, default=0), # thickness of 2D elements 'paperspace': DXFAttr(67, default=0), # 0=modelspace; 1=paperspace 'extrusion': DXFAttr(210, xtype='Point3D', default=(0.0, 0.0, 1.0)), # Z-axis of OCS (Object-Coordinate-System) } if additional is not None: dxfattribs.update(additional) return DXFAttributes(DefSubclass(None, dxfattribs))
class VPort(DXFEntity): __slots__ = () TEMPLATE = ExtendedTags.from_text(_VPORTTEMPLATE) DXFATTRIBS = DXFAttributes( DefSubclass( None, { 'handle': DXFAttr(5), 'name': DXFAttr(2), 'flags': DXFAttr(70), 'lower_left': DXFAttr(10, xtype=XType.point2d), 'upper_right': DXFAttr(11, xtype=XType.point2d), 'center_point': DXFAttr(12, xtype=XType.point2d), 'snap_base': DXFAttr(13, xtype=XType.point2d), 'snap_spacing': DXFAttr(14, xtype=XType.point2d), 'grid_spacing': DXFAttr(15, xtype=XType.point2d), 'direction_point': DXFAttr(16, xtype=XType.point3d), 'target_point': DXFAttr(17, xtype=XType.point3d), 'height': DXFAttr(40), 'aspect_ratio': DXFAttr(41), 'lens_length': DXFAttr(42), 'front_clipping': DXFAttr(43), 'back_clipping': DXFAttr(44), 'snap_rotation': DXFAttr(50), 'view_twist': DXFAttr(51), 'status': DXFAttr(68), # group code 69: 'id' is never saved in DXF, and DXF R13 and later has no group code 69 'view_mode': DXFAttr(71), 'circle_zoom': DXFAttr(72), 'fast_zoom': DXFAttr(73), 'ucs_icon': DXFAttr(74), 'snap_on': DXFAttr(75), 'grid_on': DXFAttr(76), 'snap_style': DXFAttr(77), 'snap_isopair': DXFAttr(78), }))
from .factory import register_entity if TYPE_CHECKING: from ezdxf.eztypes import TagWriter, DXFNamespace __all__ = ['Line'] acdb_line = DefSubclass( 'AcDbLine', { 'start': DXFAttr(10, xtype=XType.point3d, default=NULLVEC), 'end': DXFAttr(11, xtype=XType.point3d, default=NULLVEC), 'thickness': DXFAttr(39, default=0, optional=True), 'extrusion': DXFAttr( 210, xtype=XType.point3d, default=Z_AXIS, optional=True, validator=validator.is_not_null_vector, fixer=RETURN_DEFAULT, ), }) @register_entity class Line(DXFGraphic): """ The LINE entity represents a 3D line from `start` to `end` """ DXFTYPE = 'LINE' DXFATTRIBS = DXFAttributes(base_class, acdb_entity, acdb_line)
__all__ = ["Circle"] acdb_circle = DefSubclass( "AcDbCircle", { "center": DXFAttr(10, xtype=XType.point3d, default=NULLVEC), # AutCAD/BricsCAD: Radius is <= 0 is valid "radius": DXFAttr(40, default=1), # Elevation is a legacy feature from R11 and prior, do not use this # attribute, store the entity elevation in the z-axis of the vertices. # ezdxf does not export the elevation attribute! "elevation": DXFAttr(38, default=0, optional=True), "thickness": DXFAttr(39, default=0, optional=True), "extrusion": DXFAttr( 210, xtype=XType.point3d, default=Z_AXIS, optional=True, validator=validator.is_not_null_vector, fixer=RETURN_DEFAULT, ), }, ) acdb_circle_group_codes = group_code_mapping(acdb_circle) merged_circle_group_codes = merge_group_code_mappings(
acdb_viewport = DefSubclass( 'AcDbViewport', { # Center point (in WCS) 'center': DXFAttr(10, xtype=XType.point3d, default=NULLVEC), # Width in paper space units: 'width': DXFAttr(40, default=1), # Height in paper space units: 'height': DXFAttr(41, default=1), # Viewport status field: # -1 = On, but is fully off screen, or is one of the viewports that is not # active because the $MAXACTVP count is currently being exceeded. # 0 = Off # <positive value> = On and active. The value indicates the order of # stacking for the viewports, where 1 is the active viewport, 2 is the next, # and so on: 'status': DXFAttr(68, default=0), 'id': DXFAttr(69, default=2), # View center point (in DCS): 'view_center_point': DXFAttr(12, xtype=XType.point2d, default=NULLVEC), 'snap_base_point': DXFAttr(13, xtype=XType.point2d, default=NULLVEC), 'snap_spacing': DXFAttr(14, xtype=XType.point2d, default=Vector(10, 10)), 'grid_spacing': DXFAttr(15, xtype=XType.point2d, default=Vector(10, 10)), # View direction vector (WCS): 'view_direction_vector': DXFAttr(16, xtype=XType.point3d, default=NULLVEC), # View target point (in WCS): 'view_target_point': DXFAttr(17, xtype=XType.point3d, default=NULLVEC), 'perspective_lens_length': DXFAttr(42, default=50), 'front_clip_plane_z_value': DXFAttr(43, default=0), 'back_clip_plane_z_value': DXFAttr(44, default=0), # View height (in model space units): 'view_height': DXFAttr(45, default=1), 'snap_angle': DXFAttr(50, default=0), 'view_twist_angle': DXFAttr(51, default=0), 'circle_zoom': DXFAttr(72, default=100), # 331: Frozen layer object ID/handle (multiple entries may exist) (optional) # Viewport status bit-coded flags: # 1 (0x1) = Enables perspective mode # 2 (0x2) = Enables front clipping # 4 (0x4) = Enables back clipping # 8 (0x8) = Enables UCS follow # 16 (0x10) = Enables front clip not at eye # 32 (0x20) = Enables UCS icon visibility # 64 (0x40) = Enables UCS icon at origin # 128 (0x80) = Enables fast zoom # 256 (0x100) = Enables snap mode # 512 (0x200) = Enables grid mode # 1024 (0x400) = Enables isometric snap style # 2048 (0x800) = Enables hide plot mode # 4096 (0x1000) = kIsoPairTop. If set and kIsoPairRight is not set, then # isopair top is enabled. If both kIsoPairTop and kIsoPairRight are set, # then isopair left is enabled # 8192 (0x2000) = kIsoPairRight. If set and kIsoPairTop is not set, then # isopair right is enabled # 16384 (0x4000) = Enables viewport zoom locking # 32768 (0x8000) = Currently always enabled # 65536 (0x10000) = Enables non-rectangular clipping # 131072 (0x20000) = Turns the viewport off # 262144 (0x40000) = Enables the display of the grid beyond the drawing # limits # 524288 (0x80000) = Enable adaptive grid display # 1048576 (0x100000) = Enables subdivision of the grid below the set grid # spacing when the grid display is adaptive # 2097152 (0x200000) = Enables grid follows workplane switching 'flags': DXFAttr(90, default=0), 'clipping_boundary_handle': DXFAttr(340, default=0, optional=True), # Plot style sheet name assigned to this viewport 'plot_style_name': DXFAttr(1, default=''), # Render mode: # 0 = 2D Optimized (classic 2D) # 1 = Wireframe # 2 = Hidden line # 3 = Flat shaded # 4 = Gouraud shaded # 5 = Flat shaded with wireframe # 6 = Gouraud shaded with wireframe 'render_mode': DXFAttr( 281, default=0, validator=validator.is_in_integer_range(0, 7), fixer=RETURN_DEFAULT, ), 'ucs_per_viewport': DXFAttr( 71, default=0, validator=validator.is_integer_bool, fixer=RETURN_DEFAULT, ), 'ucs_icon': DXFAttr(74, default=0), 'ucs_origin': DXFAttr(110, xtype=XType.point3d, default=NULLVEC), 'ucs_x_axis': DXFAttr( 111, xtype=XType.point3d, default=X_AXIS, validator=validator.is_not_null_vector, fixer=RETURN_DEFAULT, ), 'ucs_y_axis': DXFAttr( 112, xtype=XType.point3d, default=Y_AXIS, validator=validator.is_not_null_vector, fixer=RETURN_DEFAULT, ), # Handle of AcDbUCSTableRecord if UCS is a named UCS. # If not present, then UCS is unnamed: 'ucs_handle': DXFAttr(345), # Handle of AcDbUCSTableRecord of base UCS if UCS is orthographic (79 code # is non-zero). If not present and 79 code is non-zero, then base UCS is # taken to be WORLD: 'ucs_base_handle': DXFAttr(346, optional=True), # UCS ortho type: # 0 = not orthographic # 1 = Top # 2 = Bottom # 3 = Front # 4 = Back # 5 = Left # 6 = Right 'ucs_ortho_type': DXFAttr( 79, default=0, validator=validator.is_in_integer_range(0, 7), fixer=RETURN_DEFAULT, ), 'elevation': DXFAttr(146, default=0), # Shade plot mode: # 0 = As Displayed # 1 = Wireframe # 2 = Hidden # 3 = Rendered 'shade_plot_mode': DXFAttr( 170, dxfversion='AC1018', validator=validator.is_in_integer_range(0, 4), fixer=RETURN_DEFAULT, ), # Frequency of major grid lines compared to minor grid lines 'grid_frequency': DXFAttr(61, dxfversion='AC1021'), 'background_handle': DXFAttr(332, dxfversion='AC1021'), 'shade_plot_handle': DXFAttr(333, dxfversion='AC1021'), 'visual_style_handle': DXFAttr(348, dxfversion='AC1021'), 'default_lighting_flag': DXFAttr(292, dxfversion='AC1021', default=1, optional=True), # Default lighting type: # 0 = One distant light # 1 = Two distant lights 'default_lighting_type': DXFAttr( 282, default=0, dxfversion='AC1021', validator=validator.is_integer_bool, fixer=RETURN_DEFAULT, ), 'view_brightness': DXFAttr(141, dxfversion='AC1021'), 'view_contrast': DXFAttr(142, dxfversion='AC1021'), # as AutoCAD Color Index 'ambient_light_color_1': DXFAttr( 63, dxfversion='AC1021', validator=validator.is_valid_aci_color, ), # as True Color: 'ambient_light_color_2': DXFAttr(421, dxfversion='AC1021'), # as True Color: 'ambient_light_color_3': DXFAttr(431, dxfversion='AC1021'), 'sun_handle': DXFAttr(361, dxfversion='AC1021'), 'ref_vp_object_1': DXFAttr(335, dxfversion='AC1021'), # unknown meaning, don't ask mozman 'ref_vp_object_2': DXFAttr(343, dxfversion='AC1021'), # unknown meaning, don't ask mozman 'ref_vp_object_3': DXFAttr(344, dxfversion='AC1021'), # unknown meaning, don't ask mozman 'ref_vp_object_4': DXFAttr(91, dxfversion='AC1021'), # unknown meaning, don't ask mozman })
acdb_ellipse = DefSubclass( 'AcDbEllipse', { 'center': DXFAttr(10, xtype=XType.point3d, default=NULLVEC), # Major axis vector from 'center': 'major_axis': DXFAttr( 11, xtype=XType.point3d, default=X_AXIS, validator=validator.is_not_null_vector, ), # The extrusion vector does not establish an OCS, it is just the normal # vector of the ellipse plane: 'extrusion': DXFAttr( 210, xtype=XType.point3d, default=Z_AXIS, optional=True, validator=validator.is_not_null_vector, fixer=RETURN_DEFAULT, ), # Ratio has to be in the range from 1e-6 to 1, but could be negative: 'ratio': DXFAttr( 40, default=MAX_RATIO, validator=is_valid_ratio, fixer=fix_ratio), # Start of ellipse, this value is 0.0 for a full ellipse: 'start_param': DXFAttr(41, default=0), # End of ellipse, this value is 2*pi for a full ellipse: 'end_param': DXFAttr(42, default=math.tau), })
acdb_tolerance = DefSubclass( "AcDbFcf", { "dimstyle": DXFAttr( 3, default="Standard", validator=validator.is_valid_table_name, ), # Insertion point (in WCS): "insert": DXFAttr(10, xtype=XType.point3d, default=NULLVEC), # String representing the visual representation of the tolerance: "content": DXFAttr(1, default=""), "extrusion": DXFAttr( 210, xtype=XType.point3d, default=Z_AXIS, optional=True, validator=validator.is_not_null_vector, fixer=RETURN_DEFAULT, ), # X-axis direction vector (in WCS): "x_axis_vector": DXFAttr( 11, xtype=XType.point3d, default=X_AXIS, validator=validator.is_not_null_vector, fixer=RETURN_DEFAULT, ), }, )
acdb_sun = DefSubclass( 'AcDbSun', { 'version': DXFAttr(90, default=1), 'status': DXFAttr( 290, default=1, validator=validator.is_integer_bool, fixer=RETURN_DEFAULT, ), 'color': DXFAttr( 63, default=7, validator=validator.is_valid_aci_color, fixer=RETURN_DEFAULT, ), 'true_color': DXFAttr(421, default=16777215), 'intensity': DXFAttr(40, default=1), 'shadows': DXFAttr( 291, default=1, validator=validator.is_integer_bool, fixer=RETURN_DEFAULT, ), 'julian_day': DXFAttr(91, default=2456922), # Time in seconds past midnight: 'time': DXFAttr(92, default=43200), 'daylight_savings_time': DXFAttr( 292, default=0, validator=validator.is_integer_bool, fixer=RETURN_DEFAULT, ), # Shadow type: # 0 = Ray traced shadows # 1 = Shadow maps 'shadow_type': DXFAttr( 70, default=0, validator=validator.is_integer_bool, fixer=RETURN_DEFAULT, ), 'shadow_map_size': DXFAttr(71, default=256), 'shadow_softness': DXFAttr(280, default=1), })
acdb_style = DefSubclass( 'AcDbTextStyleTableRecord', { 'name': DXFAttr( 2, default='Standard', validator=validator.is_valid_table_name, ), 'flags': DXFAttr(70, default=0), # Fixed height, 0 if not fixed 'height': DXFAttr( 40, default=0, validator=validator.is_greater_or_equal_zero, fixer=RETURN_DEFAULT, ), # Width factor: 'width': DXFAttr( 41, default=1, validator=validator.is_greater_zero, fixer=RETURN_DEFAULT, ), # Oblique angle in degree, 0 = vertical 'oblique': DXFAttr(50, default=0), # Generation flags: # 2 = backward # 4 = mirrored in Y 'generation_flags': DXFAttr(71, default=0), # Last height used: 'last_height': DXFAttr(42, default=2.5), # Primary font file name: 'font': DXFAttr(3, default='txt'), # Big font name, blank if none 'bigfont': DXFAttr(4, default=''), })
acdb_trace = DefSubclass( 'AcDbTrace', { # 1. corner Solid WCS; Trace OCS 'vtx0': DXFAttr(10, xtype=XType.point3d, default=NULLVEC), # 2. corner Solid WCS; Trace OCS 'vtx1': DXFAttr(11, xtype=XType.point3d, default=NULLVEC), # 3. corner Solid WCS; Trace OCS 'vtx2': DXFAttr(12, xtype=XType.point3d, default=NULLVEC), # 4. corner Solid WCS; Trace OCS: # If only three corners are entered to define the SOLID, then the fourth # corner coordinate is the same as the third. 'vtx3': DXFAttr(13, xtype=XType.point3d, default=NULLVEC), # Elevation is a legacy feature from R11 and prior, do not use this # attribute, store the entity elevation in the z-axis of the vertices. # ezdxf does not export the elevation attribute! 'elevation': DXFAttr(38, default=0, optional=True), # Thickness could be negative: 'thickness': DXFAttr(39, default=0, optional=True), 'extrusion': DXFAttr( 210, xtype=XType.point3d, default=Z_AXIS, optional=True, validator=validator.is_not_null_vector, fixer=RETURN_DEFAULT, ), })
class Solid3d(Body): __slots__ = () TEMPLATE = ExtendedTags.from_text(_3DSOLID_TPL) DXFATTRIBS = DXFAttributes( none_subclass, entity_subclass, modeler_geometry_subclass, DefSubclass('AcDb3dSolid', {'history': DXFAttr(350, default=0)}))
5 0 330 0 100 AcDbEntity 8 0 100 AcDbModelerGeometry 70 1 """ modeler_geometry_subclass = DefSubclass('AcDbModelerGeometry', { 'version': DXFAttr(70, default=1), }) def convert_tags_to_text_lines(line_tags): """ Args: line_tags: tags with code 1 or 3, tag with code 3 is the tail of previous line with more than 255 chars. Returns: yield strings """ line_tags = iter(line_tags) try: line = next(line_tags).value # raises StopIteration except StopIteration:
acdb_block_reference = DefSubclass( 'AcDbBlockReference', { 'attribs_follow': DXFAttr(66, default=0, optional=True), 'name': DXFAttr(2, validator=validator.is_valid_block_name), 'insert': DXFAttr(10, xtype=XType.any_point), 'xscale': DXFAttr( 41, default=1, optional=True, validator=validator.is_not_zero, fixer=RETURN_DEFAULT, ), 'yscale': DXFAttr( 42, default=1, optional=True, validator=validator.is_not_zero, fixer=RETURN_DEFAULT, ), 'zscale': DXFAttr( 43, default=1, optional=True, validator=validator.is_not_zero, fixer=RETURN_DEFAULT, ), 'rotation': DXFAttr(50, default=0, optional=True), 'column_count': DXFAttr( 70, default=1, optional=True, validator=validator.is_greater_zero, fixer=RETURN_DEFAULT, ), 'row_count': DXFAttr( 71, default=1, optional=True, validator=validator.is_greater_zero, fixer=RETURN_DEFAULT, ), 'column_spacing': DXFAttr(44, default=0, optional=True), 'row_spacing': DXFAttr(45, default=0, optional=True), 'extrusion': DXFAttr( 210, xtype=XType.point3d, default=Z_AXIS, optional=True, validator=validator.is_not_null_vector, fixer=RETURN_DEFAULT, ), })
acdb_text = DefSubclass('AcDbText', { # First alignment point (in OCS): 'insert': DXFAttr(10, xtype=XType.point3d, default=NULLVEC), # Text height 'height': DXFAttr( 40, default=2.5, validator=validator.is_greater_zero, fixer=RETURN_DEFAULT, ), # Text content as sting: 'text': DXFAttr( 1, default='', validator=validator.is_valid_one_line_text, fixer=validator.fix_one_line_text, ), # Text rotation in degrees (optional) 'rotation': DXFAttr(50, default=0, optional=True), # Oblique angle in degrees, vertical = 0 deg (optional) 'oblique': DXFAttr(51, default=0, optional=True), # Text style name (optional), given text style must have an entry in the # text-styles tables. 'style': DXFAttr(7, default='Standard', optional=True), # Relative X scale factor—width (optional) # This value is also adjusted when fit-type text is used 'width': DXFAttr( 41, default=1, optional=True, validator=validator.is_greater_zero, fixer=RETURN_DEFAULT, ), # Text generation flags (optional) # 2 = backward (mirror-x), # 4 = upside down (mirror-y) 'text_generation_flag': DXFAttr( 71, default=0, optional=True, validator=validator.is_one_of({0, 2, 4, 6}), fixer=RETURN_DEFAULT, ), # Horizontal text justification type (optional) horizontal justification # 0 = Left # 1 = Center # 2 = Right # 3 = Aligned (if vertical alignment = 0) # 4 = Middle (if vertical alignment = 0) # 5 = Fit (if vertical alignment = 0) # This value is meaningful only if the value of a 72 or 73 group is nonzero # (if the justification is anything other than baseline/left) 'halign': DXFAttr( 72, default=0, optional=True, validator=validator.is_in_integer_range(0, 6), fixer=RETURN_DEFAULT ), # Second alignment point (in OCS) (optional) 'align_point': DXFAttr(11, xtype=XType.point3d, optional=True), # Elevation is a legacy feature from R11 and prior, do not use this # attribute, store the entity elevation in the z-axis of the vertices. # ezdxf does not export the elevation attribute! 'elevation': DXFAttr(38, default=0, optional=True), # Thickness in extrusion direction, only supported for SHX font in # AutoCAD/BricsCAD (optional), can be negative 'thickness': DXFAttr(39, default=0, optional=True), # Extrusion direction (optional) 'extrusion': DXFAttr( 210, xtype=XType.point3d, default=Z_AXIS, optional=True, validator=validator.is_not_null_vector, fixer=RETURN_DEFAULT ), })