Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2024.
Loading...
Searching...
No Matches
Style Guide

The scripting environment is composed of two main elements:

Most of scripting classes inherit from SComp which represents a generic object and contains common functions such as SComp.GetBoundingBox().

Functions: Member functions vs Static functions

While browsing the documentation, you may encounter three types of functions:

  • Static functions
  • Member functions
  • Namespace functions

A member function refers to a class instance, therefore it can only be called from class objects and not from their class name.
It is called through the following syntax: VariableName.MemberFunction().

var newPt = SPoint.New();
var x = newPt.GetX(); // Valid syntax
var x = SPoint.GetX(); // Invalid syntax
Provide point edition and creation methods.
Definition: Reshaper.h:6761
static SPoint New()
Default constructor to create an empty new SPoint. X = Y = Z = 0.
number GetX()
Get the X coordinate value.

A static function is a class function, therefore it can only be called from its class and not class objects themselves.
It is called through the following syntax: ClassName.MemberFunction().

var myPoint = SPoint.New(); // Valid syntax
var point = myPoint.New(); // Invalid syntax

Static functions are identifiable in documentation thanks to keyword "static" at the beginning, such as SPoint.FromSel.

Namespace functions

Namespaces contain functions that are not linked to a specific object or class.
It can be seen as a place to store functions having a common field of application.
The code syntax is similar to static functions.

// Get the selected sphere object
var theSphere = SSphere.FromSel()[0];
// Call the global function Convert from the SCADUtil namespace, to convert the sphere to a CAD object
var ret = SCADUtil.Convert(mySphere);
Provide sphere edition and creation methods.
Definition: Reshaper.h:11824
static Array< SSphere > FromSel()
Get all the selected SSphere.
Provide CAD objects edition and utility methods.
Definition: Reshaper.h:12179
Note
The ScriptUtil namespace is a specific case.
For convenience purpose, all methods from this namespace have to be called without the namespace name:
ZoomAll();

Return values

Most of data processing methods (except constructors for instance) follow a common scheme, they return a map containing:

  • the error code, indicating if the function succeed or not
  • the list of output objects if any

The function SPoly.Explode illustrates this rule:

var myPoly = SPoly.FromSel()[0];
var ret = myPoly.Explode();
var returnCode = ret.ErrorCode;
var explodedPolyTbl = ret.PolyTbl;
print("Return code: " + returnCode);
print("Number of polys: " + explodedPolyTbl.length);
Provide triangular mesh edition and creation methods.
Definition: Reshaper.h:6993
static Array< SPoly > FromSel()
Get all the selected SPoly.

Enumeration

An enumeration provides access to a set of predifined values that can be used as functions parameters.
For readability purpose, they are always written in upper case.

var myCloud = SCloud.FromName("My Cloud")[0];
myCloud.SetCloudRepresentation(SCloud.CLOUD_INSPECTION);
Provide point cloud edition and creation methods.
Definition: Reshaper.h:3306
@ CLOUD_INSPECTION
Colors ares based on an inspection value on each point. (only available if the cloud contains inspect...
Definition: Reshaper.h:3359
static Array< SCloud > FromName(string name)
Search all the SCloud with the given name.