Miscellaneous Functions
calculateNesting(op)
Given an operation on an Additive Manufacturing part, returns an object that represents the arrangement of parts nested on the build platform. This object has the following fields:
numberofPartsPerLayer: number of parts on the build platform, or (for DMLS), the number of parts in one layer of parts in the build chamber.
actualNestingLength: length of the portion of the build platform that is occupied by the nested parts.
actualNestingWidth: width of the portion of the build platform that is occupied by the nested parts.
This function returns a value for operations in both the Additive Manufacturing and Machining process groups.
dtcMessage(field-name-1, field-value-1, ... field-name-n, field-value-n)
This function should be used in conjunction with a CSL Advice construct, as described in Advice.
A call to the function creates a dtcMessage object. When the cost engine evaluates the Advice construct that includes the call, it adds the created dtcMessage object to the list of dtcMessage objects associated with the current process routing. For a given costing, this list of dtcMessage objects for the selected routing determines the contents of many of the Design-to-Cost displays for Sheet Metal, Casting, and Plastic Molding.
The arguments specify the values of some of the fields of the created dtcMessage object. The arguments consist of alternating field names and field values. A field value argument specifies the value for the field named by the argument that precedes it. Here is a sample call to the function in the context of an Advice Rule and Advice construct:
AdviceRule holeToEdgeMessage: badHoleEdgeRelations <> null
Advice holeToEdgeMessage: dtcMessage(
'attributeId', 'dtcHoleAdvice.holeToEdgeAttribute',
'messageId', 'dtcHoleAdvice.holeToEdgeMessage',
'secondaryGcd', blankGcdKeyName,
'current', worstEdgeRelation.distance,
'suggestedMin', holeToBlankRecommendedProcess,
'unitType', DTC_LENGTH,
'custom.edgeList', listAsString(holeToEdgeNameListDistinct),
'category', DTC_PROXIMITY)
A field is either predefined or user-defined. The predefined fields are listed below. A user-defined field must have a name that starts with “custom.”, for example, “custom.msgTolType”.
The value of a predefined field is either user-specified or automatically-supplied. User-specified values are specified by arguments to the dtcMessage function. Values that are supplied automatically are based on the runtime context or on user-specified values for other fields.
Following are the predefined fields that are user-specified:
attributeId: string specifying the attribute or aspect of the current GCD that played a key role in triggering the associated advice rule or in causing the failure of the associated routing rule. This string is specified in one of two ways:
o Directly, as in 'Diameter' (for a rule that failed, for example, because the current GCD’s diameter is too small)
o Indirectly as a lookup key, such as 'dtcHoleAdvice.holeMinAttribute'. The key, prefixed with 'DtcMessages' (as in 'DtcMessages.dtcHoleAdvice.holeMinAttribute'), is used to look up a message in the properties file cmvMessages.properties.
The string specified by this field is used to populate the following elements of Design-to-Cost displays:
o Tolerance column on the Finishing Operations tab of the Tolerances and Special Finishing Operations dialog.
o Issue dropdown menu for the Casting Issues dialog (which appears when you click Review in the Casting section of the Design-to-Cost panel).
o Issue dropdown menu for the Plastic Issues dialog (which appears when you click Review in the Plastic Issues section of the Design-to-Cost panel).
o Sub-Type column for the Fabrication Issues dialog (which appears when you click Review in the Fabrication Issues section of the Sheet Metal Design-to-Cost panel).
messageId: string specifying the circumstances that triggered the associated advice rule or that caused the failure of the associated routing rule. This string is specified in one of two ways:
o Directly, as in 'Hole is too small' (for a rule that failed, for example, because the current GCD’s diameter is too small)
o Indirectly as a lookup key, such as 'dtcHoleAdvice.holeMinMessage'. The key, prefixed with 'DtcMessages' (as in 'DtcMessages.dtcHoleAdvice.holeMinMessage'), is used to look up a message in the properties file cmvMessages.properties.
The specified string can include placeholders that reference other fields, including custom fields and read-only fields. A placeholder for a given field is the name of the field enclosed in braces and prefixed by $. Here are some examples:
'Hole is too small to be cut with ${process}'
'Hole is too close to the following hole(s): ${custom.holesList}'
The read-only field messageText contains the result of substituting the appropriate values for the placeholders.
The string specified by this field provides the text for the message that appears below the table in the Casting Issues, Plastic Issues, or Fabrication Issues dialog when a table row is selected.
secondaryGcd: GCD, other than the current GCD, that played a key role in triggering the associated advice rule or in causing the failure of the associated routing rule. For example, if an advice rule is triggered because the current hole is too close to a second hole, secondaryGcd might be set to the second hole.
The value of this field is used to populate the GCD #2 column of the Proximity Issues table in the Fabrication Issues dialog (for the Sheet Metal process group).
current: this is the value of an attribute of the current GCD that played a key role in triggering the associated advice rule or in causing the failure of the associated routing rule. For example, if an advice rule is triggered because the current hole is too close to a second hole, current might be set to the distance between the holes.
The read-only field currentText provides a display-friendly version of the value of current, for example, "10 mm" or "15 º". The text includes the default units associated with the unit type specified by the unitType field. See also decimalPlaces, below.
The value of the currentText field is used to populate the Current column of the table in the Casting Issues, Plastic Issues, or Fabrication Issues dialog. It is also used to populate the Current value column of the table in the Finishing Operations tab of the Tolerances and Machining dialog.
suggested: this is an advisable value for the attribute whose actual value is given by current. Set this field if advice is triggered because current differs from the advisable value. See also suggestedMin and suggestedMax, below.
suggestedMin: this is the minimum advisable value for the attribute whose actual value is given by current. Set this field if creation of advice is triggered because current is less than the advisable minimum (or, more generally, because current is not between the advisable minimum and advisable maximum—see suggestedMax, below). For example, if an advice rule is triggered because the current hole is too close to a second hole, suggestedMin might be set to the minimum advisable distance between holes.
suggestedMax: this is the maximum advisable value for the attribute whose actual value is given by current. Set this field if advice is triggered because current is greater than the advisable maximum (or, more generally, because current is not between the advisable minimum and advisable maximum—see suggestedMin, above). For example, if an advice rule is triggered because the current hole is too deep, suggestedMax might be set to the maximum advisable hole depth.
unitType: unit type for the values of current, suggested, suggestedMin, and/or suggestedMax. This field is used to help provide display-friendly versions of these values via the read-only fields currrentText (see current, above) and suggestedText (see below).
decimalPlaces: number of decimal places to use for the display of values of current, suggested, suggestedMin, and/or suggestedMax. This field is used to help provide display-friendly versions of these values via the read-only fields currrentText (see current, above) and suggestedText (see below). If the field is not set or is set to -1, a maximum of 3 decimal places are displayed. The table below shows several examples of currentText values for various combinations of decimalPlaces and current:
decimalPlaces
 
