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.
Something very weird is going on.
Text field on its own works as expected.
Division fails - Text object is hashed out
Addition fails - Text object is hashed out
Multiplication fails - see screenshot
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.
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.
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.
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
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
Very useful, is there any way to change number of decimal places? wrapping PointCoordainte with float gave me two decimal digits, but I’m trying to get three.
This is beyond my level of comfort but it seems to work…
You first have to set your Document Properties -> Units -> Distance display -> Display precision to 1.000.
Note - if you don’t need to divide your result with 1000, that first step will suffice.
Then, add formatting to the string. According to the help file, both Python and .NET formatting can be used. Some trial-and-error shows that the following complete expression works fine:
Thank you, that’s really helpful, but for some reason it yielded four decimal places, not three. Replacing {:0} with {} yielded five, but I couldn’t get three