SView Help Center
English (US)

main_local.js

Author: sviewngts Last Updated: 2026-10-29 17:20

   SView native rendering entry script, called in window.onload, reads the configuration files, sets the open command parameters, and calls the open command to open the file.

  • Get the manager and initialize the configuration paths
let configManager = sview0.getFrame().getConfigManager();
let commandsManager = sview0.getFrame().getCommandsManager();
initConfigPath();
  • Read the configuration files
// Read the configuration
configManager.load(sysConfigPath).then((ret) => {
   FunctionListener.configLoaded("system");
   let pmiServerUrl = M3D.Config.Parameters.getInstance().getStringParameter("pmiServerUrl");
   if (pmiServerUrl) {
       M3D.Shapes.ComText.option.pmiServer = pmiServerUrl;
   }
   configManager.load(docConfigPath).then((ret) => {
       FunctionListener.configLoaded("doc");
       // Update the settings dialog parameters
       sview0.getViewer().getScene().getBackground().updateConfig();
       window.language = SView.UIManager.languageInfo = SView.FrameConfigure.getInstance().
                       getNumberParameter(M3D.Config.language) === 1 ? SView.UIManager.languageConstants.EN : SView.UIManager.languageConstants.CN;
       
       configManager.loadPropertiesConfigs(customPropertyPath, propertiesConfigPath).then((ret) => {
           // Simply load asynchronously; if a configuration that sets the model name is added later, the open logic must be executed after loading is complete
       });
       configManager.loadCommandConfigs(/*"File", "OpenSampleFile"*/).then((ret) => {
           FunctionListener.configLoaded("command");
       });
   });
});
  • Get the open command
let openCommand = null;
if (ret) {
   openCommand = commandsManager.getCommand(SView.Commands.CommandNames.OPENSAMPLEFILE);
} else {
   // No configuration file
   let array = new Map();
   array.set("fullClassName", "SView.Commands.OpenCommand");
   openCommand = commandsManager.getCommand(SView.Commands.CommandNames.OPENSAMPLEFILE, array);
}
  • Set the command parameters
if (svlxInfo.length === 1) {
   openCommand.fileInfo = svlxInfo[0];
} else {
   for (let fileInfo of svlxInfo) {
       if (fileInfo.directPara.get('downloadUrl')) {
           openCommand.addPath(fileInfo.directPara.get('downloadUrl'));
       }
   }
}
  • Execute the open command
commandsManager.execute(SView.Commands.CommandNames.OPENSAMPLEFILE);
  • Go directly to the processing logic for model comparison

   When entering model comparison directly, there is no need to execute the open command separately; the open command must be placed after model comparison.

// Called when entering model comparison directly
sview0.isCompare = true;
executeCommand("modelCompareButton");
// Address of the model to compare
let path2 = basePath + "/models/Wankel Engine.svlx";
filename2 = path2.slice(path2.lastIndexOf("/") + 1);
modelCompare(null, path2);
openState[0] = 0;
commandsManager.execute(SView.Commands.CommandNames.OPENSAMPLEFILE);