Rhino Script

excuse me, why did you write “Call” before a command, does it works without?

1 Like

– Dale

1 Like

It’s a personal preference. Can be done both ways:

Call Rhino.CurveArrows(idL, 3)

or

Rhino.CurveArrows idL, 3

I prefer using Call as it is visually cleaner for me to have the arguments in parenthesis.

1 Like

This sicript very usefull for me. Bur script not work. :disappointed:
Please help me !

This script very usefulla for me. But it not works and show me two wrong message.
Please help me?


Hi Hakan,

Looks like your RhinoScript plugin got damaged (that’s Rhino plugin that allows any RhinoScript to run). Unfortunately that has been happening and I see still happening recently especially when Rhino 7 is installed. What version of Rhino are you having this error with?
What should fix it is repairing Rhino install from the Windows Apps and Features. After running Repair, make sure RhinoScript plugin is loaded from Toos > Options > Plugins > RhinoScript.rhp.
That should fix it.

–jarek

2 Likes

I LOVE THIS MACRO.
But I will have a request. Ineed a macro. like the Macro here.

Measure the polycurve by Length Command
Make arrow to the ends of the polycurve
Make dot in the mid point of the polycurve
Write the length of the plycurve in the dot.

please help me

I use rhino 7. I have no problem

Hi Hakan,

Here is the script that should do it (works with multiple curves at once. If you need to change the rounding method it is commented there, I made “2” as default.
Also, if you need this on a button, you may need to add: -_RunScript ( … ) lines as the other one does.

Call Main()
Sub Main()

	'change this for different rounding 
	Dim intRound:  intRound = 2
	
	Dim arrC : arrC = Rhino.GetObjects("Curves?", 4,, True)
	If isnull(arrC) Then Exit Sub
	
	Dim i
	Rhino.EnableRedraw False
	For i=0 To Ubound(arrC)
		Call Rhino.AddTextDot(Round(Rhino.CurveLength(arrC(i)), intRound), Rhino.CurveMidPoint(arrC(i)))
		Call Rhino.CurveArrows(arrC(i), 3)
	Next
	Rhino.EnableRedraw True
	
End Sub

hth,

–jarek

1 Like

:+1: :+1: :+1: :heart: :heart: :heart:
Thank you so much. You are a very wonderful person.
These kinds of solutions work very well for me.
How can I learn. Where should I start?

hi Hakan,

Long time ago I learned scripting from this great primer:
RhinoScript 101 [McNeel Wiki]
It took a little initial effort since I did not have any coding background, but it was a time well invested.

These days most people would probably advise you to learn Python instead of RhinoScript to do scripting in Rhino - in a long run it is much more powerful, but on a basic level they both work well:
Rhino.Python 101 with unset (rhino3d.com)

All developer resources are here, for both basic scripting and advanced programming:
Rhino and Grasshopper Developer Documentation (rhino3d.com)

I would say pick a language (RhinoScript vs Python) and start with reading the 101 Primer with some basic exercises.

cheers,

–jarek

2 Likes

Thank you so much.
I will do this

1 Like

Dear Jarek and everyone, !
I hope you see my message. This scrip wonderfull .
Again, we owe you a big thank you.
Dear Jarek and everyone !
I want to add my section command in front of this script.
So when you make a section, it will do what this script does.
I would be very happy if someone could do this.

Hi Hakan,
I am not sure I follow - so you want to have the _Section command run and instantly run the script on all resulting section curves?

Like this:

Option Explicit

Call Main()
Sub Main()

	Call Rhino.Command("_Section _MultiPause")
	If Rhino.LastCommandResult() = 0 Then
	
		'change this for different rounding 
		Dim intRound:  intRound = 2
	
		Dim arrC : arrC = Rhino.SelectedObjects()
		If isnull(arrC) Then Exit Sub
		Dim i
		Rhino.EnableRedraw False
		For i=0 To Ubound(arrC)
			If Rhino.IsCurve(arrC(i)) Then
				Call Rhino.AddTextDot(Round(Rhino.CurveLength(arrC(i)), intRound), Rhino.CurveMidPoint(arrC(i)))
				Call Rhino.CurveArrows(arrC(i), 3)
			End If
		Next
		Rhino.EnableRedraw True
	
	End If
	
	
End Sub
1 Like

Hi Jarek,
When you get a section, make an arrow + measure + write the measurement result with dot.
Sorry my english is very bad.

Yeeees. Thank you so muck Jarek.

This script works so well for me. I am very happy for that. I have one more question regarding this. For example, I want 123, not 123.23. So it should not show beyond the point. What changes should be made in the code?

hi Hakan,

if you look at the script code, there is this section:

'change this for different rounding 
		Dim intRound:  intRound = 2

#2 is the # of decimal places for rounding. Simply change this to 0 in the script text and you should get only whole numbers. Does it help ?

Thank you very much dear Jarek.
How can I learn about macro, scripting? I am learning Python. But I don’t know how to use it with Rhino.
Where should I start?
Can you give me the source?

hi Hakan,

Python is definitely a way to go with Rhino these days. We discussed it before, I listed some reasources in this very post…
I would start with the 101 Primer of Python for Rhino and then just ask away in this forum - a lot of people should be able to help. The hardest part is to get started.