Creating Objects Using the new Keyword

You can create objects using the new function.

This page discusses:

new

Enables to create objects based upon the object's type name. This generic creation function is implemented on object types you can get using the autocomplete capability.

  • 3D Part, 3D Shape, Product Reference, Drawing in Product Structure domain
  • Functional Reference, Logical Reference and Logical Port in functional/logical domain
  • Geometric datum of following types (Curve, Surface, Point, Plane, Line, Circle)
  • VolatileInstance: an object that is local to the rule (with no persistency) enabling to hold attributes added dynamically with SetAttribute methods. It is used to create dialogs.
Note: This function works at runtime if you are granted the appropriate license only.

Signature

new(type: String, name: String, father: ObjectType [, freeArguments: ObjectType, ..]) : UndefinedType

Arguments

NameInput / OutputRequired?TypeComment
typeInYesStringDefines what kind of object has to be created. It is a mandatory argument. The list of possible values comprise the following ones:
  • 3DPart, 3DShape, VPMReference, Drawing
  • RFLVPMLogicalReference, RFLPLMFunctionalReference, RFLVPMLogicalPort
  • Curve, Surface, Point, Plane, Line, Circle, VolatileInstance, and VolumeGeo
Note: If you provide a wrong type name, an evaluation error is raised (Error in the function new: first argument <type> is not an existing type) and the function returns a NULL value. If you provide a type that cannot be instantiated, an evaluation error is raised (Error in the function new: first argument <type> is not a type that can be instantiated) and the function returns a NULL value.
nameInYesStringPrecises the name of the created object. If this area is left blank, the system automatically computes a default name.
fatherInYesObjectTypeObject where the new object is to be aggregated. It is not always mandatory. When a Father is set, the result of the New is an Instance for PLM objects. When the father is unset, the result of the New is a Reference for PLM objects.
Note: If a Father is precised, and if it already aggregates an object with the same name, the New method will not create another object. It simply returns the object.

Important: In case you try to aggregate an object under another one which does not support it, an evaluation error is raised (Error in the function new: impossible to create an object of type <type>under the object <father> of type <fatherType>).

This function returns a NULL value.

Important: Important: In case you try to aggregate an object under another one which does not support it, an evaluation error is raised (Error in the function new: impossible to create an object of type <type>under the object <father> of type <fatherType>). This function returns a NULL value.
freeArgumentsInNoObjectType-

ReturnType

UndefinedType

Example

let x(VPMReference)
x = new ("VPMReference","MyReference",NULL) /* creates a new VPMReference */