In 3DReshaper Script Plugin you can create new 3DReshaper objects through the use of predefined variables containing static methods. Each class has its name-matching variable allowing access to its class static functions.
To create a new class object you will call the New() static function available for most of classes:
var myPoint = SPoint.New(); // Create a new point
Once your class object created, you can call any available method from it, like for instance:
var myPoint = SPoint.New();
myPoint.AddToDoc(); // Display our point into the scene
Moreover, as you can see Classes always begin with S capital and an other capital letter.
Finally, to copy a 3DReshaper SObject Javascript instance you cannot use the = operator, indeed the = operator merely copies the object reference and does not create a copy.
To copy an SObject instance, you must use the New( objectToCopy ) static constructor available for most of class. For instance:
var myPoint = SPoint.New();
var pointCopy = SPoint.New( myPoint ); // Valid syntax
var samePoint = myPoint; // Invalid syntax
samePoint.SetX(34); // will change samePoint and myPoint
In the script plugin multiple function exist: Global, Static or Member. The most common function are Member function. We will try to explain syntax, and how to use this function.
You will encounter global function only in namespaces. Global functions are not attached to a class.
So you can call them directly in your script. For instance:
ClearDoc();
Static functions are class functions, therefore they can only be called from their class and not class objects themselves.
Static functions are called with operator ".".
For instance:
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".
Member functions referrers to class instance, therefore they can only be called from class objects and not from their class name. Member functions will act on the current object.
Member functions are called with operator ".".
For instance:
var newPt = SPoint.New();
var x = newPt.GetX(); // Valid syntax
var x = SPoint.GetX(); // Invalid syntax
Most data processing methods (except constructors for instance) follow a common scheme : they always output return values as a container object, generally with the following content attributes :
... and more, check the documentation for more details.
An enumeration is a distinct constant value. An enumeration is most of the time associated to a class. Enumerations are used for function parameters.
If enumeration is used inside member and static function, the class name must be used.
For instance:
SetViewDir(AXIS_X); // for a global function
var myCloud = SCloud.New();
myCloud.SetRepresentationType(SCloud.INSPECTION); // for a member function
var myPoly = SPoly.New();
myPoly.SetRepresentationType(SPoly.INSPECTION); // for an other member function