コード例 #1
0
    def virtual_entities(self, non_uniform_scaling=False) -> Iterable[DXFGraphic]:
        """
        Yields "virtual" entities of a block reference. This method is meant to examine the block reference
        entities at the "exploded" location without really "exploding" the block reference.

        This entities are not stored in the entity database, have no handle and are not assigned to any layout.
        It is possible to convert this entities into regular drawing entities by adding the entities to the
        entities database and a layout of the same DXF document as the block reference::

            doc.entitydb.add(entity)
            msp = doc.modelspace()
            msp.add_entity(entity)

        .. warning::

            **Non uniform scaling** returns incorrect results for text entities (TEXT, MTEXT, ATTRIB) and
            some other entities like ELLIPSE, SHAPE, HATCH with arc or ellipse path segments and
            POLYLINE/LWPOLYLINE with arc segments. Non uniform scaling is getting better, but still not perfect!

        Args:
            non_uniform_scaling: enable non uniform scaling if ``True``, see warning

        .. versionadded:: 0.12
            experimental feature

        """
        if non_uniform_scaling is False and not self.has_uniform_scaling:
            return []

        return virtual_block_reference_entities(self)
コード例 #2
0
    def virtual_entities(self,
                         non_uniform_scaling=None,
                         skipped_entity_callback: Optional[
                             Callable[[DXFGraphic, str], None]] = None
                         ) -> Iterable[DXFGraphic]:
        """
        Yields "virtual" entities of a block reference. This method is meant to
        examine the block reference entities at the "exploded" location without
        really "exploding" the block reference. The`skipped_entity_callback()`
        will be called for all entities which are not processed, signature:
        :code:`skipped_entity_callback(entity: DXFEntity, reason: str)`,
        `entity` is the original (untransformed) DXF entity of the block
        definition, the `reason` string is an explanation why the entity was
        skipped.

        This entities are not stored in the entity database, have no handle and
        are not assigned to any layout. It is possible to convert this entities
        into regular drawing entities by adding the entities to the entities
        database and a layout of the same DXF document as the block reference::

            doc.entitydb.add(entity)
            msp = doc.modelspace()
            msp.add_entity(entity)

        This method does not resolve the MINSERT attributes, only the
        sub-entities of the base INSERT will be returned. To resolve MINSERT
        entities check if multi insert processing is required, that's the case
        if property :attr:`Insert.mcount` > 1, use the :meth:`Insert.multi_insert`
        method to resolve the MINSERT entity into single INSERT entities.

        .. warning::

            **Non uniform scaling** may return incorrect results for text
            entities (TEXT, MTEXT, ATTRIB) and maybe some other entities.

        Args:
            skipped_entity_callback: called whenever the transformation of an
                entity is not supported and so was skipped

        .. versionchanged:: 0.13
            deprecated `non_uniform_scaling` argument

        """
        if non_uniform_scaling is not None:
            warnings.warn(
                'Insert.virtual_entities() argument `non_uniform_scaling` is'
                ' deprecated (removed in v0.15).',
                DeprecationWarning
            )
        return virtual_block_reference_entities(
            self, skipped_entity_callback=skipped_entity_callback)
コード例 #3
0
    def virtual_entities(
        self,
        non_uniform_scaling=None,
        skipped_entity_callback: Optional[Callable[[DXFGraphic, str],
                                                   None]] = None
    ) -> Iterable[DXFGraphic]:
        """
        Yields "virtual" entities of a block reference. This method is meant to examine the block reference
        entities at the "exploded" location without really "exploding" the block reference. The
        `skipped_entity_callback()` will be called for all entities which are not processed, signature:
        :code:`skipped_entity_callback(entity: DXFEntity, reason: str)`, `entity` is the original (untransformed)
        DXF entity of the block definition, the `reason` string is an explanation why the entity was skipped.

        This entities are not stored in the entity database, have no handle and are not assigned to any layout.
        It is possible to convert this entities into regular drawing entities by adding the entities to the
        entities database and a layout of the same DXF document as the block reference::

            doc.entitydb.add(entity)
            msp = doc.modelspace()
            msp.add_entity(entity)

        .. warning::

            **Non uniform scaling** returns incorrect results for text entities (TEXT, MTEXT, ATTRIB) and
            some other entities like HATCH with arc or ellipse path segments.

        Args:
            skipped_entity_callback: called whenever the transformation of an entity is not supported and so was skipped

        .. versionadded:: 0.12
            experimental feature

        .. versionchanged:: 0.13
            deprecated `non_uniform_scaling` argument

        """
        if non_uniform_scaling is not None:
            warnings.warn(
                'Insert.virtual_entities() argument `non_uniform_scaling` is deprecated (removed in v0.15).',
                DeprecationWarning)

        return virtual_block_reference_entities(
            self, skipped_entity_callback=skipped_entity_callback)
コード例 #4
0
ファイル: insert.py プロジェクト: vshu3000/ezdxf
    def virtual_entities(
        self,
        non_uniform_scaling=False,
        skipped_entity_callback: Optional[Callable[[DXFGraphic, str],
                                                   None]] = None
    ) -> Iterable[DXFGraphic]:
        """
        Yields "virtual" entities of a block reference. This method is meant to examine the block reference
        entities at the "exploded" location without really "exploding" the block reference. The
        `skipped_entity_callback()` will be called for all entities which are not processed, signature:
        :code:`skipped_entity_callback(entity: DXFEntity, reason: str)`, `entity` is the original (untransformed)
        DXF entity of the block definition, the `reason` string is an explanation why the entity was skipped.

        This entities are not stored in the entity database, have no handle and are not assigned to any layout.
        It is possible to convert this entities into regular drawing entities by adding the entities to the
        entities database and a layout of the same DXF document as the block reference::

            doc.entitydb.add(entity)
            msp = doc.modelspace()
            msp.add_entity(entity)

        .. warning::

            **Non uniform scaling** returns incorrect results for text entities (TEXT, MTEXT, ATTRIB) and
            some other entities like ELLIPSE, SHAPE, HATCH with arc or ellipse path segments and
            POLYLINE/LWPOLYLINE with arc segments. Non uniform scaling is getting better, but still not perfect!

        Args:
            non_uniform_scaling: enable non uniform scaling if ``True``, see warning
            skipped_entity_callback: called whenever the transformation of an entity is not supported and so was skipped

        .. versionadded:: 0.12
            experimental feature

        """
        if non_uniform_scaling is False and not self.has_uniform_scaling:
            return []

        return virtual_block_reference_entities(
            self, skipped_entity_callback=skipped_entity_callback)
コード例 #5
0
def test_transparency_of_virtual_entities_from_insert(doc):
    msp = doc.modelspace()
    insert = msp.add_blockref("BLK1", (0, 0))
    line = list(explode.virtual_block_reference_entities(insert))[0]
    assert line.transparency == 0.0
    assert line.dxf.hasattr("transparency") is False
コード例 #6
0
def test_virtual_entities_from_insert(doc):
    msp = doc.modelspace()
    insert = msp.add_blockref("BLK1", (0, 0))
    result = list(explode.virtual_block_reference_entities(insert))
    assert len(result) == 1