CADViewer Space Objects - Solution Flow
This is a small check-list for the solution flow when setting up a CADViewer solution flow for any application usage for Space Management-, IWMS- and IOT-solutions and many many more. Most of the items in this check-list references other parts of the documentation.
CADViewer consists of the CADViewer Front-End supported by one or more CAD Data Converters (AutoXchange, DwgMerge) and CAD Data Extractors (LinkList, DwgList) implemented on the server-side and acccessed either through our CADViewer RESTFUL API or directly spawned as a command-line executable.
The first decision to be made is to convert drawings on-the-fly or ahead of time. For drawings that change often, on-the-fly conversion is preferred. If the base drawings are static in nature (of course the Space Object Overlays on top of the CAD drawing can and will dynamically change), then it is better to apply a CAD conversion ahead of time and use the pre-converted floor-plan.
1) For convertion on-the-fly, then the CADViewer Solution Architecture, will specifically be as outlined in the CADViewer Architecture Overview. Use the Platform Handlers overview to select your particular back-end/front-end combination. The Platform Handlers overview list will link into our GitHub Repository which contains a large number of sample implementations of Front-end/Back-end combinations depending on platform combination.
2) If converting ahead of time, there are two ways of approching this:
- 2A: Implement a native call to the command-line tools: CAD Data Converters (AutoXchange, DwgMerge) and CAD Data Extractors (LinkList, DwgList) directly. For conversion of CAD floor-plans use AutoXchange 2023 Converter, where the command line parameter interface is described at: AutoXchange Parameter Interface. To process Space Objects the Database Linkage Parameter Interface parameters are needed. Note: that if the base CAD drawing contains both model and multiple views, then the parameter basic is needed to create a batch of SVG files (for later display) otherwise the model-space parameter model is needed. Also, note, that template code to call AutoXchange AX2023 on various platforms can be found in these endpoint scipts.
- 2B: Instead of a native call to the converter, the same can be accomplished by using the CADViewer Restful API with the appropriate Platform Handler installed on the server, see the GitHub Rest-API Samples on how to make the appropriate REST calls. As above, for conversion of floor-plans use AutoXchange AX2023 converter, where the command line parameter interface is described at: AutoXchange Parameter Interface. In a REST call the conversion parameters are passed into the REST JSON object. To process Space Objects the Database Linkage Parameter Interface parameters are needed. Note: that if the base CAD drawing contains both model and multiple views, then the parameter basic is needed to create a batch of SVG files (for later display) otherwise the model-space model. All these command are written into the REST calls in the GitHub CADViewer-REST-API-Conversion-Server sample.
Space Object Processing
The CADViewer Space Object Interface can be used in the following ways to process Space Objects:
- 3A: Pre-processing of polygons and blocks in the CAD drawing into clickable objects.
- 3B: Adding Space Object Icons or drawn space polygons on top of the drawing.
- 3C: A combination of 3A) and 3B).
Typically, the pre-processing under 3A: will be done as part of the general process under 2A: or 2B:. The conversion process is described in the Database Area Linkage section of the AutoXchange AX2023 documentation, where the detailed (RL/TL) parameters are described in the Database Linkage Parameter Interface.
When the pre-processed Space Objects are loaded into CADViewer they are processed as JSON Objects. Typically, the application programmer will extract these JSON Objects with all processed spaces using the API command cvjs_returnAllSpaceObjects in the call-back cvjs_OnLoadEnd(). The available API commands to manipulate Space Objects are here: JSON Structure & JSON Commands.
There is an API cvjs_setSpaceObjectProcessing() to select not to process JSON Objects at load time of the drawing, so the complete JSON Object consistent of the operations 3A:, 3B: and 3C: can then be inserted after load call-back cvjs_OnLoadEnd() on the base CAD drawing using the API cvjs_setSpaceObjectsStructureDirect(). Obviously the pre-processing process needs to be repeated in case the underlying floor-plan changes.
Template Samples for the Front-End
- ReactJS - General Sample, dotNetCoreReact
- AngularJS - General Sample - TypeScript Angular 13, General Sample - Angular 11
- VueJS - General Sample
Front-End Implementation Notes
The samples contains the standard initialization settings, which can be found in CADViewer Front-End, but some quick notes below:
1: When loading a drawing from CADViewer use the API command cvjs_LoadDrawing(). The FileName parameter is the server location of the display file and needs to be passed over from the application programmers code. If using on-the-fly the filename will be a CAD (DWG/DXF/PDF) file on the server, if file is converted ahead of time, it will be an SVG file. Note, if drawing is pre-processed and navigation between views is needed, then the full SVG bundle must be present the folder passed over.
2: The application programmer must always set the URL to the Back-end location, the URL of the front-end itself as well as an optional setting of ServerLocation (should be an empty string in production).
var ServerBackEndUrl = http(s)://mybackendcadviewerserver; var ServerUrl = window.location.protocol+"//"+window.location.hostname+"/cadviewer/"; var ServerLocation = "";
3: Use the CADViewer Call-Back method cvjs_OnLoadEnd() to add specific processing. For example, programmers can add processing flags in cvjs_OnLoadEnd() so on the first run cvjs_returnAllSpaceObjects is used to extract all pre-processed content, on re-load of the drawing, cvjs_setSpaceObjectsStructureDirect is used to insert all content.
4: The CADViewer Call-Back method cvjs_graphicalObjectOnChange() captures any change or creation of Space Objects on the CAD Canvas. This CADViewer Call-Back is therefore used to monitor all user actions, the API command cvjs_returnSpaceObjectID(spaceID) can be called to fetch the Space Object, so it can saved into the application programmer’s back-end for re-use. All samples contains reference code for implementing cvjs_graphicalObjectOnChange();