v1.1
 
Style Template Structure

Style template includes:

  • .json parameters and ports description file;
  • one or more .lua script files.

Parameters and Ports Description File

A parameter and port description file in JSON format must contain the object style parameter groups in the following structure:

{
"metadata":{
"defaultName": "DefaultName",
"description": "Description",
"version": "1.0.0",
"author": "Author"
},
"styleParameters":[
{
"name": "Group1",
"text": "Group 1",
"params": [
{
"name": "ParameterName",
"text": "Parameter name",
"type": "Id",
"entityTypeId": "0000000-0000-0000-0000-000000000000"
}
]
},
{
"name": "Group2",
"text": "Group 2",
"params": [
{
"name": "ParameterName",
"text": "Parameter name",
"type": "Length",
"default": 595,
"min": 1,
"max": 1000000.0
}
]
}
],
"ports": [
{
"name": "PortName",
"text": "Port name",
"flowDirection": "Inlet",
"systemCategories": [
"DomesticColdWater"
]
}
]
}

Parameters Description

The metadata section contains data that will be displayed in the Categories window in Renga Professional. The style template version must be specified as 3 numbers separated by dots, such as "1.2.34".

The styleParameters section contains parameter groups that describe all possible object style parameters. The visibility of parameter groups in the object style editor can be enabled or disabled using the Style Template API functions.

Each parameter must contain a name, text, and type. Depending on the parameter type, additional data is specified.

Allowed parameter types:

Value Description
Integer Integer
Real Real number
String String
CoreEnum Style Template API enumeration
UserEnum User enumeration
Length The length in millimeters
Angle The angle in decimal degrees
Id Identifier
Boolean Boolean (true/false)

For all parameter types except Id, you can specify the default key. The value of this key will be the default value of the parameter. The value cannot be empty.

For numeric parameters, you can set the minimum and maximum values using the min and max keys.

For CoreEnum, specify the CoreEnumType key. Valid values for the key can be found in the Core Enums section.

For UserEnum, create an items array and set the values to select from the list.

"items" : [
{
"key" : "Item1",
"text" : "Item 1"
},
{
"key" : "Item2",
"text" : "Item 2"
},
{
"key" : "Item3",
"text" : "Item 3"
}
]

For the Id parameter type, you must specify the entityTypeId key, the value of which should be specified according to the Renga API help. Currently, you can only set a link to the material:

{
"name" : "Material",
"text" : "Material",
"type" : "Id",
"entityTypeId" : "0abcb18f-0aaf-4509-bf89-5c5fad9d5d8b"
}

Ports Description

The ports section includes groups of parameters for describing ports.

The port description should include the name, text, flowDirection, and a set of valid categories for pipe, duct, or electrical systems, known as systemCategories.

Allowed flow directions:

  • Inlet
  • Outlet
  • InletAndOutlet

Pipe system categories:

  • DomesticColdWater
  • DomesticHotWater
  • DomesticSewage
  • Gas
  • Firewater
  • Heating
  • GaseousFireSuppression
  • Rainwater
  • IndustrialColdWater
  • IndustrialHotWater
  • IndustrialSewage
  • OtherPipeSystem

Duct system categories:

  • Ventilation
  • Exhaust
  • Pressurization
  • SmokeExhaust
  • Vacuum
  • OtherDuctSystem

Electrical system categories:

  • LightingCircuit
  • PowerCircuit
  • OtherElectricalSystem

The pipe accessory and duct accessory port descriptions may include a portRole parameter to define the role of the port. Valid values:

Value Description
TransitPort Port for placing the object on a route.
EndPort Port to create a route from the object

For example, to allow a pipe accessory to be both placed on a pipe route and connected to an electrical system, describe the ports as follows:

