Back to top

hsbExport | hsbcad Model Data Formatting

This feature allows the properties of Entities, Projects and Groups to be formatted inside a string.
The feature was primarily developed to allow user defined names to be specified that included dynamic content from model data.

e.g. when defining folder names for CNC output the number or name of the project could be included. C:\MyCNCData\@(ProjectNumber)

How the format string is defined

The format string is made up of constant text and variables. The variables take the form:

@(<VariableName>)

The variable names directly relate to the property names of the classes so any string, number, enumeration or boolean property can be specified. If the variable name cannot be found it will not be resolved and will stay inside the format string unchanged.

e.g. for a Beam using a format string of "@(Length) x @(Width) x @(Height)" would use the Length, Width and Height properties of the beam.

There are also a set of variable names that provide special functionality.

Parent variable names

The following variables represent data for parent objects that can be accessed from their children.

BackColor Specifies the background color used in the layout.
CustomStyle Insert the name of a style in a graphical user interface format.
CustomStyleName Insert the name of a style in a textual context and not one found in visual outputs.
Element Represents an element in a layout, such as a Wall or Column.
ElementLength The length of the element calculated using the bounds of the GenBeams in the element rounded to zero decimal places.
ElementHeight The height (dimension in the Y direction) of the element calculated using the bounds of the GenBeams in the element rounded to zero decimal places.
ElementWidth The width of the element calculated using the bounds of the GenBeams in the element rounded to zero decimal places.
ElementCode The code of the element.
SubType The subtype of the element.
Information The information of the element.
Quantity The quantity of the element.
Definition The definition of the element.
ProfNettoArea Specifies the netto area of the wall profile.
ProfBruttoArea Specifies the brutto area of the wall profile.
Length The length property of the entity.
Width The width property of the entity.
Height The height property of the entity.
SolidLength The actual analyzed length of the entity.
SolidWidth The actual analyzed width of the entity.
SolidHeight The actual analyzed height of the entity.
Type The type property of the entity.
Material The material property of the entity.
Label The label property of the entity.
SubLabel The sublabel property of the entity.
SubLabel2 The second sublabel property of the entity.
Name The name property of the entity.
Grade The grade property of the entity.
BeamCode The beam code property of the entity.
PosNum The positional number property of the entity.
Company name Format This will set the Ifc Organization in the Ifc file.
Grouping The way in which the entities will be grouped.
Include MapX Data Export MapX Data as Property Set.
Name Format This will set the name of the Ifc file.
Output Path Format Name of the output file.
Username Format This will set the Ifc Person in the Ifc file.
ProjectNumber The number of the project as defined in the project settings and ProjectInfo class.
ProjectName The name of the project as defined in the project settings and ProjectInfo class.
ProjectDir The project directory.
ProjectComment The comment as defined in the project settings.
ProjectCity The city as defined in the project settings.
ProjectDwgName The name of the DWG file.
ProjectRevision The revision as defined in the project settings.
ProjectStreet The street as defined in the project settings.
ProjectUser The user as defined in the project settings.
ProjectCompany The company path in the project settings.
ProjectWallDetailPath The wall detail path in the project settings.
ProjectFloorDetailPath The floor detail path in the project settings.
ProjectDirName The name of the folder where the source drawing file is located.

e.g. including the element number a beam belongs to. 

string beamDescription = beam.Format("@(Length) x @(Width) x @(Height) from @(ElementNumber)"); 

Multiwall Variable Name

A special variable name exists to list the single walls of a multiwall.

@(SingleWalls) or just @(SW) will list the names of the single walls.
@(ReverseSingleWalls) or just @(RSW) will list the names of the single walls in reverse order. This can be necessary where the orientation of the multiwall has changed.

An optional paramter can also be used to specify the delimiter.
@(SingleWalls:<delimiter>) where the can be one or more characters.


e.g. For a multiwall containing the walls FF1, FF2, FF3 and FF4 the following formats could be used:
@(SW) = FF1-FF2-FF3-FF4
@(SW:_) = FF1_FF2_FF3_FF4
@(SW:, ) = FF1, FF2, FF3, FF4

Formatting Functions

There are a number of functions that can be used to format string values.
E.g. To take the last two characters from the element number: @(ElementNumber:R2)

Possible functions are: 

