SView Help Center
English (US)

Custom Views

Author: sviewngts Last Updated: 2026-10-28 16:39

Interface List

Interface Name Description
View List Obtains the model's currently existing views, including in-model views and online views
Create Creates a custom view
Delete Deletes a custom view
Change Changes to the scene saved in the view
Rename Renames a custom view
Set Default View Sets a view as the default view
Serialize Serializes a view into JSON format
Deserialize Deserializes JSON-format view data into a view object

View List

// 1. Execute the get view list command
let array = new Map();
array.set("fullClassName", "SView.Commands.ShowViewListCommand");// Information about the class corresponding to the command
// Set command parameters
let inputParas = new SView.CommandParameters();
let inputPara = new SView.CommandParameter();
// Whether to load the view list directly or only switch the model view; set loadFlag to false to obtain the view list
inputPara.name = "loadFlag";
inputPara.value = false;
inputParas.add(inputPara);
array.set("commandParameters", inputParas);
getCommandsManager().execute("ShowViewList", array);
// 2. Obtain the view list
let modelViews = shapes.getShapes(M3D.Shapes.ShapeType.SHAPE_MODELVIEW);

Create View

   Create a view:

let array = new Map();
array.set("fullClassName", "SView.Commands.CreateViewCommand");// Information about the class corresponding to the command
commandManager.execute("CreateView");

   Obtain the created view object:

let createViewCmd = commandManager.getCommand("CreateView");
let currentView = createViewCmd.modelViewAction.modelView;

Delete View

let id = currentView.getId();
let viewServerId = currentView.getProperty("serverId") + "";
let array = new Map();
// If already populated in the configuration file, the fullClassName parameter can be omitted
array.set("fullClassName", "SView.Commands.DeleteViewCommand");
// Populate view information
let inputParas = new SView.CommandParameters();
let inputPara = new SView.CommandParameter();
inputPara.name = "viewId";
inputPara.value = id;
inputParas.add(inputPara);
inputPara = new SView.CommandParameter();
inputPara.name = "viewServerId";
inputPara.value = viewServerId;
inputParas.add(inputPara);
array.set("commandParameters", inputParas);
commandManager.execute("DeleteView", array);

Change View

let array = new Map();
array.set("fullClassName", "SView.Commands.ChangeViewCommand");// Information about the class corresponding to the command
let inputParas = new SView.CommandParameters();
let inputPara = new SView.CommandParameter();
inputPara.name = "modelViewId";
inputPara.value = modelViewId;
inputParas.add(inputPara);
inputPara = new SView.CommandParameter();
inputPara.name = "loadFlag";
inputPara.value = false;
inputParas.add(inputPara);
inputPara = new SView.CommandParameter();
inputPara.name = "isEditMode";
inputPara.value = isEditMode || false;
inputParas.add(inputPara);
array.set("commandParameters", inputParas);
commandManager.execute("ChangeView", array);

Rename View

let targetModelView = ***;
let id = targetModelView.getId();
let viewServerId = targetModelView.getProperty("serverId") + "";
let viewName = targetModelView.getName();
let array = new Map();
array.set("fullClassName", "SView.Commands.RenameViewCommand");// Information about the class corresponding to the command
let inputParas = new SView.CommandParameters();
let inputPara = new SView.CommandParameter();
inputPara.name = "viewId";
inputPara.value = id;
inputParas.add(inputPara);
inputPara = new SView.CommandParameter();
inputPara.name = "viewServerId";
inputPara.value = viewServerId;
inputParas.add(inputPara);
inputPara = new SView.CommandParameter();
inputPara.name = "viewName";
inputPara.value = viewName;
inputParas.add(inputPara);
array.set("commandParameters", inputParas);
commandManager.execute("RenameView", array);

Set Default View

let array = new Map();
array.set("fullClassName", "SView.Commands.SetDefaultViewCommand");// Information about the class corresponding to the command
let inputParas = new SView.CommandParameters();
let inputPara = new SView.CommandParameter();
inputPara.name = "viewId";
inputPara.value = id;
inputParas.add(inputPara);
inputPara = new SView.CommandParameter();
inputPara.name = "viewServerId";
inputPara.value = currentView.getProperty("serverId") + "";
inputParas.add(inputPara);
inputPara = new SView.CommandParameter();
inputPara.name = "isActivated";
inputPara.value = isActivated;
inputParas.add(inputPara);
array.set("commandParameters", inputParas);
frame.getCommandsManager().execute("SetDefaultView", array);

View Serialization

// Serialize view information and scene information into JSON format
let contentStr = M3D.Reader.ModelViewFactory.toJson(modelView);
// Serialize instance data and additional data in the view into JSON format
let subContentStr = M3D.Reader.ModelViewFactory.toServerJson(modelView, scene);

View Deserialization

// Deserialize JSON data into a view object
let modelView = M3D.Reader.ModelViewFactory.fromJsonByServer(contentStr, subContentStr, scene);
// Add the view to the scene
shapes.addShape(modelView);