"ports": [
{
"name": "PipeInlet",
"text": "Pipe inlet",
"flowDirection": "Inlet",
"portRole":"TransitPort",
"systemCategories": [
// List of pipe system categories
]
},
{
"name": "PipeOutlet",
"text": "Pipe outlet",
"flowDirection": "Outlet",
"portRole":"TransitPort",
"systemCategories": [
// List of pipe system categories
]
},
{
"name": "ElectricPort",
"text": "Electric port",
"flowDirection": "InletAndOutlet",
"portRole": "EndPort",
"systemCategories": [
"PowerCircuit"
]
}
]

Script File

Using a Lua script, you can create an object style description. This allows you to create a three-dimensional model of the object that can be modified using parameters, represent the object for display on drawings, specify which parameters to display in the object style editor in Renga, and set the connection parameters and the position of ports.

A Lua script may contain:

  1. Getting parameters from the parameter and port file.
  2. A detailed geometry for creating a 3D model.
  3. A symbol description for display in a drawing.
  4. A symbolic geometry for display in a drawing.
  5. A position of ports and connection parameters.
  6. Setting parameter display in the object style editor.

Functions for specifying geometry, port positions, connection parameters, and setting the display of object style parameters are located in the Style namespace.

Parameters

To get parameters, use the Style.GetParameter() function, and to get parameter values, use the Style.GetParameterValues() function, which returns a table of parameters.

Example of getting a parameter value with Style.GetParameterValues():

local parameters = Style.GetParameterValues()
print(parameters.Dimensions.BodyWidth)
Style namespace.
Definition GeometryStyleMethodRegistrator.h:13

In this case, the value of the "BodyWidth" parameter from the "Dimensions" parameter group will be printed to the log.

To set the visibility of parameters in the object style editor, you must get the parameter group or to the parameter object using the functions Style.GetParameterGroup(groupName) or Style.GetParameter(groupName, parameterName).

Detailed Geometry

Detailed geometry defines the object 3D model. To set the detailed geometry, the Style.SetDetailedGeometry(modelGeometry) function is used, which takes as an argument the model geometry created using the Style Template API functions and classes.

For example:

function MakeBody()
return CreateBlock(dimensions.Width, dimensions.Depth, dimensions.Height):Shift(0, 0, - dimensions.Height / 2)
end
local solid = MakeBody()
solid:Shift(0, 0, dimensions.Height / 2)
Style.SetDetailedGeometry(ModelGeometry():AddSolid(solid))
Model geometry.
Solid CreateBlock(number xSize, number ySize, number zSize, Placement3D oPlacement)
Creates a rectangular parallelepiped.

Symbol Geometry

Symbol geometry defines the symbol that will be displayed in a drawing. It can be created for the following types of objects:

To set the symbol geometry, the Style.SetSymbolGeometry(modelGeometry) function is used, which takes as an argument the model geometry created using the Style Template API functions and classes.

Symbolic Geometry

Symbolic geometry defines the symbolic representation of an object in a drawing. It can be created for the following types of objects:

To set the symbolic geometry, the Style.SetSymbolicGeometry(modelGeometry) function is used, which takes as an argument the model geometry created using the Style Template API functions and classes.

Ports

In a script, you can set:

  • Port position.
  • Anchor. You can set an anchor for details and accessories to move them relative to the route.
  • Parameters for connection to pipe or duct systems.

You can get the port using the Style.GetPort(portName) function, which takes as an argument the port name specified in the file with parameter and port descriptions.

local height = Style.GetParameter("Dimensions", "Height"):GetValue()
local coldWaterOrigin = Point3D(0, 0, height)
local portPlacement = Placement3D(coldWaterOrigin, Vector3D(0, 1, 0), Vector3D(1, 0, 0))
Style.GetPort("PortName"):SetPlacement(portPlacement)
local connectionType = Style.GetParameter("Port", "ConnectionType"):GetValue()
local diameter = Style.GetParameter("Port", "Diameter"):GetValue()
Style.GetPort("PortName"):SetPipeParameters(connectionType, diameter)
Local coordinate system in three dimensional space.
Three-dimensional point.
Port.
Three-dimensional vector.