Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2021.

Syntax

  • General syntax

    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.

    SXxxxx

    And Function names always begin with a capital letter.
    XxxxXxx()

    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



  • Functions

    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.

    • Global Functions

      You will encounter global function only in namespaces. Global functions are not attached to a class.

      GlobalFunction()

      So you can call them directly in your script. For instance:

      ClearDoc();



    • Static Functions

      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 ".".

      SClass.StaticFunction()

      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

      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 ".".

      variable.MemberFunction()

      For instance:

      var newPt = SPoint.New();
      var x = newPt.GetX(); // Valid syntax
      var x = SPoint.GetX(); // Invalid syntax


    • Return values

      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 :

      1. Return.ErrorCode : The error code, 0 on success
      2. Return.Multi : The output SMultiline, if any
      3. Return.Poly : The output SPoly, if any
      4. Return.Cloud : The output SCloud, if any
      5. Return.Matrix : The output SMatrix, if any
      6. Return.Circle : The output SCircle, if any
      7. Return.Plane : The output SPlane, if any
      8. Return.Point : The output SPoint, if any
      9. Return.Cylinder : The output SCylinder, if any
      10. Return.Vector : The output SVector, if any
      11. Return.MultiTbl : The output SMultiline array, if any
      12. Return.PolyTbl : The output SPoly array, if any
      13. Return.CloudTbl : The output SCloud array, if any
      14. Return.MatrixTbl : The output SMatrix array, if any
      15. Return.CircleTbl : The output SCircle array, if any
      16. Return.PlaneTbl : The output SPlane array, if any
      17. Return.PointTbl : The output SPoint array, if any

      ... and more, check the documentation for more details.



  • Enumerations

    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.

    GlobalFunction(Enum)
    SClass.StaticFunction(SClass.Enum)
    variable.MemberFunction(SClass.Enum)

    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