Scene Operations
Interface List
| Interface Name | Description |
|---|---|
| Visualization Object Operations | Get, add, and delete visualization objects, e.g.: models, annotations,measurements, sections, etc. |
| Selection Operations | Selection operations on visualization objects |
| Visibility Control | Set the display or hiding of visualization objects |
| Background Operations | Get the background object and set the background |
Visualization Object Operations
Visualization object operations are performed through shapes from the basic interfaces
//Get all Model objects
let models = shapes.getShapes(M3D.Shapes.ShapeType.MODEL);
//Get all annotation objects
let annotations = shapes.getShapes(M3D.Shapes.ShapeType.ANNOTATION_NOTE);
//Get multi-leader annotations
let multiLeaderAnnotations = shapes.getShapes(M3D.Shapes.ShapeType.MULTILEADER_ANNOTATION_NOTE);
//Get hand-drawn annotations
let gestures = shapes.getShapes(M3D.Shapes.ShapeType.THREED_GESTURE_NOTE);
//Get all measurements
let measures = shapes.getShapes(M3D.Shapes.ShapeType.MEASURE_BASE);
//Get all sections. Use SECTION to get the sections created in the current scene, and use SECTION_PLANE to get the sections loaded from an SVLX file or an online view.
let sections = shapes.getShapes(M3D.Shapes.ShapeType.SECTION);
let sectionPlanes = shapes.getShapes(M3D.Shapes.ShapeType.SECTION_PLANE);
//Get all PMIs
let pmis = shapes.getShapes(M3D.Shapes.ShapeType.PMI);
//Get all views
let modelViews = shapes.getShapes(M3D.Shapes.ShapeType.SHAPE_MODELVIEW);
//Get a single visualization object
let shape = shapes.getShape(id);
let shape = shapes.getShape(id,shapeType);
//Add visualization objects
shapes.addShapes(shapeList);
shapes.addShape(shape);
//Delete visualization objects
shapes.removeShape(id);
shapes.removeShapes(isList);
//Clear visualization objects; passing no parameter clears visualization data of all types
shapes.clearShapes();
shapes.clearShapes(shapeType);
//Get a visualization object by ObjectId
let shape = shapes.getShapeByObjectId(id);
let shape = shapes.getShapeByObjectId(id,shapeType);
//Get a PMI by PMIId
let pmi = shapes.getPMIByPMIId(PMIId);
Selection Operations
Selection operations are performed through selector from the basic interfaces
//Get the selected objects
let shapes = selector.getAll();
//Get the first selected object
let shape = selector.get();
//Get the data of a certain type in the selector
let shapeList = selector.getShapesByType(shapeType);
//Add selection
selector.add(shapeId);
selector.add(shape);
selector.add(shapeList);
//Remove selection
selector.remove(id);
selector.remove(shape);
selector.remove(shapeList);
//Clear the selector
selector.clear();
//Get the number of selected items
selector.count();
//Check whether a visualization object has been selected
selector.exist(shape);
selector.exist(id);
Visibility Control
Visibility control is performed through visibles from the basic interfaces
//Add visible objects
visibles.add(shape);
visibles.add(shapeList);
//Remove visible objects
visibles.remove(shape);
visibles.remove(shapeList);
visibles.remove(shapeType);
visibles.remove(id,shapeType);
//Version 10.3.36 and later: clear visible objects. After clearing, call the scene's refresh method to update the viewport
visibles.clear();
scene.refresh();
//Get visible objects
visibles.get(id);
visibles.get(id,shapeType);
//Get all visible objects. The return value is an array, where index is a value of type ShapeType and value is also an array; within the value array, index is the shapeId and value is the shape object
visibles.getAll();
//Get the number of visible objects
visibles.count();
Background Operations
Background operations require getting the background object through the scene, and then operating on it
//Get the background object
let background = scene.getBackground();
//Set the background type, of type M3D.Shapes.BackgroundType
//BackgroundType.ColorBackground、BackgroundType.ImageBackgournd、BackgroundType.SkyboxBackgournd
background.setType(type);
//After setting the background type, call different interfaces to set which type to use
//To set a background color, call
background.setUseColor(true);
//To set a background image, call
background.setUseImage(true);
//To set a skybox, call
background.setUseSkyBox(true);
//Get the background type
background.getType();
//Set the background top color, of type M3D.M3DMath.Color
//The Color constructor parameters are r, g, b, a, numbers in the range 0-1
let color = new M3D.M3DMath.Color(1,1,1,1);
background.setTopColor(color);
//Set the background bottom color, of type M3D.M3DMath.Color
let color = new M3D.M3DMath.Color(0,0,0,1);
background.setBottomColor(color);
//Get the background top color
background.getTopColor();
//Get the background bottom color
background.getBottomColor();
//Set the background image path
background.setImage(imagePath);
//Clear the skybox images
background.clearSkyBoxImage();
//Add skybox images; a skybox consists of six images
//Add the image paths of the +X, -X, +Y, -Y, +Z, and -Z directions in order
background.addSkyBoxImage(imagePath);
//After the background parameters are set, call the update method
scene.refresh();