mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
int formatting function #5039
Example - https://i.imgur.com/wDGFNci.png
This commit is contained in:
@@ -134,10 +134,11 @@ get_element_grammar = lark.Lark(
|
||||
format_grammar = lark.Lark(
|
||||
"""start: function
|
||||
|
||||
function: round | number | format_length | lower | upper | title | concat | substr | ESCAPED_STRING | NUMBER
|
||||
function: round | number | int | format_length | lower | upper | title | concat | substr | ESCAPED_STRING | NUMBER
|
||||
|
||||
round: "round(" function "," NUMBER ")"
|
||||
number: "number(" function ["," ESCAPED_STRING ["," ESCAPED_STRING]] ")"
|
||||
int: "int(" function ")"
|
||||
format_length: metric_length | imperial_length
|
||||
metric_length: "metric_length(" function "," NUMBER "," NUMBER ")"
|
||||
imperial_length: "imperial_length(" function "," NUMBER ["," ESCAPED_STRING "," ESCAPED_STRING] ")"
|
||||
@@ -249,6 +250,9 @@ class FormatTransformer(lark.Transformer):
|
||||
float(value), int(precision), unit_system="imperial", input_unit=input_unit, output_unit=output_unit
|
||||
)
|
||||
|
||||
def int(self, args: list[str]) -> str:
|
||||
return str(int(float(args[0])))
|
||||
|
||||
|
||||
class GetElementTransformer(lark.Transformer):
|
||||
def start(self, args):
|
||||
|
||||
Reference in New Issue
Block a user