current
currentText
-1 (default)
5
5
-1 (default)
5.3
5.3
-1 (default)
5.78264
5.783
2
5
5.00
2
5.78264
5.78
category: free-form string that is used to categorize advice messages. For example, the value of category is DTC_PROXIMITY (defined as the string 'proximityWarning') for any dtcMessage object that is used to report a proximity issue in the Fabrication Issues dialog for the Sheet Metal process group.
priority: relative importance of this advice message. In a future release, Design to Cost may support filtering of messages by importance.
An invocation of the dtcMessage function can contain 0 or more field-name/field-value pairs. But note that a dtcMessage object is used to determine the content of Design-to-Cost panels only if the appropriate fields are set. See further below.
Following are the read-only fields of dtcMessage objects. Their values are set based on field values specified by function arguments (see for example the field current, above) or based on aspects of the context in which the function is invoked, such as the current operation or GCD.
gcd: current GCD.
process: current process or operation.
vpe: current VPE.
attributeText: this is the string specified by the field attributeId (see above). When the dtcMessage function is executed, the cost engine attempts to use the value of attributeId (prefixed with 'DtcMessages') as a lookup key. If a message with that key is found in cmvMessages.properties, the field attributeText is set to that message. Otherwise, attributeText is set to the value of attributeId.
messageText: this is the string specified by the field messageId (see above). When the dtcMessage function is executed, the cost engine attempts to use the value of messageId (prefixed with 'DtcMessages') as a lookup key. If a message with that key is found in cmvMessages.properties, the field messageText is set to that message. Otherwise, messageText is set to the value of messageId.
currentText: display-friendly version of the field current (see above), for example, "10 mm" or "15 º". The text includes the default units associated with the unit type specified by the unitType field (see above). See also decimalPlaces, above.
The value of the currentText field is used to populate the Current column of the table in the Casting Issues, Plastic Issues, or Fabrication Issues dialog. It is also used to populate the Current value column of the table in the Finishing Operations tab of the Tolerances and Machining dialog.
suggestedText: display-friendly version of suggested, if suggested is set. Otherwise, suggestedText is a display-friendly version of suggestedMin and/or suggestedMax, if one or both is set. The text assumes the default units of the type specified by the field unitType, and limits the number of decimal places displayed to the value specified by the field decimalPlaces (see above).
The table below shows several examples of suggestedText values for various combinations of suggested, suggestedMin, and suggestedMax:
suggested
suggestedMin
suggestedMax
unitType
suggestedText
5
 
 
Angle
5 º
 
