Sprintf Equivalent

Hello, I finally took a deep dive into RhinoScript. I am slowly finding my way after looking at sample scripts. However, I am having a bit of trouble formatting a string, which in turn writes to a file. I used to C program back in the days and often used Sprintf. Is there something that is equivalent in Rhinoscript ?

for example I have -

arrCurveStart = Rhino.CurveStartPoint(strObject)
strPoint = CStr(arrCurveStart(0))&" " & CStr(arrCurveStart(1))&" " & CStr(arrCurveStart(2)) 
objStream.WriteLine(strPoint)

which comes out as
“2.50213545249695 -2.49806545041767 0”

Is there a function in Rhinoscript, smiliar to C/C++ sprintf that would format a string to like this ?
“2.502 -2.498 0.000”

Thank you for reading.

Hi @gchliu,

Sorry, no. But this sample method, from the help file, might be useful.

https://developer.rhino3d.com/api/rhinoscript/sample_scripts/formatmessage.htm

I should add that a lot of users, who have used RhinoScript in the past, have migrated to Python.

You might check it out.

– Dale

Hi Dale

Thank you for the link to Python. I am looking at Python, which appears to be more versatile than the RhinoScript. While trying my first Python script using the sample “hello world” script, I ran into an error message. I am not sure what the problem is.

I will start a separate thread to understand the cause.

George