Creating a table in Visual Scripting [Gelöst]

Schlagworte:
  • Text
  • Decimals
  • Table

Hello.

I attached the print screen of a simple Visual Script that gets the numeric value of the Volume of a box. The value is '0.999999999' because the 'OperatorDivision' coverts the number from cubic millimeters in cubic meters. I have two questions:

1. How can I control the number of decimals, in case that I want only 2 or 3?

2. Is there a function that creates a simple table showing this information, for example a table with 1 row and 2 columns, one column having a text like "Volume" and the other column showing the variable with desired number of decimals, something like "0.99". There is a function named 'DrawTable', but I cannot make it work and I couldn't find any example showing how it works.

3. Can I concatenate a variable and a string like: "0.99 m3' ?

Thank you.

Anhänge (1)

Typ: image/png
219-mal heruntergeladen
Größe: 73,45 KiB

Lösung anzeigen Lösung verbergen

Zitiert von: horatios
1. How can I control the number of decimals, in case that I want only 2 or 3?

Currently, there is no dedicate node to do that. But you can try node FunctionX with some python function to do that, e.g.:
  • to round a number with 2 decimals:
    round(x,2)

  • to floor a number with 2 decimals:
    floor(x*100.0)/100.0

Zitiert von: horatios
2. Is there a function that creates a simple table showing this information, for example a table with 1 row and 2 columns, one column having a text like "Volume" and the other column showing the variable with desired number of decimals, something like "0.99". There is a function named 'DrawTable', but I cannot make it work and I couldn't find any example showing how it works.

Did you mean to see the value of a parameter directly? We are working on a function to watch the value, but for now tooltip may help a little bit here. Otherwise, you can try node Print. It will print value of a parameter to the trace window(be sure to let it start with Allplan), which will give you some more information, especially when it contains a list. But I'm not sure, if I got your point correctly.

Zitiert von: horatios
3. Can I concatenate a variable and a string like: "0.99 m3' ?

Yes. For that try the normal OperatorAddition, but make sure both inputs are String. For that you can use ConvertDataType to convert a double value to a string.

Please check attached screenshot for more details.

Product Owner API, Allplan GmbH

Anhänge (1)

Typ: image/png
237-mal heruntergeladen
Größe: 114,18 KiB

Zitiert von: horatios
1. How can I control the number of decimals, in case that I want only 2 or 3?

Currently, there is no dedicate node to do that. But you can try node FunctionX with some python function to do that, e.g.:
  • to round a number with 2 decimals:
    round(x,2)

  • to floor a number with 2 decimals:
    floor(x*100.0)/100.0

Zitiert von: horatios
2. Is there a function that creates a simple table showing this information, for example a table with 1 row and 2 columns, one column having a text like "Volume" and the other column showing the variable with desired number of decimals, something like "0.99". There is a function named 'DrawTable', but I cannot make it work and I couldn't find any example showing how it works.

Did you mean to see the value of a parameter directly? We are working on a function to watch the value, but for now tooltip may help a little bit here. Otherwise, you can try node Print. It will print value of a parameter to the trace window(be sure to let it start with Allplan), which will give you some more information, especially when it contains a list. But I'm not sure, if I got your point correctly.

Zitiert von: horatios
3. Can I concatenate a variable and a string like: "0.99 m3' ?

Yes. For that try the normal OperatorAddition, but make sure both inputs are String. For that you can use ConvertDataType to convert a double value to a string.

Please check attached screenshot for more details.

Product Owner API, Allplan GmbH

Anhänge (1)

Typ: image/png
237-mal heruntergeladen
Größe: 114,18 KiB