The MorphBox class gives you access to morph boxes in PRIMER. More...
The PRIMER JavaScript API provides many class constants, properties and methods. For Arup to
be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase
or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you
should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your
own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:
| Name | Type | Description |
| exists (read only) | logical | true if box exists, false if referred to but not defined. |
| include | integer | The Include file number that the box is in. |
| label | integer | MorphBox number. |
| model (read only) | integer | The Model number that the box is in. |
| nx (read only) | integer | Number of morph points in parametric X direction |
| ny (read only) | integer | Number of morph points in parametric Y direction |
| nz (read only) | integer | Number of morph points in parametric Z direction |
| setid (read only) | integer | ID for node set of nodes dragged with the box. This will be a *SET_NODE_COLUMN containing the nodes together with their parametric coordinates in X, Y, Z. It is strongly discouraged to edit the contents of this set or the column data manually. |
Detailed DescriptionThe MorphBox class allows you to create, modify and manipulate morph boxes. See the documentation below for more details. |
Constructornew MorphBox(Model[Model], label[integer], flag[Flag], options (optional)[object])DescriptionCreate a new MorphBox object around flagged items. |
Model that morph box will be created in
MorphBox number
Flag set on the entities (for example nodes, elements and/or parts) that you want to create the box around
Options to create the box.
Object has the following properties:
| Name | Type | Description |
| csys (optional) | integer | Coordinate system for local coordinates. Leave undefined if using global coordinates or if local coordinate system defined with n1, n2 and n3. |
| n1 (optional) | integer | Node 1 label for local coordinate. Leave undefined if using global coordinates or if local coordinate system defined with csys. |
| n2 (optional) | integer | Node 2 label for local coordinate. Leave undefined if using global coordinates or if local coordinate system defined with csys. |
| n3 (optional) | integer | Node 3 label for local coordinate. Leave undefined if using global coordinates or if local coordinate system defined with csys. |
| nx (optional) | integer | Number of points in X direction of box (assumed to be 2 for linear box if omitted) |
| ny (optional) | integer | Number of points in Y direction of box (assumed to be 2 for linear box if omitted) |
| nz (optional) | integer | Number of points in Z direction of box (assumed to be 2 for linear box if omitted) |
| points (optional) | Array of integers | Array of integers of depth 3 containing the morph point IDs. This should be omitted in the (default) case of also creating new morph points together with the morph box at the locations based on the bounding box of the flagged items. If this array contains 'nx' by 'ny' by 'nz' existing morph points, the morph box is attached to these points, and 'csys', 'n1', 'n2', 'n3' will be irrelevant. Each 'points[i][j][k]' should contain the morph point ID to be added at index i in local X direction, index j in local Y direction and index k in local Z direction. The box will then still contain flagged nodes only, but nodes geometrically outside the volume of the morph points will not be included either. |
ReturnsMorphBox object Return typeMorphBox |
If model should be redrawn or not. If omitted redraw is false. If you want to apply the morphing to several boxes and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using Model.UpdateGraphics().
ReturnsNo return value |
ExampleTo calculate all global X, Y and Z coordinates for the morphed nodes for box b: b.ApplyMorphing();
|
AssociateComment(Comment[Comment])DescriptionAssociates a comment with a box. |
Comment that will be attached to the box
ReturnsNo return value |
ExampleTo associate comment c to the box b: b.AssociateComment(c);
|
Blank()DescriptionBlanks the box |
No arguments
ReturnsNo return value |
ExampleTo blank box b: b.Blank();
|
BlankAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionBlanks all of the boxs in the model. |
Model that all boxs will be blanked in
If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().
ReturnsNo return value |
ExampleTo blank all of the boxs in model m: MorphBox.BlankAll(m);
|
BlankFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionBlanks all of the flagged boxs in the model. |
Model that all the flagged boxs will be blanked in
Flag set on the boxs that you want to blank
If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().
ReturnsNo return value |
ExampleTo blank all of the boxs in model m flagged with f: MorphBox.BlankFlagged(m, f);
|
Blanked()DescriptionChecks if the box is blanked or not. |
No arguments
Returnstrue if blanked, false if not. Return typeBoolean |
ExampleTo check if box b is blanked: if (b.Blanked() ) do_something...
|
ClearFlag(flag[Flag])DescriptionClears a flag on the box. |
Flag to clear on the box
ReturnsNo return value |
ExampleTo clear flag f for box b: b.ClearFlag(f);
|
Copy(range (optional)[boolean])DescriptionCopies the box. The target include of the copied box can be set using Options.copy_target_include. |
If you want to keep the copied item in the range specified for the current include. Default value is false. To set current include, use Include.MakeCurrentLayer().
ReturnsMorphBox object Return typeMorphBox |
ExampleTo copy box b into box z: var z = b.Copy();
|
DetachComment(Comment[Comment])DescriptionDetaches a comment from a box. |
Comment that will be detached from the box
ReturnsNo return value |
ExampleTo detach comment c from the box b: b.DetachComment(c);
|
Error(message[string], details (optional)[string])DescriptionAdds an error for box. For more details on checking see the Check class. |
The error message to give
An optional detailed error message
ReturnsNo return value |
ExampleTo add an error message "My custom error" for box b: b.Error("My custom error");
|
First(Model[Model]) [static]DescriptionReturns the first box in the model. |
Model to get first box in
ReturnsMorphBox object (or null if there are no boxs in the model). Return typeMorphBox |
ExampleTo get the first box in model m: var b = MorphBox.First(m);
|
FirstFreeLabel(Model[Model], layer (optional)[Include number]) [static]DescriptionReturns the first free box label in the model. Also see MorphBox.LastFreeLabel(), MorphBox.NextFreeLabel() and Model.FirstFreeItemLabel(). |
Model to get first free box label in
Include file (0 for the main file) to search for labels in (Equivalent to First free in layer in editing panels). If omitted the whole model will be used (Equivalent to First free in editing panels).
ReturnsMorphBox label. Return typeNumber |
ExampleTo get the first free box label in model m: var label = MorphBox.FirstFreeLabel(m);
|
FlagAll(Model[Model], flag[Flag]) [static]DescriptionFlags all of the boxs in the model with a defined flag. |
Model that all boxs will be flagged in
Flag to set on the boxs
ReturnsNo return value |
ExampleTo flag all of the boxs with flag f in model m: MorphBox.FlagAll(m, f);
|
FlagAllMorphedConnections(model[Model], flag[integer]) [static]DescriptionFlags all connections, in a given model, that have been morphed since their last remake. This includes connections that have been morphed by a morph box that has since been deleted. |
Model containing desired connections.
Flag to mark morphed connections.
Returnstrue if successful, false if not. Return typeBoolean |
ExampleTo flag all morphed connections in Model m with flag. var flag = AllocateFlag(); MorphBox.FlagAllMorphedConnections(m, flag);
|
Flag to mark morphed connections.
Returnstrue if successful, false if not. Return typeBoolean |
ExampleTo flag all morphed connections in a MorphBox with flag. var flag = AllocateFlag(); box.FlagMorphedConnections(flag);
|
Flagged(flag[Flag])DescriptionChecks if the box is flagged or not. |
Flag to test on the box
Returnstrue if flagged, false if not. Return typeBoolean |
ExampleTo check if box b has flag f set on it: if (b.Flagged(f) ) do_something...
|
ForEach(Model[Model], func[function], extra (optional)[any]) [static]DescriptionCalls a function for each box in the model. |
Model that all boxs are in
Function to call for each box
An optional extra object/array/string etc that will appended to arguments when calling the function
ReturnsNo return value |
GetAll(Model[Model], property (optional)[string]) [static]DescriptionReturns an array of MorphBox objects or properties for all of the boxs in a model in PRIMER. If the optional property argument is not given then an array of MorphBox objects is returned. If the property argument is given, that property value for each box is returned in the array instead of a MorphBox object |
Model to get boxs from
Name for property to get for all boxs in the model
ReturnsArray of MorphBox objects or properties Return typeArray |
GetComments()DescriptionExtracts the comments associated to a box. |
No arguments
ReturnsArray of Comment objects (or null if there are no comments associated to the node). Return typeArray |
ExampleTo get the array of comments associated to the box b: var comm_array = b.GetComments();
|
GetFlagged(Model[Model], flag[Flag], property (optional)[string]) [static]DescriptionReturns an array of MorphBox objects for all of the flagged boxs in a model in PRIMER If the optional property argument is not given then an array of MorphBox objects is returned. If the property argument is given, then that property value for each box is returned in the array instead of a MorphBox object |
Model to get boxs from
Flag set on the boxs that you want to retrieve
Name for property to get for all flagged boxs in the model
ReturnsArray of MorphBox objects or properties Return typeArray |
GetFromID(Model[Model], number[integer]) [static]DescriptionReturns the MorphBox object for a box ID. |
Model to find the box in
number of the box you want the MorphBox object for
ReturnsMorphBox object (or null if box does not exist). Return typeMorphBox |
ExampleTo get the MorphBox object for box 100 in model m var b = MorphBox.GetFromID(m, 100);
|
GetParameter(prop[string])DescriptionChecks if a MorphBox property is a parameter or not. Note that object properties that are parameters are normally returned as the integer or float parameter values as that is virtually always what the user would want. For this function to work the JavaScript interpreter must use the parameter name instead of the value. This can be done by setting the Options.property_parameter_names option to true before calling the function and then resetting it to false afterwards.. This behaviour can also temporarily be switched by using the MorphBox.ViewParameters() method and 'method chaining' (see the examples below). |
box property to get parameter for
ReturnsParameter object if property is a parameter, null if not. Return typeParameter |
GetPoint(xindex[integer], yindex[integer], zindex[integer])DescriptionReturns the morph point ID on the morph box at indices in X, Y and Z directions. |
Index of the point in X direction. Note that indices start at 0, so it should be 0 for the points with the smallest parameteric X coordinate and box.nx-1 for the points with the highest X.
Index of the point in Y direction. Note that indices start at 0, so it should be 0 for the points with the smallest parameteric Y coordinate and box.ny-1 for the points with the highest Y.
Index of the point in Z direction. Note that indices start at 0, so it should be 0 for the points with the smallest parameteric Z coordinate and box.nz-1 for the points with the highest Z.
ReturnsA MorphPoint object for the point on the box at given indices. Return typeMorphPoint |
ExampleTo get the 2nd point on the edge along the local Y direction and at highest local X and lowest local Z coordinate: var point = box.GetPoint(box.nx-1, 1, 0);
|
Keyword()DescriptionReturns the keyword for this morph box (*MORPH_BOX or *MORPH_BOX_HIGH_ORDER). Note that a carriage return is not added. See also MorphBox.KeywordCards() |
No arguments
Returnsstring containing the keyword. Return typeString |
ExampleTo get the keyword for morph box b: var key = b.Keyword();
|
KeywordCards()DescriptionReturns the keyword cards for the morph box. Note that a carriage return is not added. See also MorphBox.Keyword() |
No arguments
Returnsstring containing the cards. Return typeString |
ExampleTo get the cards for morph box b: var cards = b.KeywordCards();
|
Last(Model[Model]) [static]DescriptionReturns the last box in the model. |
Model to get last box in
ReturnsMorphBox object (or null if there are no boxs in the model). Return typeMorphBox |
ExampleTo get the last box in model m: var b = MorphBox.Last(m);
|
LastFreeLabel(Model[Model], layer (optional)[Include number]) [static]DescriptionReturns the last free box label in the model. Also see MorphBox.FirstFreeLabel(), MorphBox.NextFreeLabel() and see Model.LastFreeItemLabel() |
Model to get last free box label in
Include file (0 for the main file) to search for labels in (Equivalent to Highest free in layer in editing panels). If omitted the whole model will be used.
ReturnsMorphBox label. Return typeNumber |
ExampleTo get the last free box label in model m: var label = MorphBox.LastFreeLabel(m);
|
Next()DescriptionReturns the next box in the model. |
No arguments
ReturnsMorphBox object (or null if there are no more boxs in the model). Return typeMorphBox |
ExampleTo get the box in model m after box b: var b = b.Next();
|
NextFreeLabel(Model[Model], layer (optional)[Include number]) [static]DescriptionReturns the next free (highest+1) box label in the model. Also see MorphBox.FirstFreeLabel(), MorphBox.LastFreeLabel() and Model.NextFreeItemLabel() |
Model to get next free box label in
Include file (0 for the main file) to search for labels in (Equivalent to Highest+1 in layer in editing panels). If omitted the whole model will be used (Equivalent to Highest+1 in editing panels).
ReturnsMorphBox label. Return typeNumber |
ExampleTo get the next free box label in model m: var label = MorphBox.NextFreeLabel(m);
|
Pick(prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean], button text (optional)[string]) [static]DescriptionAllows the user to pick a box. |
Text to display as a prompt to the user
If the argument is a Model then only boxs from that model can be picked. If the argument is a Flag then only boxs that are flagged with limit can be selected. If omitted, or null, any boxs from any model can be selected. from any model.
If picking is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the pick will be modal.
By default the window with the prompt will have a button labelled 'Cancel' which if pressed will cancel the pick and return null. If you want to change the text on the button use this argument. If omitted 'Cancel' will be used.
ReturnsMorphBox object (or null if not picked) Return typeMorphBox |
ExampleTo pick a box from model m giving the prompt 'Pick box from screen': var b = MorphBox.Pick('Pick box from screen', m);
|
Previous()DescriptionReturns the previous box in the model. |
No arguments
ReturnsMorphBox object (or null if there are no more boxs in the model). Return typeMorphBox |
ExampleTo get the box in model m before box b: var b = b.Previous();
|
RenumberAll(Model[Model], start[integer]) [static]DescriptionRenumbers all of the boxs in the model. |
Model that all boxs will be renumbered in
Start point for renumbering
ReturnsNo return value |
ExampleTo renumber all of the boxs in model m, from 1000000: MorphBox.RenumberAll(m, 1000000);
|
RenumberFlagged(Model[Model], flag[Flag], start[integer]) [static]DescriptionRenumbers all of the flagged boxs in the model. |
Model that all the flagged boxs will be renumbered in
Flag set on the boxs that you want to renumber
Start point for renumbering
ReturnsNo return value |
ExampleTo renumber all of the boxs in model m flagged with f, from 1000000: MorphBox.RenumberFlagged(m, f, 1000000);
|
Reset(redraw (optional)[boolean])DescriptionResets the morph box to its initial position and updates the coordinates of all its nodes. |
If model should be redrawn or not. If omitted redraw is false. If you want to reset several boxes and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using Model.UpdateGraphics().
ReturnsNo return value |
ExampleTo reset box b: b.Reset();
|
Select(flag[Flag], prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean]) [static]DescriptionAllows the user to select boxs using standard PRIMER object menus. |
Flag to use when selecting boxs
Text to display as a prompt to the user
If the argument is a Model then only boxs from that model can be selected. If the argument is a Flag then only boxs that are flagged with limit can be selected (limit should be different to flag). If omitted, or null, any boxs can be selected. from any model.
If selection is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the selection will be modal.
ReturnsNumber of boxs selected or null if menu cancelled Return typeNumber |
SetFlag(flag[Flag])DescriptionSets a flag on the box. |
Flag to set on the box
ReturnsNo return value |
ExampleTo set flag f for box b: b.SetFlag(f);
|
SetMorphConnections(status[boolean]) [static]DescriptionTurns Morph Connections on/off. |
true turns Morph Connections on. false turns Morph Connections off.
ReturnsNo return value. |
ExampleTo turn Morph Connections on. MorphBox.SetMorphConnections(true);
|
Index of the point in X direction. Note that indices start at 0, so it should be 0 for the points with the smallest parameteric X coordinate and box.nx-1 for the points with the highest X.
Index of the point in Y direction. Note that indices start at 0, so it should be 0 for the points with the smallest parameteric Y coordinate and box.ny-1 for the points with the highest Y.
Index of the point in Z direction. Note that indices start at 0, so it should be 0 for the points with the smallest parameteric Z coordinate and box.nz-1 for the points with the highest Z.
New MorphPoint id.
ReturnsNo return value |
ExampleTo replace the 2nd point on the edge along the local X direction and at lowest local Y and highest local Z coordinate with point 101: box.SetPointID(1, 0, box.nz-1, 101);
|
Sketch(redraw (optional)[boolean])DescriptionSketches the box. The box will be sketched until you either call MorphBox.Unsketch(), MorphBox.UnsketchAll(), Model.UnsketchAll(), or delete the model |
If model should be redrawn or not after the box is sketched. If omitted redraw is true. If you want to sketch several boxs and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo sketch box b: b.Sketch();
|
SketchFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionSketches all of the flagged boxs in the model. The boxs will be sketched until you either call MorphBox.Unsketch(), MorphBox.UnsketchFlagged(), Model.UnsketchAll(), or delete the model |
Model that all the flagged boxs will be sketched in
Flag set on the boxs that you want to sketch
If model should be redrawn or not after the boxs are sketched. If omitted redraw is true. If you want to sketch flagged boxs several times and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo sketch all boxs flagged with flag in model m: MorphBox.SketchFlagged(m, flag);
|
Total(Model[Model], exists (optional)[boolean]) [static]DescriptionReturns the total number of boxs in the model. |
Model to get total for
true if only existing boxs should be counted. If false or omitted referenced but undefined boxs will also be included in the total.
Returnsnumber of boxs Return typeNumber |
ExampleTo get the total number of boxs in model m: var total = MorphBox.Total(m);
|
Unblank()DescriptionUnblanks the box |
No arguments
ReturnsNo return value |
ExampleTo unblank box b: b.Unblank();
|
UnblankAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionUnblanks all of the boxs in the model. |
Model that all boxs will be unblanked in
If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().
ReturnsNo return value |
ExampleTo unblank all of the boxs in model m: MorphBox.UnblankAll(m);
|
UnblankFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionUnblanks all of the flagged boxs in the model. |
Model that the flagged boxs will be unblanked in
Flag set on the boxs that you want to unblank
If model should be redrawn or not. If omitted redraw is false. If you want to do several (un)blanks and only redraw after the last one then use false for all redraws apart from the last one. Alternatively you can redraw using View.Redraw().
ReturnsNo return value |
ExampleTo unblank all of the boxs in model m flagged with f: MorphBox.UnblankFlagged(m, f);
|
UnflagAll(Model[Model], flag[Flag]) [static]DescriptionUnsets a defined flag on all of the boxs in the model. |
Model that the defined flag for all boxs will be unset in
Flag to unset on the boxs
ReturnsNo return value |
ExampleTo unset the flag f on all the boxs in model m: MorphBox.UnflagAll(m, f);
|
Unsketch(redraw (optional)[boolean])DescriptionUnsketches the box. |
If model should be redrawn or not after the box is unsketched. If omitted redraw is true. If you want to unsketch several boxs and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo unsketch box b: b.Unsketch();
|
UnsketchAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionUnsketches all boxs. |
Model that all boxs will be unblanked in
If model should be redrawn or not after the boxs are unsketched. If omitted redraw is true. If you want to unsketch several things and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo unsketch all boxs in model m: MorphBox.UnsketchAll(m);
|
UnsketchFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionUnsketches all flagged boxs in the model. |
Model that all boxs will be unsketched in
Flag set on the boxs that you want to unsketch
If model should be redrawn or not after the boxs are unsketched. If omitted redraw is true. If you want to unsketch several things and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo unsketch all boxs flagged with flag in model m: MorphBox.UnsketchAll(m, flag);
|
UpdateParametricCoordinates()DescriptionRecalculates parametric X, Y, Z coordinates for each node in the *SET_NODE_COLUMN associated with the morph box. This needs to be called whenever morph points on the box or their coordinates have been changed manually and you wish to keep all nodes at their intrinsic global X, Y, Z coordinates. Provided Morph Connections is on (see MorphBox.SetMorphConnections()), this will also force PRIMER to recalculate the parametric coordinates for any connections in the morph box next time one of its morph points is moved. |
No arguments
ReturnsNo return value |
ExampleTo recalculate all X, Y and Z coordinates for box b: b.UpdateParametricCoordinates();
|
No arguments
ReturnsMorphBox object. Return typeMorphBox |
ExampleTo check if MorphBox property b.example is a parameter by using the MorphBox.GetParameter() method: if (b.ViewParameters().GetParameter(b.example) ) do_something...
|
Warning(message[string], details (optional)[string])DescriptionAdds a warning for box. For more details on checking see the Check class. |
The warning message to give
An optional detailed warning message
ReturnsNo return value |
ExampleTo add a warning message "My custom warning" for box b: b.Warning("My custom warning");
|
Xrefs()DescriptionReturns the cross references for this box. |
No arguments
ReturnsXrefs object. Return typeXrefs |
ExampleTo get the cross references for box b: var xrefs = b.Xrefs();
|
toString()DescriptionCreates a string containing the morph box data in keyword format. Note that this contains the keyword header and the keyword cards. See also MorphBox.Keyword() and MorphBox.KeywordCards(). |
No arguments
Returnsstring Return typeString |
ExampleTo get data for morph box b in keyword format var s = b.toString();
|