3
 
Length
>= 3 mm
 
 
8
Length
<= 8 mm
 
2
18
Length
2 – 18 mm
10
15
30
Angle
10º
12
 
 
 
12
 
2
5
 
2 – 5
If you want to display advice in the Fabrication Issues dialog for the Sheet Metal process group, set some or all of the following fields in your call to the dtcMessage function (all fields are optional except category):
attrbuteId: specify the string that you want to appear in the Sub-Type column. Not used for Proximity Issues.
messageId: specify the string that you want to appear below the table when the corresponding table row is selected. The string that appears is the result of substituting the appropriate values for placeholders in the string specified by messageId.
secondaryGcd: specify the GCD whose name you want to appear in the column GCD #2. This is generally the GCD to which the current GCD is too close, or to which the current GCD bears some problematic proximity relation. Only used for Proximity Issues.
current: specify the value that you want to appear in the Current column. The string that appears includes the default units for the type specified by unitType, and uses, at most, the number of decimal places specified by decimalPlaces.
suggested, suggestedMin, suggestedMax: specify the value or range that you want to appear in the Suggested column. The string that appears is the value of suggestedText—see above.
unitType: set this to the unit type that is associated with the values of current, suggested, suggestedMin, and/or suggestedMax.
decimalPlaces: set this to the maximum number of decimal places to use for the display of values of current, suggested, suggestedMin, and/or suggestedMax.
category: set this to one of the following, depending on what Issue Type you want your advice to fall under:
o 'proximityWarning'
o 'bendIssue'
o 'formIssue'
o 'materialIssue'
o 'holeIssue'
If you want to display advice in the Plastic Issues or Casting Issues dialog, set some or all of the following fields in your call to the dtcMessage function (the fields attributeId and custom.panelOutput are required; other fields are optional):
attrbuteId: specify the text for the menu-item that you want the user to select in order to display the advice.
messageId: specify the string that you want to appear below the table when the corresponding table row is selected. The string that appears is the result of substituting the appropriate values for placeholders in the string specified by messageId.
current: specify the value that you want to appear in the Current column. The string that appears includes the default units for the type specified by unitType, and uses, at most, the number of decimal places specified by decimalPlaces (see currentText, above).
suggested, suggestedMin, suggestedMax: specify the value or range that you want to appear in the Suggested column. The string that appears is the value of suggestedText—see above.
unitType: set this to the unit type that is associated with the values of current, suggested, suggestedMin, and/or suggestedMax.
decimalPlaces: set this to the maximum number of decimal places to use for the display of values of current, suggested, suggestedMin, and/or suggestedMax.
custom.panelOutput: set this to one of the following:
o 'castingIssue'
o 'plasticIssue'
If you want to display advice in the Tolerances and Machining dialog, set some or all of the following fields in your call to the dtcMessage function (the fields attributeId and category are required; other fields are optional):
current: specify the value that you want to appear in the Current Value column. The string that appears includes the default units for the type specified by unitType, and uses, at most, the number of decimal places specified by decimalPlaces.
suggested, suggestedMin, suggestedMax: specify the value or range that you want to appear in the Primary Process column. The string that appears is the value of suggestedText—see above.
unitType: set this to the unit type that is associated with the values of current, suggested, suggestedMin, and/or suggestedMax.
decimalPlaces: set this to the maximum number of decimal places to use for the display of values of current, suggested, suggestedMin, and/or suggestedMax.
category: set this to one of the following:
o 'toleranceWarning'
o 'roughnessWarning'
o 'roughnessRzWarning'
o 'diamToleranceWarning'
o 'positionToleranceWarning'
o 'circularityWarning'
o 'concentricityWarning'
o 'cylindricityWarning'
o 'parallelismWarning'
o 'perpendicularityWarning'
o 'runoutWarning'
o 'totalRunoutWarning'
o 'straightnessWarning'
o 'symmetryWarning'
o 'profileOfSurfaceWarning'
o 'flatnessWarning'
gcdNeedsCam(artifact, coDirectionalEpsilon)
Returns true if none of the isAccessible setup axes for artifact are within coDirectionalEpsilon degrees of the MainFace's normal direction; returns false otherwise. 
getAngleBetweenPartStripFlowAndSetupAxis(
holeSetupAxis,
normalVector,
eastDirection
)
Calculates the angle between the part strip flow direction and the setup axis passed in, which is typically derived from a hole on a pierce cam. The function has the following arguments:
holeSetupAxis: setup axis whose angle is to be calculated
normalVector: main surface's normal vector
eastDirection: main surface's east direction
Note: If the setup axis' direction is within .01 degrees of the normal vector, null is returned (because the calculation becomes unstable as the hole's setup axis approaches the same direction as the normal).
getDistanceToPartFrontEnd(turningAxis, Gcd)
Returns the distance from Gcd's centroid to the turningAxis' front face. The turningAxis front face is the face that faces in the same direction the turningAxis is pointing.  If Gcd does not have a centroid (for example, if it is an edge), null is returned.
getFlattenedOps(op)
Returns a flattened collection of all of op’s costed child operations.
Example:
 
