Usage Notes
- Only BIMFACE platform web applications are supported, using JSSDK v3
- Strictly follow
references/the code style of the corresponding documentation in the directory; do not change the API calling methods on your own - Only implement the functionality explicitly requested by the user
API Calling Guide
1. Page Initialization
- BIMFACE initialization: refer toBIMFACE initialization
1.1 Requirement Analysis (mandatory before coding)
After receiving the user's requirements, complete the following steps before starting to code:
- Capability mapping: match the keywords of the user's requirements against
§2 功能模块to find the matching reference documentation - Scope confirmation: if the requirement involves more than 3 modules, list the modules planned to be called and let the user confirm the priority
- Unsupported notification: if the requirement cannot match any existing reference, immediately inform the user that "it is not supported within the current SDK capability scope" to avoid silently generating incorrect code
- Multi-drawing determination: if the requirement involves switching between or simultaneously loading multiple drawings, confirm whether it is necessary to use
drawing2D.getDrawing(modelId)to specify the target drawing
2. Functional Modules
2.1 Drawing Interaction Related
- Common listening events: refer toListening events
- Display modes and view switching: refer toDisplay modes and views
- View control: refer toView control
- State saving and restoration: refer toState management
- Drawing screenshots: refer toScreenshots
2.2 Element Operation Related
- Element selection/highlighting/hiding/showing: refer toElement operations
- Bounding box: refer toBounding box
2.3 Layer Related
- Layer management: refer toLayer management
2.4 Annotation Related
- 2D labels: refer to2D labels
- Aggregated labels: refer toAggregated labels
- Drawing annotations: refer toDrawing annotations
- Drawing measurement: refer toDrawing measurement
3. Global Variable Naming Conventions
All reference documents uniformly use the following variable names, which are no longer declared individually:
| Variable name | Type/Description | How to obtain |
|---|---|---|
viewer2D |
2D drawing viewer object | app2D.getViewer() |
app2D |
WebApplicationDrawing application object | new Glodon.Bimface.Application.WebApplicationDrawing(config) |
drawing2D |
Drawing object | viewer2D.getDrawing(modelId)(if modelId is not passed, the default drawing object is returned) |
drawableContainer |
2D label container object | new Glodon.Bimface.Plugins.Drawable.DrawableContainer(config) |
Key constraints:
drawing2Dmust be obtained only after the drawing'sLoadedevent is triggered; before operating on layers/elements, obtain the target drawing object viaviewer2D.getDrawing(modelId).
4. Code Self-Check
After development is complete, check item by item:
- Functionality traceability: Compare the generated code against the original requirements one by one, confirm that every feature point in the requirements has a corresponding implementation, and that there is no "A was required but B was generated" or extra generation of features that were not requested.
- Do variable names conform to the naming convention (
viewer2D/app2D/drawing2D/drawableContainer) - Can the exact same method signature be found in the corresponding reference for each API call (without inventing method names or parameter names yourself)? If a feature has no explicit API in the corresponding reference documentation, tell the user that "the current SDK capability scope does not support it" and do not invent method names or parameters yourself.
- Are the results of asynchronous operations (
getObjectDataById、getAllObjectIds、createSnapshotAsync, etc.) handled in callback functions? - After a state change, is
viewer2D.render() - Is the event handler a named function (to ensure it can be unregistered)?
- Before drawing operations, has the drawing finished loading been confirmed through the
Loadedevent? - Does color construction use
new Glodon.Web.Graphics.Color()rather than a bare color string or array? - Are there any "wild variables" in the code that are not declared in
§3 全局变量命名约定?
4.1 Common Errors Quick Reference
| ❌ Incorrect | ✅ Correct |
|---|---|
new WebApplication3DConfig() + WebApplication3D |
For vector drawings, use WebApplicationDrawingConfig + WebApplicationDrawing, see BIMFACE initialization |
viewMetaData.viewType == "3DView" |
For vector drawings, determine viewMetaData.viewType == "dwgView", see BIMFACE initialization |
In the ViewAdded event, operate on the element |
For 2D drawings, listen to the Loaded event rather than ViewAdded, see Listen to events |
For 2D coordinates, pass in {x, y, z} |
The world coordinates of the drawing are {x, y} without a z value; passing in a z value will be ignored or cause an error |
viewer2D.getObjectDataById(id, cb) |
Use drawing2D.getObjectDataById(id, cb), which is a method of the drawing object, not a method of the viewer |