MLightCAD
    Preparing search index...

    Module @mlightcad/cad-simple-viewer - v1.5.5

    CAD Simple Viewer

    License: MIT npm version

    This package provides the high-performance core components of a CAD viewer such as document management, command handling, and collaboration between the UI and rendering engines. It's designed for optimal performance when handling large CAD files.

    This module doesn't depend on any UI framework and doesn't provide any UI except canvas. If you want to integrate a high-performance CAD viewer into a web application with your own UI, this module is the correct choice.

    • Document management optimized for large files
    • Efficient command stack and undo/redo operations
    • Optimized integration with rendering engines
    • Performance-focused settings and context management
    • Framework-agnostic design for maximum flexibility

    Use cad-simple-viewer if you need core CAD logic only (document management, command stack, rendering engine integration) without any UI framework dependencies. This package is ideal if:

    • You want to build your own custom UI or integrate CAD functionality into a non-Vue or non-web environment.
    • You require maximum flexibility and performance for handling large CAD files, and plan to connect the logic to your own rendering or UI layer.
    • You want a framework-agnostic solution that provides only the essential CAD operations and canvas rendering.

    Recommended for: Custom integrations, headless CAD processing, or advanced users building highly tailored CAD solutions.

    • src/app/ – Document/context management, settings
    • src/command/ – Command implementations (open, zoom, select, etc.)
    • src/editor/ – Command stack, input handling, global functions
    • src/view/ – Layout and scene management
    • src/util/ – Utilities
    npm install @mlightcad/cad-simple-viewer
    

    Please refer to cad-simple-viewer-example on basic usage and advanced usage.

    While cad-simple-viewer doesn't support saving drawings to DWG/DXF files, it provides comprehensive support for modifying drawings in real-time. You can add, edit, and delete entities within the drawing, and the viewer will automatically update to reflect these changes.

    When you modify entities, you're working directly with the underlying drawing database. The viewer automatically detects these changes and updates the display accordingly. This real-time synchronization ensures that:

    • All modifications are immediately visible
    • The command stack properly tracks changes for undo/redo operations. This will be implemented soon.

    This capability makes cad-simple-viewer suitable for applications that need to not only display CAD files but also allow users to interact with and modify the drawing content.

    Important Note: The usage patterns in cad-simple-viewer are very similar to AutoCAD RealDWG. If you're familiar with AutoCAD RealDWG development, you'll find the API structure and workflow nearly identical. The main difference is that we use the realdwg-web API instead of the native RealDWG libraries.

    In cad-simple-viewer-example it demonstrates how to create one drawing with realdwg-web API.

    • AcApContext - Main application context
    • AcApDocManager - Document management
    • AcApDocument - Individual document handling
    • AcApSettingManager - Settings management
    • AcApOpenCmd - Open file command
    • AcApZoomCmd - Zoom command
    • AcApPanCmd - Pan command
    • AcApSelectCmd - Selection command

    SVG export (csvg) is provided by the optional @mlightcad/cad-svg-plugin package.

    • AcEditor - Main editor class
    • AcEdCommandStack - Command stack management
    • AcEdSelectionSet - Selection handling
    • AcEdInputPoint - Input point management
    • AcTrScene - Scene management
    • AcTrLayoutView - Layout view handling
    • AcTrView2d - 2D view management

    This package acts as the core logic layer, connecting the frontend UI with the rendering engines and managing all document-related operations.

    MIT

    Enumerations

    AcEdCorsorType
    AcEdOpenMode
    AcEdPromptStatus
    AcEdViewMode
    MTextParagraphAlignment

    Classes

    AcApAnnotation
    AcApArcCmd
    AcApBaseRevCmd
    AcApCacheFontCmd
    AcApCircleCmd
    AcApCircleJig
    AcApClearMeasurementsCmd
    AcApContext
    AcApConvertToDxfCmd
    AcApConvertToPngCmd
    AcApCopyCmd
    AcApDimJig
    AcApDimLinearCmd
    AcApDocManager
    AcApDocument
    AcApDxfConvertor
    AcApEllipseCmd
    AcApEraseCmd
    AcApExamplePlugin
    AcApFontUtil
    AcApHatchCmd
    AcApHideObjectsCmd
    AcApI18n
    AcApLayerCloseCmd
    AcApLayerCmd
    AcApLayerCurCmd
    AcApLayerDelCmd
    AcApLayerFreezeCmd
    AcApLayerIsoCmd
    AcApLayerLockCmd
    AcApLayerOnCmd
    AcApLayerPCmd
    AcApLayerThawCmd
    AcApLayerUnisoCmd
    AcApLayerUnlockCmd
    AcApLayoffCmd
    AcApLineCmd
    AcApLineJig
    AcApLogCmd
    AcApMeasureAngleCmd
    AcApMeasureArcCmd
    AcApMeasureAreaCmd
    AcApMeasureDistanceCmd
    AcApMeasureDistanceJig
    AcApMLineCmd
    AcApMLineJig
    AcApMoveCmd
    AcApMTextCmd
    AcApOffsetCmd
    AcApOpenCmd
    AcApPanCmd
    AcApPluginManager
    AcApPngConvertor
    AcApPointCmd
    AcApPolygonCmd
    AcApPolylineCmd
    AcApPolylineJig
    AcApQNewCmd
    AcApRayCmd
    AcApRectCmd
    AcApRectJig
    AcApRegenCmd
    AcApRevCircleCmd
    AcApRevCloudCmd
    AcApRevCloudJig
    AcApRevRectCmd
    AcApRevVisibilityCmd
    AcApRotateCmd
    AcApSelectCmd
    AcApSettingManager
    AcApSketchCmd
    AcApSketchJig
    AcApSplineCmd
    AcApSplineJig
    AcApSwitchBgCmd
    AcApSysVarCmd
    AcApUnisolateObjectsCmd
    AcApXLineCmd
    AcApZoomCmd
    AcEdBaseView
    AcEdCommand
    AcEdCommandLine
    AcEdCommandStack
    AcEdConditionWaiter
    AcEdCursorManager
    AcEdHoverController
    AcEdInputManager
    AcEditor
    AcEdKeyword
    AcEdKeywordCollection
    AcEdMarker
    AcEdMarkerManager
    AcEdMTextEditor
    AcEdPreviewJig
    AcEdPromptAngleOptions
    AcEdPromptBoxOptions
    AcEdPromptBoxResult
    AcEdPromptDistanceOptions
    AcEdPromptDoubleOptions
    AcEdPromptDoubleResult
    AcEdPromptEntityOptions
    AcEdPromptEntityResult
    AcEdPromptIntegerOptions
    AcEdPromptIntegerResult
    AcEdPromptKeywordOptions
    AcEdPromptNumericalOptions
    AcEdPromptNumericalResult
    AcEdPromptOptions
    AcEdPromptPointOptions
    AcEdPromptPointResult
    AcEdPromptResult
    AcEdPromptSelectionOptions
    AcEdPromptSelectionResult
    AcEdPromptStateMachine
    AcEdPromptStringOptions
    AcEdSelectionFilter
    AcEdSelectionSet
    AcTrScene
    AcTrView2d
    MTextColor
    ShxParserFont

    Interfaces

    AcApCacheFontOptions
    AcApDocManagerOptions
    AcApLazyPluginRegistration
    AcApOpenDatabaseOptions
    AcApPlugin
    AcApSettingManagerEventArgs
    AcApSettings
    AcApWebworkerFiles
    AcDbDocumentEventArgs
    AcDbSysVarEventArgs
    AcEdCommandEventArgs
    AcEdCommandGroup
    AcEdFontNotLoadedInfo
    AcEdHoverHost
    AcEdInputModifiers
    AcEdInputToggles
    AcEdKeywordPromptFormat
    AcEdLayerInfo
    AcEdMissedData
    AcEdMouseEventArgs
    AcEdMTextEditorCurrentFormatObservable
    AcEdMTextEditorOptions
    AcEdMTextEditorResult
    AcEdPromptState
    AcEdSelectionEventArgs
    AcEdSelectionModifierState
    AcEdSpatialQueryResultItem
    AcEdSpatialQueryResultItemEx
    AcEdViewHoverEventArgs
    AcEdViewRenderFrameEventArgs
    AcEdViewResizedEventArgs
    AcTrSceneStats
    AcTrView2dOptions
    FontInfo
    FontLoadStatus
    HatchSettings
    MTextToolbarColorPickerContext
    MTextToolbarColorPickerInstance
    ShxFontData

    Type Aliases

    AcApFontMapping
    AcApLocale
    AcEdCalculateSizeCallback
    AcEdEvents
    AcEdMarkerType
    AcEdMessageType
    AcEdMTextEditorActiveInputBox
    AcEdMTextEditorActiveInputBoxChangeListener
    AcEdMTextEditorCurrentFormatChangeListener
    AcEdPromptStateStep
    AcEdSelectionAction
    AcEdSelectionMode
    AcEdUiTheme
    FontType
    MTextToolbarColorPickerFactory

    Variables

    AcTrGeometryUtil
    DARK_THEME_FOREGROUND
    DEFAULT_VIEW_2D_OPTIONS
    eventBus
    LIGHT_THEME_FOREGROUND
    MODEL_SPACE_BACKGROUND
    PAPER_SPACE_BACKGROUND
    POLARMODE_ADDITIONAL_ANGLES
    POLARMODE_POLAR_TRACKING

    Functions

    acedAlert
    applySessionHiddenObjectState
    applyUiTheme
    canvasBackgroundFromColor
    captureLayerStateBeforeOperation
    clearAllMeasurements
    cmdDescription
    colorToCssAlpha
    constrainToOrtho
    constrainToTracking
    contrastingForegroundColor
    cssColor
    cursorColorForBackground
    foregroundColorForBackground
    foregroundColorFromColorTheme
    geBox2dToThreeBox2d
    geBox2dToThreeBox3d
    geBox3dToGeBox2d
    geBox3dToThreeBox3d
    getDrawingExportBaseName
    getLayerPreviousStateManager
    getPolaraddang
    getPolarang
    getPolarmode
    hideObjects
    isLightBackground
    isLightColorTheme
    isModelSpaceDatabase
    isOpenFileProgressComplete
    isOrthoModeEnabled
    isPolarTrackingEnabled
    layoutBackgroundSysVar
    makeBadge
    makeDot
    makeLiveBadge
    makeLiveDot
    makeOverlayCanvas
    makeSnapIndicator
    measurementColor
    readLayoutBackgroundColor
    registerMeasurementCleanup
    resetExportDownloadNamesForTests
    resolveExportDownloadName
    resolvePointerSelectionAction
    resolveSelectionActionFromEvent
    sysCmdDescription
    threeBox2dToGeBox2d
    threeBox3dToGeBox2d
    threeBox3dToGeBox3d
    toggleBlackWhiteBackgroundColor
    togglePolarTracking
    unisolateObjects
    userCmdDescription
    yieldToMain

    References

    AcGiTextParagraphAlignment → MTextParagraphAlignment