Method AddFromDocument
- Namespace
- VectorDraw.Professional.vdCollections
- Assembly
- VectorDraw.Professional.dll
AddFromDocument(string, vdDocument, bool)
Creates a vdBlock object taking all model entities from a vdDocument.
public vdBlock AddFromDocument(string BlockName, vdDocument document, bool redefine)
Parameters
BlockNamestringThe name of the created block.
documentvdDocumentThe source vdDocument from which all model entities will be taken.
redefineboolIf
true, an existing block with the same name in the current document will be redefined (replaced). Iffalse, an existing block will be returned and left intact.
Returns
Remarks
This overload delegates to AddFromDocument(string, vdDocument, MergeTablesFlags),
mapping redefine to Redefine when true,
or to KeepExisting when false.
AddFromDocument(string, vdDocument, MergeTablesFlags)
Creates a vdBlock in this collection using all model entities from a source vdDocument.
public vdBlock AddFromDocument(string BlockName, vdDocument document, vdDocument.MergeTablesFlags mergeflags)
Parameters
BlockNamestringThe name to assign to the created block. If an empty string is provided, a new unnamed block is created.
documentvdDocumentThe source vdDocument whose model entities will be used to populate the new block.
mergeflagsvdDocument.MergeTablesFlagsA vdDocument.MergeTablesFlags value that controls how tables (layers, styles, blocks, etc.) with the same name are imported from
documentinto this document. For example, KeepExisting will keep existing tables in the target document and skip replacing them.
Returns
- vdBlock
The vdBlock object that was created or found in this collection. If a block with the same name already exists in this collection and
mergeflagsis KeepExisting, the existing block is un-deleted and returned. Otherwise a newly created/merged block is returned and its Entities collection will contain the transformed entities from the source document's model.
Remarks
- This method merges necessary tables from the source document into the destination document.
- If the source document contains a block with the same name that is referenced by its model entities, the source block may be renamed to avoid name conflicts; in that case a generic error is raised via RaiseGenericError(string, string).
- The method will use undo groups on both documents: it begins an undo group on the destination document and enables/stores an undo group on the source document while the import is performed. The source document's undo state is restored before returning.
- If the resulting block is not an XREF (see IsXref), the method copies and transforms all model entities (taking into account the source document's InsUnits and BasePoint) into the new block.
- Progress is reported to the destination document via MeterProgress callbacks during the creation and finishing phases.
- The method may call VectorDraw.Professional.vdCollections.ResolveReferenceObjects to resolve object references during import.
- Any errors encountered during the merge/import will be surfaced through RaiseGenericError(string, string) or via thrown exceptions.