Method AddFromStreamEx
- Namespace
- VectorDraw.Professional.vdCollections
- Assembly
- VectorDraw.Professional.dll
AddFromStreamEx(string, MemoryStream, bool, MergeTablesFlags)
Creates a block from an in-memory stream containing a serialized VectorDraw document and imports it into the current document according to the specified merge flags.
public vdBlock AddFromStreamEx(string BlockName, MemoryStream stream, bool iscompressed, vdDocument.MergeTablesFlags mergeflags)
Parameters
BlockNamestringBase name to assign to the created block. The method appends a newly created handle from the current document to this base name to guarantee uniqueness for the temporary block name used during import.
streamMemoryStreamA MemoryStream that contains the source document data (vdml/vdcl). If the stream is
nullthe method returnsnull.iscompressedboolIf
true, the stream is treated as compressed(vdcl) when loading the temporary document.mergeflagsvdDocument.MergeTablesFlagsA vdDocument.MergeTablesFlags value that controls how tables (layers, blocks, styles, etc.) from the source document are merged into the current document.
Returns
- vdBlock
The created vdBlock imported from the stream, or
nullif the stream could not be loaded or the import failed.
Remarks
Implementation notes:
- The method creates a temporary vdDocument, forwards its progress events to the owning document while loading, and then delegates merging/importing to AddFromDocument(string, vdDocument, MergeTablesFlags).
- Progress event handlers are unsubscribed and the temporary document is disposed before the method returns.
- If loading the temporary document fails, the temporary document is disposed and the method returns
null. - Any exceptions raised by AddFromDocument(string, vdDocument, MergeTablesFlags) will propagate
to the caller; load failures are reported by returning
null.
- See Also
AddFromStreamEx(string, MemoryStream, string, MergeTablesFlags)
Creates a vdBlock by loading a VectorDraw document from an in-memory stream and importing its model into the current document using the specified merge behavior.
public vdBlock AddFromStreamEx(string BlockName, MemoryStream stream, string fileTypeExtension, vdDocument.MergeTablesFlags mergeflags)
Parameters
BlockNamestringThe base name to assign to the created block in the destination document. This name is passed as-is to AddFromDocument(string, vdDocument, MergeTablesFlags) when performing the import.
streamMemoryStreamA MemoryStream that contains the source document data ( ".vdml",".vdcl",".vds",".vdf",".dxf",".dwg",".dgn",".pdf",".ifc"). If
nullthe method returnsnull.fileTypeExtensionstringThe file type extension to use when loading the stream (for example, ".vdml",".vdcl",".vds",".vdf",".dxf",".dwg",".dgn",".pdf",".ifc"). This value is forwarded to LoadFromStream(Stream, string) when loading the temporary document.
mergeflagsvdDocument.MergeTablesFlagsA vdDocument.MergeTablesFlags value that controls how tables (layers, blocks, styles, etc.) from the source document are merged into the current document. See vdDocument.MergeTablesFlags for options such as
KeepExistingandRedefine.
Returns
- vdBlock
The vdBlock that was imported into the current document, or
nullif the owning Document isnull, the stream could not be loaded, or the import failed.
Remarks
- Progress events raised by the temporary document while loading are forwarded to the owning document via the document progress callbacks (OnProgress / OnProgressStart / OnProgressStop).
- The method creates a temporary vdDocument, attempts to load it from the provided stream
using the specified
fileTypeExtension, and then delegates the import/merge logic to AddFromDocument(string, vdDocument, MergeTablesFlags). - If loading the temporary document fails the temporary document is disposed and
nullis returned. - If importing fails, any errors from the import will propagate or be reported by the destination document's error handlers.