Text Field Arithmetic - Divide Point Coordinate by 1000

G’day,

How can I perform some basic arithmetic of dividing the Z coord result from a point coordinate text field by 1000? That sentence is a bit convoluted, field is below.

%<PointCoordinate(“19067630-7c14-4b72-bb53-9689f0b5672f”,“Z”)/1000>%

Something very weird is going on.
Text field on its own works as expected.
image
Division fails - Text object is hashed out
image
Addition fails - Text object is hashed out
Multiplication fails - see screenshot

This seems to be a string multiplication (2235.915 repeated 1000 times) rather than an arithmetic operation.

cheers,
Nick

Hi Nick - yep, I do not think there is any provision for that - I do not know that there could not be, but as far as I know it is not.

-Pascal

Internally PointCoordinate is a function that returns a string which I think may be a bug. @Trav and I will need to dig in little deeper to figure out if this really is the case and if it can be modified.

Since the function returns a string, you would currently need to convert that string back into a number for math to be performed on it. This would require placing PointCoordinate inside a float function to go from string to number.

%<float(PointCoordinate(“19067630-7c14-4b72-bb53-9689f0b5672f”,“Z”))/1000>%

Yeah it does some string formatting for displaying “X,Y,Z” if all three are checked but I am sure we can either add some overloads for different options or come up with something easier out of the gate. I’ve made a YT for it here so we can make sure to take a look.

https://mcneel.myjetbrains.com/youtrack/issue/RH-64016

Thanks for looking at this. The float conversion from string works well and I’d be happy for it to be the final solution. It might be confusing to alternately return strings or floats from the same text field.

Is this a standard Python function? Perhaps an amendment to the help would be sufficient.

image

cheers,
Nick

Hi Nick -

Float conversion doesn’t only apply to the PointCoordinate text field.
Further up on that page, you will find this section:

… where the “How to…” links to the “Convert strings to numbers” page.

Obviously, it’s not 100% discoverable but I’m not sure if that should be repeated for each text field on that page that returns a string that could be a number…
Perhaps that part should be moved to the “Math Support” section a bit further up?
-wim

My hope is we can eventually provide a simple formula editor for these text fields with features that would make this easier.

Ah, that’s where it is. Honestly, I was looking for something similar.

Agree.

Alternatively, perhaps document as per script functions and state the data type that is returned by each field.
Area (returns a Float)
Length (Float)
Coordinates (List of Strings or Single String)
BlockInstanceCount (Integer)
etc

Thank you for your help.
Nick