numberOfFacing = _
select count(op) from flattenedOps op where _
op.simpleName=='Facing'
 
flattenedOps = getFlattenedOps(op)
getCamAssignments(
holes,
codirectionalEpsilon,
minimumDistanceBetweenHoles,
rows
)
Returns a collection of CamAssignment objects that assigns each hole in holes to one cam. The argument rows is a collection of rows from a lookup table (such as camUnitSizes from the Sheet Metal process group) that specifies size information about the various types of cams to be assigned.
Holes are placed on the same cam (CamAssignment object) if all the following hold:
All the holes’ setup axes are codirectional, that is, the angle between their setup axes varies by at most by codirectionalEpsilon.
All holes meet the distance apart requirement, that is, the outer edges of holes are at least minimumDistanceBetweenHoles apart.
The rectangular size covered by all the holes is not greater than the size of the cam mounting surface (the product of Cam Face Width and Cam Face Height for the row that represents the cam). For example, two holes that are 1000mm apart are not both assigned to a cam that has a mounting surface that measures 500 X 500mm.
The function always chooses a cam with the smallest possible cam mounting surface possible for a group of holes. It also groups holes together until such a time as there is no cam mounting surface large enough for them, at which point subsequent holes are put on a new cam.
isTrue(string)
Returns true if the string passed in is non-null and equals (case insensitive) ‘true’, ‘yes’ or ‘1’.
isNodePrecededBy(node, precedingNodeName)
Returns true if node is preceded by precedingNodeName in the current process routing or operation sequence; returns false otherwise.

