The MorphFlow class gives you access to morph flows 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 flow exists, false if referred to but not defined. |
| include | integer | The Include file number that the flow is in. |
| max | real | Maximum value for type set to "CONTINUOUS" or "STEP" when written as design variable for LS-OPT. |
| min | real | Minimum value for type set to "CONTINUOUS" or "STEP" when written as design variable for LS-OPT. |
| model (read only) | integer | The Model number that the flow is in. |
| name | string | Name of the morph flow. If the flow is used for applying LS-OPT variables, this should match the variable name in the listing file written by LS-OPT. |
| npoints (read only) | integer | Number of morph points referenced by the flow. |
| nvals (read only) | integer | Number of values in the list when type is set to "DISCRETE". |
| step | real | Step size for type set to "STEP" when written as design variable for LS-OPT. |
| type | string | Range type for the morph flow. This should be "CONTINUOUS", "STEP" or "DISCRETE" and may be used for LS-OPT when writing design variable files from morph flows. |
Detailed DescriptionThe MorphFlow class allows you to create, modify and manipulate morph flows. See the documentation below for more details. |
Constructornew MorphFlow(Model[Model], name[string])DescriptionCreate a new MorphFlow object. |
Model that morph flow will be created in
MorphFlow name
ReturnsMorphFlow object Return typeMorphFlow |
ExampleTo create a new (empty) morph flow in model m with name 'depth' var f = new MorphFlow(m, "depth");
|
Details of functionsAssociateComment(Comment[Comment])DescriptionAssociates a comment with a flow. |
Comment that will be attached to the flow
ReturnsNo return value |
ExampleTo associate comment c to the flow flow: flow.AssociateComment(c);
|
Blank()DescriptionBlanks the flow |
No arguments
ReturnsNo return value |
ExampleTo blank flow flow: flow.Blank();
|
BlankAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionBlanks all of the flows in the model. |
Model that all flows 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 flows in model m: MorphFlow.BlankAll(m);
|
BlankFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionBlanks all of the flagged flows in the model. |
Model that all the flagged flows will be blanked in
Flag set on the flows 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 flows in model m flagged with f: MorphFlow.BlankFlagged(m, f);
|
Blanked()DescriptionChecks if the flow is blanked or not. |
No arguments
Returnstrue if blanked, false if not. Return typeBoolean |
ExampleTo check if flow flow is blanked: if (flow.Blanked() ) do_something...
|
Browse(modal (optional)[boolean])DescriptionStarts an edit panel in Browse mode. |
If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.
Returnsno return value |
ExampleTo Browse flow flow: flow.Browse();
|
ClearFlag(flag[Flag])DescriptionClears a flag on the flow. |
Flag to clear on the flow
ReturnsNo return value |
ExampleTo clear flag f for flow flow: flow.ClearFlag(f);
|
Copy(range (optional)[boolean])DescriptionCopies the flow. The target include of the copied flow 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().
ReturnsMorphFlow object Return typeMorphFlow |
ExampleTo copy flow flow into flow z: var z = flow.Copy();
|
Create(Model[Model], modal (optional)[boolean]) [static]DescriptionStarts an interactive editing panel to create a flow |
Model that the flow will be created in.
If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.
ReturnsMorphFlow object (or null if not made). Return typeMorphFlow |
ExampleTo start creating a flow in model m: var flow = MorphFlow.Create(m);
|
DetachComment(Comment[Comment])DescriptionDetaches a comment from a flow. |
Comment that will be detached from the flow
ReturnsNo return value |
ExampleTo detach comment c from the flow flow: flow.DetachComment(c);
|
Edit(modal (optional)[boolean])DescriptionStarts an interactive editing panel. |
If this window is modal (blocks the user from doing anything else in PRIMER until this window is dismissed). If omitted the window will be modal.
Returnsno return value |
ExampleTo Edit flow flow: flow.Edit();
|
Error(message[string], details (optional)[string])DescriptionAdds an error for flow. 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 flow flow: flow.Error("My custom error");
|
First(Model[Model]) [static]DescriptionReturns the first flow in the model. |
Model to get first flow in
ReturnsMorphFlow object (or null if there are no flows in the model). Return typeMorphFlow |
ExampleTo get the first flow in model m: var flow = MorphFlow.First(m);
|
FlagAll(Model[Model], flag[Flag]) [static]DescriptionFlags all of the flows in the model with a defined flag. |
Model that all flows will be flagged in
Flag to set on the flows
ReturnsNo return value |
ExampleTo flag all of the flows with flag f in model m: MorphFlow.FlagAll(m, f);
|
Flagged(flag[Flag])DescriptionChecks if the flow is flagged or not. |
Flag to test on the flow
Returnstrue if flagged, false if not. Return typeBoolean |
ExampleTo check if flow flow has flag f set on it: if (flow.Flagged(f) ) do_something...
|
ForEach(Model[Model], func[function], extra (optional)[any]) [static]DescriptionCalls a function for each flow in the model. |
Model that all flows are in
Function to call for each flow
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 MorphFlow objects or properties for all of the flows in a model in PRIMER. If the optional property argument is not given then an array of MorphFlow objects is returned. If the property argument is given, that property value for each flow is returned in the array instead of a MorphFlow object |
Model to get flows from
Name for property to get for all flows in the model
ReturnsArray of MorphFlow objects or properties Return typeArray |
GetComments()DescriptionExtracts the comments associated to a flow. |
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 flow flow: var comm_array = flow.GetComments();
|
GetFlagged(Model[Model], flag[Flag], property (optional)[string]) [static]DescriptionReturns an array of MorphFlow objects for all of the flagged flows in a model in PRIMER If the optional property argument is not given then an array of MorphFlow objects is returned. If the property argument is given, then that property value for each flow is returned in the array instead of a MorphFlow object |
Model to get flows from
Flag set on the flows that you want to retrieve
Name for property to get for all flagged flows in the model
ReturnsArray of MorphFlow objects or properties Return typeArray |
GetFromID(Model[Model], number[integer]) [static]DescriptionReturns the MorphFlow object for a flow ID. |
Model to find the flow in
number of the flow you want the MorphFlow object for
ReturnsMorphFlow object (or null if flow does not exist). Return typeMorphFlow |
ExampleTo get the MorphFlow object for flow 100 in model m var flow = MorphFlow.GetFromID(m, 100);
|
GetFromName(Model[Model], morph flow name[string]) [static]DescriptionReturns the stored MorphFlow object for a morph flow name. WARNING: This assumes that there is at most one morph flow with a given name. Otherwise this function only returns the first occurrence. |
Model to find the morph flow in
name of the morph flow you want the MorphFlow object for
ReturnsMorphFlow object (or null if morph flow does not exist). Return typeMorphFlow |
ExampleTo get the MorphFlow object for flow "depth" in model m var f = MorphFlow.GetFromName(m, "depth");
|
GetParameter(prop[string])DescriptionChecks if a MorphFlow 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 MorphFlow.ViewParameters() method and 'method chaining' (see the examples below). |
flow property to get parameter for
ReturnsParameter object if property is a parameter, null if not. Return typeParameter |
GetRow(row[integer])DescriptionReturns the data for a row in the morph flow. |
The row you want the data for. Note row indices start at 0.
ReturnsAn array of numbers containing the morph point ID at index 0 and the vector components at indices 1, 2, 3. Return typeNumber |
ExampleTo get the data for the 2nd row in morph flow f: var data = f.GetRow(1); var point_id = data[0]; var dx = data[1]; var dy = data[2]; var dz = data[3];
|
GetValue(index[integer])DescriptionGet the value at given index on the morph flow with type "DISCRETE". |
The index where you are extracting the value. Note row indices start at 0.
Returnsreal Return typeNumber |
ExampleTo get the 2nd value for morph flow f with type "DISCRETE": var value = f.GetValue(1); To get the last value on the list of values on f: var value = f.GetValue(f.nvals - 1);
|
Keyword()DescriptionReturns the keyword for this morph flow (*MORPH_FLOW). Note that a carriage return is not added. See also MorphFlow.KeywordCards() |
No arguments
Returnsstring containing the keyword. Return typeString |
ExampleTo get the keyword for morph flow f: var key = f.Keyword();
|
KeywordCards()DescriptionReturns the keyword cards for the morph flow. Note that a carriage return is not added. See also MorphFlow.Keyword() |
No arguments
Returnsstring containing the cards. Return typeString |
ExampleTo get the cards for morph flow f: var cards = f.KeywordCards();
|
Last(Model[Model]) [static]DescriptionReturns the last flow in the model. |
Model to get last flow in
ReturnsMorphFlow object (or null if there are no flows in the model). Return typeMorphFlow |
ExampleTo get the last flow in model m: var flow = MorphFlow.Last(m);
|
Next()DescriptionReturns the next flow in the model. |
No arguments
ReturnsMorphFlow object (or null if there are no more flows in the model). Return typeMorphFlow |
ExampleTo get the flow in model m after flow flow: var flow = flow.Next();
|
Pick(prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean], button text (optional)[string]) [static]DescriptionAllows the user to pick a flow. |
Text to display as a prompt to the user
If the argument is a Model then only flows from that model can be picked. If the argument is a Flag then only flows that are flagged with limit can be selected. If omitted, or null, any flows 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.
ReturnsMorphFlow object (or null if not picked) Return typeMorphFlow |
ExampleTo pick a flow from model m giving the prompt 'Pick flow from screen': var flow = MorphFlow.Pick('Pick flow from screen', m);
|
Previous()DescriptionReturns the previous flow in the model. |
No arguments
ReturnsMorphFlow object (or null if there are no more flows in the model). Return typeMorphFlow |
ExampleTo get the flow in model m before flow flow: var flow = flow.Previous();
|
RemoveRow(row[integer])DescriptionRemoves the data (a morph point ID and its three vector components) for a row in *MORPH_FLOW. |
The row you want to remove the data for. Note that row indices start at 0.
ReturnsNo return value. |
ExampleTo remove the second row of data for morph flow f: f.RemoveRow(1);
|
RemoveValue(index[integer])DescriptionRemoves the value at given index in *MORPH_FLOW with type "DISCRETE". |
The index where you are removing the value. Note that indices start at 0.
ReturnsNo return value. |
ExampleTo remove the second value for morph flow f: f.RemoveValue(1); To remove the last value for f: f.RemoveValue(f.nvals - 1);
|
Select(flag[Flag], prompt[string], limit (optional)[Model or Flag], modal (optional)[boolean]) [static]DescriptionAllows the user to select flows using standard PRIMER object menus. |
Flag to use when selecting flows
Text to display as a prompt to the user
If the argument is a Model then only flows from that model can be selected. If the argument is a Flag then only flows that are flagged with limit can be selected (limit should be different to flag). If omitted, or null, any flows 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 flows selected or null if menu cancelled Return typeNumber |
SetFlag(flag[Flag])DescriptionSets a flag on the flow. |
Flag to set on the flow
ReturnsNo return value |
ExampleTo set flag f for flow flow: flow.SetFlag(f);
|
SetRow(row[integer], data[Array of data])DescriptionSets the data for a row in *MORPH_FLOW. |
The row you want to set the data for. Note that row indices start at 0.
The data you want to set the row to. It should be of length 4 having the morph point ID at index 0, and the vector components at indices 1, 2, 3.
ReturnsNo return value. |
SetValue(index[integer], value[real])DescriptionSets the value at given index in a *MORPH_FLOW with type "DISCRETE". |
The row you want to set the data for. Note that row indices start at 0.
The new value to insert into the list.
ReturnsNo return value. |
ExampleTo set the second value morph flow f to 20.0: f.SetValue(1, 20.0); To append the value 20.0 to the end of the list: f.SetValue(f.nvals, 20.0);
|
Sketch(redraw (optional)[boolean])DescriptionSketches the flow. The flow will be sketched until you either call MorphFlow.Unsketch(), MorphFlow.UnsketchAll(), Model.UnsketchAll(), or delete the model |
If model should be redrawn or not after the flow is sketched. If omitted redraw is true. If you want to sketch several flows and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo sketch flow flow: flow.Sketch();
|
SketchFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionSketches all of the flagged flows in the model. The flows will be sketched until you either call MorphFlow.Unsketch(), MorphFlow.UnsketchFlagged(), Model.UnsketchAll(), or delete the model |
Model that all the flagged flows will be sketched in
Flag set on the flows that you want to sketch
If model should be redrawn or not after the flows are sketched. If omitted redraw is true. If you want to sketch flagged flows several times and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo sketch all flows flagged with flag in model m: MorphFlow.SketchFlagged(m, flag);
|
Total(Model[Model], exists (optional)[boolean]) [static]DescriptionReturns the total number of flows in the model. |
Model to get total for
true if only existing flows should be counted. If false or omitted referenced but undefined flows will also be included in the total.
Returnsnumber of flows Return typeNumber |
ExampleTo get the total number of flows in model m: var total = MorphFlow.Total(m);
|
Unblank()DescriptionUnblanks the flow |
No arguments
ReturnsNo return value |
ExampleTo unblank flow flow: flow.Unblank();
|
UnblankAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionUnblanks all of the flows in the model. |
Model that all flows 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 flows in model m: MorphFlow.UnblankAll(m);
|
UnblankFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionUnblanks all of the flagged flows in the model. |
Model that the flagged flows will be unblanked in
Flag set on the flows 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 flows in model m flagged with f: MorphFlow.UnblankFlagged(m, f);
|
UnflagAll(Model[Model], flag[Flag]) [static]DescriptionUnsets a defined flag on all of the flows in the model. |
Model that the defined flag for all flows will be unset in
Flag to unset on the flows
ReturnsNo return value |
ExampleTo unset the flag f on all the flows in model m: MorphFlow.UnflagAll(m, f);
|
Unsketch(redraw (optional)[boolean])DescriptionUnsketches the flow. |
If model should be redrawn or not after the flow is unsketched. If omitted redraw is true. If you want to unsketch several flows and only redraw after the last one then use false for redraw and call View.Redraw().
ReturnsNo return value |
ExampleTo unsketch flow flow: flow.Unsketch();
|
UnsketchAll(Model[Model], redraw (optional)[boolean]) [static]DescriptionUnsketches all flows. |
Model that all flows will be unblanked in
If model should be redrawn or not after the flows 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 flows in model m: MorphFlow.UnsketchAll(m);
|
UnsketchFlagged(Model[Model], flag[Flag], redraw (optional)[boolean]) [static]DescriptionUnsketches all flagged flows in the model. |
Model that all flows will be unsketched in
Flag set on the flows that you want to unsketch
If model should be redrawn or not after the flows 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 flows flagged with flag in model m: MorphFlow.UnsketchAll(m, flag);
|
No arguments
ReturnsMorphFlow object. Return typeMorphFlow |
ExampleTo check if MorphFlow property flow.example is a parameter by using the MorphFlow.GetParameter() method: if (flow.ViewParameters().GetParameter(flow.example) ) do_something...
|
Warning(message[string], details (optional)[string])DescriptionAdds a warning for flow. 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 flow flow: flow.Warning("My custom warning");
|
Xrefs()DescriptionReturns the cross references for this flow. |
No arguments
ReturnsXrefs object. Return typeXrefs |
ExampleTo get the cross references for flow flow: var xrefs = flow.Xrefs();
|
toString()DescriptionCreates a string containing the morph flow data in keyword format. Note that this contains the keyword header and the keyword cards. See also MorphFlow.Keyword() and MorphFlow.KeywordCards(). |
No arguments
Returnsstring Return typeString |
ExampleTo get data for morph flow f in keyword format var s = f.toString();
|