AN Architectural Notation: Formats numbers into architectural notation, taking the precision as a parameter.
CU Change Unit: Converts units for length, area and volume taking the target unit as a parameter. Supported target units are: mm, cm, m, in, ft.
D Default Value: Specifies the value to use if the value can no be resolved. The default is an empty string or a constant can be specified.
DN Decimal Notation: Formats numbers into architectural notation, taking the precision as a parameter.
L Left: Takes the specified number of characters from the left of the string.
R Right: Takes the specified number of characters from the right of the string.
S SubString: Given one number will take all characters starting at the position (zero based). Given two numbers will start at the first number and take the second number of characters.
T Tokeniser: Returns the member of a delimited list using the specified index (zero based). A delimiter can be specified as an optional parameter with the default delimiter being the semicolon character.
U Upper: Converts the string to upper case.
PL Pad Left: Pads the string to the left the specified number of characters with an optional parameter to specify the character to pad with.
PR Pad Right: Pads the string to the right the specified number of characters with an optional parameter to specify the character to pad with.
R Regex Replace: Lookup and replace values based on a Regular Expression (Regex).
RX Regex Lookup: Lookup values based on a Regular Expression (Regex).
# Rounds a number. Specify the number of decimals to round to. Trailing zeros are removed.
RL Round Local: Rounds a number using the local regional settings.

For example:

Given a group name of "House\Floor\Walls"
@(GroupName:L5) = "House"
@(GroupName:R5) = "Walls"
@(GroupName:S7) = "Floor\Walls"
@(GroupName:S7;5) = "Floor"


It is also possible to chain them together.
@(GroupName:S7:R5:U) = "WALLS" 
@(GroupLevel3:PL7) = "  Walls"
@(GroupLevel3:PR7;x) = "Wallsxxx"
@(GroupName:T1;\) = "Floor"


Or given a beam with a solid width of 29.499765 mm
        @(SolidWidth:0) = “29”
        @(SolidWidth:1) = “29.5”
        @(SolidWidth:2) = “29.5”

Same could be done for a beam using: @(Solidheight) or @(SolidWidth)

D: default value if variable does not get resolved

If Information property is set to: Lion,Tiger,Frog

@(nokey) => @(nokey) // no default specified

@(nokey:D) =>  // empty default returns blank

@(nokey:D"bb") => bb // default value must be enclosed in double brackets

@(nokey:D;"cc") => cc // default value can also be second argument

@(nokey:D:PR4;A) => AAAA // After default substitution other commands can be applied

@(nokey:D"BB":PR4;A) => BBAA // After default substitution other commands can be applied

@(nokey:PR7;a:D:PR4;b) => bbbb // Commands before default are ignored in case of default

@(Information:T1;,:PL6;a:D:PR7;b) => aTigerb // Default is ignored if variable is resolved


As you know, @(nokey:D) => // empty default returns blank

@(key1:D)@(key2:D) would always take key1 and key2, but this ends up as an 'or' if only one is present.

​T: Tokeniser

The T function has since V23.8.9 an additional option 3rd argument, which expresses the default in case the index is out of range.

T Tokenise to get the nth (n is 0 based index) part out of a separated list.
The first argument is the index. The second is an optional separator, which defaults to ;. The third optional argument, which default to an empty string, is the string which is returned in case the index is out of range.

If Information property is set to: Lion,Tiger, Elephant,Frog
@(Information:T0;,) => Lion // the first value with index 0
@(Information:T1;,) => Tiger // the second value with index 1
@(Information:T2;,) => Elephant // values are automatically trimmed
@(Information:T4;,) => // empty string, because index 4 (fifth value) is out of range
@(Information:T4;,;pink elephant) => pink elephant // index out of range will use the default

If the separator is ; you can omit it in the expression, so if Information is set to Lion;Tiger; Elephant;Frog
@(Information:T0) => Lion // the first value with index 0
@(Information:T1) => Tiger // the second value with index 1
@(Information:T2) => Elephant // values are automatically trimmed
@(Information:T4) => // empty string, because index 4 (fifth value) is out of range
@(Information:T4;;pink elephant) => pink elephant // index out of range will use the default

Separators for the tokenizer can be specified enclosed or not enclosed with double quotes.
Since the colon is already used in chaining the different commands, it always has to be enclosed in double quotes.
So if you want to use colon : as a separator you have to enclose it in double quotes as in the following example:
Given
label = "elephant:lion"
@(label:T1;":")
becomes "lion"

CU: Unit Conversion and Form​atting

@(SolidLength:CU;mm) - change the value from drawing units to mm

@(SolidLength:CU;m) - change to m

