ReadonlyeventsEvents fired during document lifecycle
Fired when a document becomes active
Fired when a new document is created
Gets the list of available fonts that can be loaded.
Note: These fonts are available for loading but may not be loaded yet.
Array of available font names
Base URL to load fonts
Gets the current application context.
The context binds the current document with its associated view.
The current application context
Gets the current 2D view used to display the drawing.
The current 2D view instance
Gets the currently active document.
For now, this is the same as curDocument since only one document
can be active at a time.
The current active document
StaticinstanceGets the singleton instance of the document manager.
Creates a new instance if one doesn't exist yet.
The singleton document manager instance
Destroy the view and unload all plugins
Loads default fonts for CAD text rendering.
This method loads either the specified fonts or falls back to default Chinese fonts (specifically 'simkai') if no fonts are provided. The loaded fonts are used for rendering CAD text entities like MText and Text in the viewer.
It is better to load default fonts when viewer is initialized so that the viewer can render text correctly if fonts used in the document are not available.
Optionalfonts: string[]Optional array of font names to load. If not provided or null, defaults to ['simkai'] for Chinese text support
Promise that resolves when all specified fonts are loaded
Search through all of the global and untranslated names in all of the command groups in the command stack starting at the top of the stack trying to find a match with cmdName. If a match is found, the matched AcEdCommand object is returned. Otherwise undefined is returned to indicate that the command could not be found. If more than one command of the same name is present in the command stack (that is, in separate command groups), then the first one found is used.
The command is only returned if it is compatible with that open mode of the current document. Higher value modes are compatible with lower value modes.
Input the command name to search for
Return the matched AcEdCommand object if a match is found and compatible with the open mode of the current document. Otherwise, return undefined.
Search through all of the local and translated names in all of the command groups in the command stack starting at the top of the stack trying to find a match with cmdName. If a match is found, the matched AcEdCommand object is returned. Otherwise undefined is returned to indicate that the command could not be found. If more than one command of the same name is present in the command stack (that is, in separate command groups), then the first one found is used.
The command which is compatible with the open mode of the current document is only returned
Input the command name to search for
Return the matched AcEdCommand object if a match is found and compatible with the open mode of the current document. Otherwise, return undefined.
ProtectedonProtectedPerforms setup operations after a document opening attempt.
This protected method is called automatically after any document opening operation. If the document was successfully opened, it dispatches the documentActivated event, sets up layout information, and zooms the view to fit the content.
Whether the document was successfully opened
ProtectedonProtectedPerforms cleanup operations before opening a new document.
This protected method is called automatically before any document opening operation. It clears the current view to prepare for the new document content.
Opens a CAD document from file content.
This method loads a document from the provided file content (binary data) and replaces the current document. It handles the complete document lifecycle including before/after open events.
The name of the file being opened (used for format detection)
The file content
Database opening options including font loader settings
Promise that resolves to true if the document was successfully opened, false otherwise
Opens a CAD document from a URL.
This method loads a document from the specified URL and replaces the current document. It handles the complete document lifecycle including before/after open events.
The URL of the CAD file to open
Optionaloptions: AcApOpenDatabaseOptionsOptional database opening options. If not provided, default options with font loader will be used
Promise that resolves to true if the document was successfully opened, false otherwise
Redraws the current view. Currently it is used once you modified font mapping for missed fonts so that the drawing can apply new fonts.
Fuzzy search for commands by prefix using the command iterator.
This method iterates through all commands in all command groups and returns those whose global or local names start with the provided prefix. The search is case-insensitive. Only commands which are compatible with that open mode of the current document are returned. Higher value modes are compatible with lower value modes.
The prefix string to search for. Case-insensitive.
An array of objects containing matched commands and their corresponding group names.
Executes a command by its string name.
This method looks up a registered command by name and executes it with the current context. It checks if the command's required mode is compatible with the document's current mode. If the command is not found or not compatible, an error is thrown.
The command string to execute (e.g., 'pan', 'zoom', 'select')
Configures layout information for the current view.
Sets up the active layout block table record ID and model space block table record ID based on the current document's space configuration.
StaticcreateCreates the singleton instance with an optional canvas element.
This method should be called before accessing the instance property
if you want to provide a specific canvas element.
Options for creating AcApDocManager instance
The singleton instance
Document manager that handles CAD document lifecycle and provides the main entry point for the CAD viewer.
This singleton class manages:
The manager follows a singleton pattern to ensure only one instance manages the application state.