def is_verify(self, state: bool) -> None: """ Verification is required on input of this attribute. (CAD application feature) """ self.dxf.flags = set_flag_state(self.dxf.flags, const.ATTRIB_VERIFY, state)
def set_flag_state(self, flag: int, state: bool = True, name: str = 'flags') -> None: """ Set binary coded `flag` of DXF attribute `name` to ``1`` (on) if `state` is ``True``, set `flag` to ``0`` (off) if `state` is ``False``. """ flags = self.dxf.get(name, 0) self.dxf.set(name, set_flag_state(flags, flag, state=state))
def load_xdata_into_dxf_namespace(self) -> None: try: tags = [v for c, v in self.xdata.get_xlist('ACAD', 'MVIEW')] except DXFValueError: return tags = tags[3:-2] dxf = self.dxf flags = 0 flags = set_flag_state(flags, const.VSF_FAST_ZOOM, bool(tags[11])) flags = set_flag_state(flags, const.VSF_SNAP_MODE, bool(tags[13])) flags = set_flag_state(flags, const.VSF_GRID_MODE, bool(tags[14])) flags = set_flag_state(flags, const.VSF_ISOMETRIC_SNAP_STYLE, bool(tags[15])) flags = set_flag_state(flags, const.VSF_HIDE_PLOT_MODE, bool(tags[24])) try: dxf.view_target_point = tags[0] dxf.view_direction_vector = tags[1] dxf.view_twist_angle = tags[2] dxf.view_height = tags[3] dxf.view_center_point = tags[4], tags[5] dxf.perspective_lens_length = tags[6] dxf.front_clip_plane_z_value = tags[7] dxf.back_clip_plane_z_value = tags[8] dxf.render_mode = tags[9] # view_mode == render_mode ? dxf.circle_zoom = tags[10] # fast zoom flag : tag[11] dxf.ucs_icon = tags[12] # snap mode flag = tags[13] # grid mode flag = tags[14] # isometric snap style = tags[15] # dxf.snap_isopair = tags[16] ??? dxf.snap_angle = tags[17] dxf.snap_base_point = tags[18], tags[19] dxf.snap_spacing = tags[20], tags[21] dxf.grid_spacing = tags[22], tags[23] # hide plot flag = tags[24] except IndexError: # internal exception raise DXFStructureError("Invalid viewport entity - missing data") dxf.flags = flags self._frozen_layers = tags[26:] self._frozen_layers_content_type = 'names' self.xdata.discard('ACAD')
def is_preset(self, state: bool) -> None: """ No prompt during insertion. (CAD application feature) """ self.dxf.flags = set_flag_state(self.dxf.flags, const.ATTRIB_IS_PRESET, state)
def is_invisible(self, state: bool) -> None: """ Attribute is invisible (does not appear). """ self.dxf.flags = set_flag_state(self.dxf.flags, const.ATTRIB_INVISIBLE, state)
def is_const(self, state: bool) -> None: """ This is a constant attribute. """ self.dxf.flags = set_flag_state(self.dxf.flags, const.ATTRIB_CONST, state)
def test_set_flag_state(): assert set_flag_state(0, 1, True) == 1 assert set_flag_state(0b10, 1, True) == 0b11 assert set_flag_state(0b111, 0b010, False) == 0b101 assert set_flag_state(0b010, 0b111, True) == 0b111 assert set_flag_state(0b1111, 0b1001, False) == 0b0110
def set_flag_state(self, flag: int, state: bool = True, name: str = 'flags') -> None: flags = self.get_dxf_attrib(name, 0) self.set_dxf_attrib(name, set_flag_state(flags, flag, state=state))
def set_flag_state(self, flag, state=True, name='flags'): flags = self.get_dxf_attrib(name, 0) self.set_dxf_attrib(name, set_flag_state(flags, flag, state=state))