example:
bool = isPrecededBy(op, 'Drilling')
safeEval(expression, defaultValue)
Returns the result of evaluating expression., if no error occurs during the evaluation. If any error occurs during that evaluation, defaultValue is returned.
For example, safeEval(12*3, 2)returns 36, while safeEval(12 + bogus, 2) returns 2, if bogus is not a defined expression or variable. See also Examples.
.
safeGet(x, altVal)
Returns x if x is non-null; returns altVal otherwise.
getSlidesAndLiftersForGCDs(
gcds,
maxGCDPitch,
maxActionLength,
minimumLifterClearance,
drawDirectionOrthogonalEpsilon
)
Returns a collection with two elements (each of which is itself a collection):
Collection of slides
Collection of lifters
Each slide and lifter has the following fields:
start: location relative to an arbitrary point. The length of the slide or lifter is the difference between start and end.
end: location relative to an arbitrary point (the same one used by start). The length of the slide or lifter is the difference between start and end.
artifacts: GCDs handled by this slide or lifter
setupAxis: setup axis used by the GCDs handled by this slide or lifter
The function first determines what setup axis to use for each GCD, by doing the following:
Sort GCDs based on size (volume), in descending order.
For each GCD, iterate over each of its isAccessible relations.
Check if any of the isAccessible relations has a distance to obstruction equal to -1, a setup axis that is within drawDirectionOrthogonalEpsilon degrees of being orthogonal to the draw direction, and a setup axis that has already been picked for a previous gcd for use in a Slide. If so, use that setup axis and assign this GCD to a slide. If more than one setup axis satisfies these criteria, use the one with the smallest length on the isAccessible relation.  If more than one setup axis has the same smallest length, use the one with the smallest distanceToSolidShadowBorder.  Note that the function considers the length to be the same if it is literally the same, or if the two setup axes for the two relations are within 5 degrees of each other or within 5 degrees of being exact opposite directions (180 degrees).  This is because there is some latitude when length is populated and length for two setup axes pointing in the same direction or in opposite directions should essentially be the same.
If no setup axis was chosen in the previous step, check if any isAccessible relations have a distance to obstruction greater than or equal to (minimumLifterClearance + isAccessible.length) or distanceToObstruction=-1 with setup axis not within drawDirectionOrthogonalEpsilon degrees of being orthogonal to the draw direction and a setup axis that has already been picked for a previous GCD for use in a lifter. If so, use that setup axis and assign this GCD to a lifter. If more than one setup axis satisfies these criteria, use the one with the smallest length on the isAccessible relation.
If no setup axis was chosen in the previous steps and if  there exists an isAccessible relation with distance to obstruction equal to -1 and a setup axis that is within drawDirectionOrthogonalEpsilon degrees of being orthogonal to the draw direction, use the setup axis on that relation an assign this GCD to a slide. If more than one relation/setup axis pair satisfies these criteria, use the one with the smallest length on the isAccessible relation.
If no setup axis was chosen in the previous steps, check if any isAccessible relations have a distance to obstruction greater than or equal to (minimumLifterClearance + isAccessible.length) or distanceToObstruction=-1 with setup axis not within drawDirectionOrthogonalEpsilon degrees of being orthogonal to the draw direction, use the setup axis on that relation and assign this GCD to a lifter. If more than one relation/setup axis pair satisfies these criteria, use the one with the smallest length on the isAccessible relation.
If no setup axis was chosen in the previous steps, put the GCD on its own lifter.
All the GCDs passed in are thus grouped together according to their setup axis as found in step 1 and whether they will be on a lifter or a slide.
For each group of GCDs with the same setup axis, a group of lifters or slides will be created. Lifters/slides are non-overlapping with a maximum length of maxActionLength.  If the start of a current GCD falls within an existing lifter/slide’s start + maxActionLength, then that GCD is added to that existing lifter.  Otherwise, a new lifter/slide is created whose start the GCD’s start.  If a GCD is assigned to a lifter/slide and the GCD’s end runs past the lifter/slide’s start + maxActionLength, then an additional lifter/slide is created and the GCD is assigned to that additional lifter/slide. In addition, if the end of one GCD minus the start of the next GCD is greater than maxGCDPitch then these two GCDs are placed on different lifters/slides. In addition, any GCD passed in that falls through to the last step above is placed on its own lifter. Note that this lifter will have no setup axis nor will it have a start/end.
getAssociatedSlides(gcd, slideList, forLengthWise)
Returns a pair of collections, each of which contains all of the slides that are allocated to either one side or the other side of the specified GCD.  If forLengthWise is true, the function returns all slides that fall on either side of the lengthwise sides of the part. If forLengthWise is false, the function returns all slides that fall on either side of the widthwise sides of the part. The four sides of the part are divided into equal 90 degree quadrants.  Which quadrant (or which side) a slide gets assigned to depends on which quadrant contains its setup axis.
Example:
 