@(SolidLength:CU;cm)

@(SolidLength:CU;in)

@(SolidLength:CU;ft)

@(Volume:CU;m) => change value to cubic meters

@(Len:DN3) => force decimal notation, rounding to 3

@(Len:AN3) => force architectural notation, rounding to 1/8

@(Len:CU;mm:DN3) => convert to mm, decimal notation​

@(SolidLength:AN3) - formatted to 1/8 inch

@(SolidLength:AN4) - formatted to 1/16 inch

@(SolidLength:AN5) - formatted to 1/32 inch​

Aliases

Aliases allow values to be replaced with another value, an alias.
The aliases are stored in files inside the company folder.
e.g. TestAliases.dat.

An alias is made up of:

  • Expression – what is being mapped to. This can contain the wild card character '*' to represent zero or more characters.
  • Text – the value being returned if the expression is matched.

e.g.

Expression = "*ground*"
Text = "GF" 

This would match the following  "House\Ground Floor\Walls"  and "GF" would be the result.
 
The is implemented inside the formatting as an Alias string function.

e.g. Assuming the global aliases are being used:

@(GroupName:A) would look for an alias of the group name.

To use a custom alias file a parameter is specified.

e.g. using the custom "Test" alias (file name is TestAliases.dat)

@(GroupName:A;Test)


For more information see our article about Aliases. Alias Manager

MapX and PropertySets

Propertysets are groups of Properties that are added to objects.

MapX is a map (like a set of properties) that is available in the exporter.
MapX and PropretySet data can be accessed by simply specifying the path to data in the underlying map starting with the MapX key or PropertySet name.

The MapX data will take precendence over the PropertySet data.
     e.g. An entitty has MapX data with a key of "Hsb_ElementInfo" which contains a value "Weight".
This could be accessed using the format:

@(Hsb_ElementInfo.Weight)

The path for MapX data can go as deep as necessary.
    e.g. @(Key.SubMap1.SubMap2.SubMap3.ValueKey).

Drawing Pr​​​operties

The Drawing Properties are specified as:

@(DrawingProperties.Title)
@(DrawingProperties.Author)
@(DrawingProperties.Subject)
@(DrawingProperties.KeyWords)
@(DrawingProperties.Comments)
@(DrawingProperties.LastSavedBy)
@(DrawingProperties.RevisionNumber)
@(DrawingProperties.HyperLink)

 Custom properties are access the same way:

@(DrawingProperties.<CustomPropertyName>)

e.g. @(DrawingProperties.HOI)

Standard names will always take precedence over customer ones, and the names are not case sensitive. ​

RX: Regex RX;”expression”  or RXn;”expression”  or RXn;”expression”;”result”  

Learning regex you could use: https://qntm.org/files/re/re.html.

As a regex reference: https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference

Some of us use a tool called expresso when validating regex expressions: http://www.ultrapico.com/Expresso.htm.

Find a match using a regex expression. By default the matching expression is returned. Since in an input string multiple matches might be found, the n-th match can be returned by specifying a first argument. By default the first match is returned. When the result string is added as third argument, the match is used to build the result string. In this case regex indexed groups and named groups can be used.

The regex expression as well as the result are encapsulated in double quotes “. The consequence of that is when you want to use double quotes inside them, you have to escape it. The escape character is back slash \. So besides the other special regex characters that need escaping, the double quote needs it too.

If Information property is set to: Lion,Tiger,Frog

The following regex will return the following result:

            @(Information:RX;"[^,]+") => Lion

            @(Information:RX0;"[^,]+") => Lion

            @(Information:RX1;"\\w+") => Tiger

            @(Information:RX2;"\\w+") => Frog

            @(Information:RX3;"\\w+") =>

For an Information property: Lion,Tiger():"Elephant";Frog

The following regex will return the following result:

            @(Information:RX;"[^,]+") => Lion

            @(Information:RX;"\\w+") => Lion

            @(Information:RX0;"\\w+") => Lion

            @(Information:RX1;"\\w+") => Tiger

            @(Information:RX;"[^,]*") => Lion // @(Animals:RX"[^,]*")

            @(Information:RX;"[^)]*") => Lion,Tiger( // ) chars inside regex string are allowed

            @(Information:RX;"[^:]*") => Lion,Tiger() // : chars inside regex string are allowed

            @(Information:RX;"[^\\]*"") => Lion

Need Support?

Can’t find the answer you’re looking for? Don’t worry we’re here to help!

Contact support