Method AddFromFile
- Namespace
- VectorDraw.Professional.vdCollections
- Assembly
- VectorDraw.Professional.dll
AddFromFile(string, bool)
Creates a vdBlock from the specified file and adds it to this collection.
public vdBlock AddFromFile(string FileName, bool redefine)
Parameters
FileNamestringThe path to the file from which model entities for the block will be taken.
redefineboolIf
trueand a block with the same name already exists in this document, the existing block will be redefined (replaced) by the block imported from the file. Iffalse, an existing block with the same name will be preserved (kept) and returned — in that case the existing block is un-deleted if necessary.
Returns
- vdBlock
The vdBlock that was created or found in this collection. Returns
nullif the file could not be opened or the import failed.
Remarks
This overload maps the boolean redefine to a vdDocument.MergeTablesFlags value:
true=> Redefinefalse=> KeepExisting
- See Also
AddFromFile(string, MergeTablesFlags)
Creates a vdBlock object from a file.
public vdBlock AddFromFile(string FileName, vdDocument.MergeTablesFlags mergeflags)
Parameters
FileNamestringThe full path to the source file from which model entities for the block will be taken.
mergeflagsvdDocument.MergeTablesFlagsA vdDocument.MergeTablesFlags value that controls how tables (layers, blocks, styles, etc.) with the same name are merged into the current document. For example:
- KeepExisting - keep existing tables in the destination document and skip replacing them.
- Redefine - replace destination tables with those from the source.
Returns
- vdBlock
The vdBlock that was created or found in this collection. If a block with the same name already exists and
mergeflagsis KeepExisting, the existing block is returned (and un-deleted). If the file cannot be opened or no block is created, the method returnsnull.
Remarks
This method:
- Extracts the file name without extension to determine the block name.
- Temporarily appends the file directory to SupportPath while opening the file.
- Creates a temporary vdDocument to load the source file and delegates the merge/import work to AddFromDocument(string, vdDocument, MergeTablesFlags).
- Restores SupportPath and disposes the temporary document before returning.
- Any exceptions raised during the import are reported via RaiseGenericError(string, string); the method itself suppresses exceptions and returns
nullon failure to open the file.
AddFromFile(string, string, MergeTablesFlags)
Creates a vdBlock object from a file.
public vdBlock AddFromFile(string blockname, string FileName, vdDocument.MergeTablesFlags mergeflags)
Parameters
blocknamestringThe name to assign to the created block. If an empty string is provided, a new unnamed block is created.
FileNamestringThe full path to the source file from which model entities for the block will be taken.
mergeflagsvdDocument.MergeTablesFlagsA vdDocument.MergeTablesFlags value that controls how tables (layers, blocks, styles, etc.) with the same name are merged into the current document. For example:
- KeepExisting - keep existing tables in the destination document and skip replacing them.
- Redefine - replace destination tables with those from the source.
Returns
- vdBlock
The vdBlock that was created or found in this collection. If a block with the same name already exists and
mergeflagsis KeepExisting, the existing block is returned (and un-deleted). If the file cannot be opened or no block is created, the method returnsnull.
Remarks
This method:
- Temporarily appends the file directory to SupportPath while opening the file.
- Creates a temporary vdDocument to load the source file and delegates the merge/import work to AddFromDocument(string, vdDocument, MergeTablesFlags).
- Restores SupportPath and disposes the temporary document before returning.
- Any exceptions raised during the import are reported via RaiseGenericError(string, string); the method itself suppresses exceptions and returns
nullon failure to open the file.