How to use the ezdxf.lldxf.const.DXFValueError function in ezdxf

To help you get started, we’ve selected a few ezdxf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mozman / ezdxf / src / ezdxf / math / bspline.py View on Github external
def __init__(self, control_points: Iterable['Vertex'],
                 order: int = 4,
                 knots: Iterable[float] = None,
                 weights: Iterable[float] = None):
        self.control_points: List[Vector] = Vector.list(control_points)
        self.order: int = order
        if order > self.count:
            raise DXFValueError(f'Invalid need more control points for order {order}')

        if knots is None:
            knots = open_uniform_knot_vector(self.count, self.order, normalize=True)
        else:
            knots = list(knots)
            required_knot_count = self.count + self.order
            if len(knots) != required_knot_count:
                raise ValueError(f"{required_knot_count} knot values required, got {len(knots)}.")
            if knots[0] != 0.0:
                knots = normalize_knots(knots)
        self.basis = Basis(knots, self.order, self.count, weights=weights)
github mozman / ezdxf / src / ezdxf / layouts / base.py View on Github external
def move_to_layout(self, entity: 'DXFGraphic', layout: 'BaseLayout') -> None:
        """
        Move entity to another layout.

        Args:
            entity: DXF entity to move
            layout: any layout (modelspace, paperspace, block) from **same** drawing

        """
        if entity.doc != layout.doc:
            raise DXFStructureError('Moving between different DXF drawings is not supported.')

        try:
            self.unlink_entity(entity)
        except ValueError:
            raise DXFValueError('Layout does not contain entity.')
        else:
            layout.add_entity(entity)
github mozman / ezdxf / ezdxf / legacy / polyline.py View on Github external
def delete_vertices(self, pos: int, count=1) -> None:
        db = self.entitydb
        prev_vertex = self.__getitem__(pos - 1).tags if pos > 0 else self.tags
        vertex = db[prev_vertex.link]
        while vertex.dxftype() == 'VERTEX':
            db.delete_handle(prev_vertex.link)  # remove from database
            prev_vertex.link = vertex.link  # remove vertex from list
            count -= 1
            if count == 0:
                return
            vertex = db[prev_vertex.link]
        raise DXFValueError("invalid count")
github mozman / ezdxf / ezdxf / lldxf / attributes.py View on Github external
def _set_extended_type(self, tags: Tags, value: Iterable) -> None:
        value = tuple(value)
        vlen = len(value)
        if vlen == 3:
            if self.xtype is XType.point2d:
                raise DXFValueError('2 axis required')
        elif vlen == 2:
            if self.xtype is XType.point3d:
                raise DXFValueError('3 axis required')
        else:
            raise DXFValueError('2 or 3 axis required')
        tags.set_first(DXFVertex(self.code, value))
github mozman / ezdxf / src / ezdxf / entities / dxfgroups.py View on Github external
def delete(self, group: Union[DXFGroup, str]) -> None:
        """ Delete `group`, `group` can be an object of type :class:`DXFGroup` or a group name as string. """
        if isinstance(group, str):  # delete group by name
            name = group
        elif group.dxftype() == 'GROUP':
            name = group.get_name()
        else:
            raise DXFTypeError(group.dxftype())

        if name in self:
            super().delete(name)
        else:
            raise DXFValueError("GROUP not in group table registered.")
github mozman / ezdxf / ezdxf / lldxf / attributes.py View on Github external
def _set_extended_type(self, tags: Tags, value: Iterable) -> None:
        value = tuple(value)
        vlen = len(value)
        if vlen == 3:
            if self.xtype is XType.point2d:
                raise DXFValueError('2 axis required')
        elif vlen == 2:
            if self.xtype is XType.point3d:
                raise DXFValueError('3 axis required')
        else:
            raise DXFValueError('2 or 3 axis required')
        tags.set_first(DXFVertex(self.code, value))
github mozman / ezdxf / ezdxf / lldxf / extendedtags.py View on Github external
def get_app_data(self, appid: str) -> Tags:
        """
        Get AppData including first and last marker tag.

        """
        for appdata in self.appdata:
            if appdata[0].value == appid:
                return appdata
        raise DXFValueError("Application defined group '%s' does not exist." % appid)
github mozman / ezdxf / src / ezdxf / drawing.py View on Github external
def delete_layout(self, name: str) -> None:
        """
        Delete paper space layout `name` and all entities owned by this layout. Available only for DXF R2000 or later,
        DXF R12 supports only one paperspace and it can't be deleted.

        """
        if name not in self.layouts:
            raise DXFValueError(f"Layout '{name}' does not exist.")
        else:
            self.layouts.delete(name)
github mozman / ezdxf / src / ezdxf / entities / hatch.py View on Github external
def set_seed_points(self, points: Sequence[Tuple[float, float]]) -> None:
        """
        Set seed points, `points` is a list of ``(x, y)`` tuples, I don't know why there can be more than one
        seed point. All points in :ref:`OCS` (:attr:`Hatch.dxf.elevation` is the Z value)
        """
        if len(points) < 1:
            raise const.DXFValueError(
                "Param points should be a collection of 2D points and requires at least one point.")
        self.seeds = list(points)
        self.dxf.n_seed_points = len(self.seeds)