The Attach Assembly Macro is a System Macro which is used by the V-Suite CORE Model Connect and Insert Command.

The Attach Assembly Macro creates an Assembly of PADL driven Assets. An example of such an Assembly is a Flanged Valve Assembly which consist of a Flange - Gasket - Valve - Gasket - Flange. Create the Macro and set the Macro Type to Attach Assembly.

Custom Options

The custom options define to which Assets the Assembly can be connected and optionally into which Asset it can be inserted.

Connect Points

Specify to which Assets the Assembly can be connected. For instance a Flanged Valve (the first Flange) can be connected to an elbow, straight and reducer.  Optionally if the Assembly can only be connected at a specify connect point select the appropriate connect point only:

Allow Insert into

Specify into which Asset(s) the Assembly can be inserted. Only 'breakable' Assets will be displayed. Please note that only Assemblies of which the start and end connection are inline with the Asset into which it is to be inserted can be inserted. For example and Angle Valve can be connected to an Asset but cannot be inserted into an Asset.

Assembly Icon

Specify the Icon with which the Assembly is presented in the different V-Suite CORE Model menus and controls. Custom Icons can be created with Icon Manager.

Attach Assembly JScript Expression

The Attach Assembly Macro must consist of series of specific commands. These commands are available in the Assemblies Macro API Command Class. The Macro will consist of a series of CreateAttachment commands. The result of the Macro must be returned to the function that uses the Macro. The result of the Attach Assembly Macro must be an object VariableTable which can be created with Utilities.NewVariableTable.  Optionally if the Assembly has Asset with an orientation (for example Valve Hand Wheel)  you can specify placement options.

Consider the following example of Flanged Valve Assembly which can be connected to the End of a Straight

 

 

First get the Asset Templates of Flange, Gasket and Valve:

var flangeTemplate = Database.GetAssetTemplate("Flange","LINx.V-Suite CORE")

var gasketTemplate = Database.GetAssetTemplate("Gasket","LINx.V-Suite CORE")

var valveTemplate = Database.GetAssetTemplate("Valve","LINx.V-Suite CORE")

V-Suite CORE expects a VariableTable which contains information about the newly created Assets.

Initialize the VariableTable that will be returned by the Macro :

var macroResult = Utilities.NewVariableTable()

Attach the Weld Connect Point of a Flange to Straight. Attach Assembly Macros will receive input from V-Suite CORE to which Asset and at which Asset Connect Point the Assembly is to be connected. The parameters will be assigned to reserved global variable PARAMETERS. The input parameter names are strings.
To ensure that the correct parameter names are used it is advised to use the reserved global CONST object, this way parameter names do not need to hard-coded ensuring version compatibility.

// Get the Input Parameters and create the first flange

var Asset = PARAMETERS.Get("Asset")

var SnapPoint = PARAMETERS.Get("SnapPoint")

 

 var flange1 = Assemblies.CreateAttachment(Asset, SnapPoint, flangeTemplate, "Weld")

Attach the Start of the first Gasket to the Face of the first Flange:

var gasket1 = Assemblies.CreateAttachment(flange1, "Face", gasketTemplate, "Start")

Attach the Start of the Valve to the End of the first Gasket:

var valve = Assemblies.CreateAttachment(gasket1, "End", valveTemplate, "Start")

Attach the Start of the second Gasket to the End of the Valve:

var gasket2 = Assemblies.CreateAttachment(valve, "End", valveTemplate, "Start")

Finally, Attach the Face of the second  Flange to the End of the second Gasket:

var flange2 = Assemblies.CreateAttachment(gasket2, "End", flangeTemplate, "Face")

In order for V-Suite CORE to display the newly created Assets the Macro must return a list of Assets.
Create the Object List which will hold the IDs of the newly created Assets.

var objectList = Utilities.NewObjectPropertyList()

Add the new Assets to the Macro Result

objectList.Add(flange1)

objectList.Add(gasket1)

objectList.Add(valve)

objectList.Add(flange2)

objectList.Add(gasket2)

 

Add the object list to the variable table, use reserved global variable CONST to avoid hard-coding variable names:

macroResult.AddVariable("ObjectList",objectList)

 

If the Assembly can be inserted the VariableTable must also contain Variables "StartLocation" and "EndLocation" indicating the start- connection of the first asset and end-connection of the last asset. Add these values to the VariableTable:

macroResult.AddVariable("StartLocation","Weld")

macroResult.AddVariable("EndLocation","Weld")

The Valve Asset has a Hand Wheel which we would like to be able to re-orient in the V-Suite CORE Model Connect Command.  Calculate 4 default orientations (0, 90, 180, 270). First get the Direction and Orientation of the Valve so that we can calculate the default orientations. Please note that these Placement Options are optional.

var Direction = Assets.GetPhysicalPropertyValue(valve,"Direction")

var Orientation = Assets.GetPhysicalPropertyValue(valve,"Orientation")

Calculate the default orientations by rotating the orientation around the direction (axis or rotation).

var opt1 = Orientation  // 0

var opt2 = Orientation.Rotate( 90, Direction)

var opt3 = Orientation.Rotate( 180, Direction)

var opt4 = Orientation.Rotate( 270, Direction)

Add the Valve Orientation Placement Options to the ObjectList.

objectList.AddObjectProperty(valve, "Orientation",  opt1)

objectList.AddObjectProperty(valve, "Orientation",  opt2)

objectList.AddObjectProperty(valve, "Orientation",  opt3)

objectList.AddObjectProperty(valve, "Orientation",  opt4)

Finally instruct the Macro to return the Macro Result to V-Suite CORE Model.

RESULT = macroResult