numSlidesLengthWiseSide2 = _
select count(s) from slidesInLengthWiseDirection.second s
numSlidesWidthWiseSide1 = _
select count(s) from slidesInWidthWiseDirection.first s
numSlidesWidthWiseSide2 = _
select count(s) from slidesInWidthWiseDirection.second s

slidesInLengthWiseDirection = getAssociatedSlides(gcd, slides, true)

slidesInWidthWiseDirection = getAssociatedSlides(gcd, slides, false)
 
getAssociatedSlideBundles(gcd, slideBundleList, forLengthWise)
Returns a pair of collections, each of which contains all of the slide bundles that are allocated to either one side or the other side of the specified GCD.  If forLengthWise is true, the function returns all slide bundles that fall on either side of the lengthwise sides of the part. If forLengthWise is false, the function returns all slide bundles that fall on either side of the widthwise sides of the part. The four sides of the part are divided into equal 90 degree quadrants.  Which quadrant (or which side) a slide bundle gets assigned to depends on which quadrant contains the setup axis that the slide bundle is accessible from.
Example:
 
slideBundlesInLengthWiseSide1 = slideBundlesInLengthWiseDirection.first
slideBundlesInLengthWiseSide2 = slideBundlesInLengthWiseDirection.second
 
slideBundlesInLengthWiseDirection = _
getAssociatedSlideBundles(gcd, slideBundles, true)
 
slideBundles =  select x from gcd.childArtifacts x where isSlideBundle(x)
 
postMessageAndReturnValue(value, message)
Adds the string message to the message tree as an Info message (associated with a green dot).  Returns value.  To aid in internationalization, the actual parameter for message is typically a variable that is tied to a literal string within a centralized messages file.
Example:
postMessageAndReturnValue(2.0, successMsg) // in a file shared across languages
successMsg = 'Calculation was successful' // in a language-specific file
getClockAngle(normalDirection, noonDirection, clockDirection)
Returns the clock angle. Following is the calculation performed, in Java:
 
double cos = noonDirection.dot(clockDirection);
Vector3d cross = new Vector3d();
cross.cross(clockDirection, noonDirection);
double sin = normalDirection.dot(cross);
double angle = Math.atan2(sin, cos);
if (angle < 0)angle = 2 * Math.PI + angle;
return Math.toDegrees(angle);
 
hasField(obj, fieldName)
Returns true if the object has a field by the specified name; returns false otherwise.
getFinishedArea(plantRMillPercentile, gcd, op)
Returns the sum of all finished areas of all operations that lie on the specified GCD that have an opDiameter that is less than or equal to the selected opDiameter. The selected opDiameter is selected based on the plantRMillPercentile in conjunction with all the diameters of all operations that lie on the specified GCD. 
Example:

GetAreaFinished3(millSize) = {
getFinishedArea(plant.smallRMillPercentile, gcd, op) _
if (millSize == SMALLEST_MILL)
getFinishedArea(plant.largeRMillPercentile, gcd, op) _
if (millSize == LARGEST_MILL)
getFinishedArea(plant.middleRMillPercentile, gcd, op) _
if (millSize == MIDDLE_MILL)
}