Insert Point with ID and Number- Rhinoscript

Dear All,

For a button in Rhino, I’m trying to write a tool with Rhinoscript to pick points in Rhino. My target is to name the point with a ID and a Text Entity and increment the number with the given starting value.

I am a beginner and could not increment the picked points numbers for instance from 100 to 104. My goal is to bake a text next to it with the same number.Insert-Coordinate-Name-Example.3dm (31.8 KB)
Coordinate Name_190429A.rvb (1.3 KB)

I hope somebody can help me with this script. The .rvb file and the rhino example(how it should look like) are available in the attachment.

Many Thanks,

J.Bijlstra

Hi @jbijlstra,

How about something like this?

Option Explicit

Call Main

Sub Main
	
	Dim nValue, bContinue
	Dim strObject, arrPoint, arrPlane
	
	nValue = Rhino.GetInteger("Starting value")
	If IsNull(nValue) Then Exit Sub
	
	bContinue = True
	While (bContinue)
		strObject = Rhino.GetObject("Select point", 1, False)
		If Not IsNull(strObject) Then
			Call Rhino.ObjectName(strObject, CStr(nValue))
			arrPoint = Rhino.PointCoordinates(strObject)
			arrPlane = Rhino.MovePlane(Rhino.ViewCPlane, arrPoint)
			Call Rhino.AddText(CStr(nValue), arrPlane, 300.0, "Arial", 0, 2)
			nValue = nValue + 1
		Else
			bContinue = False
		End If
	Wend

End Sub

– Dale

Hi,
If you are new to scripting then I suggest using Python (a :smiley: scripting language) rather than VBScript (a :frowning: scripting language) unless you have a good reason to prefer VBScript.
Graham

Hello Dale,

Thank you for the reply, the script works now! I think that you worked with strings instead of picking a point as an array. Is it possible to use ‘Rhino.GetPoint’ to place a point with a snap in a particular location and name it with an incrementing ID and Text?
I tried to translate the Text too by a Vector however it didn’t work(I commented in green). I put the rvb file in the attachment. Maybe you have time to look to it.

Many Thanks.Coordinate Name_190430.rvb (1.1 KB)

Jaap

Hello Graham,

Thank you for the message. I don’t know if Python is able to use the same commands out of Rhino as Rhinoscript?
I looked in the RhinoPythonPrimer, It looks like that it is possible to make Rhino toolbarbuttons with the use of Python?

Jaap

Yes the primer describes the rhinoscriptsyntax module in Python which is based upon the syntax of RhinoScript :smiley: - there are some differences and the usual frustrations when switching from one way of thinking to another but I found the transition very easy overall.

Yes you can attach a Python script to a toolbar button, either directly or via a _RunPythonScript call.

Python is a very popular choice for beginners due to the clear syntax and shallow learning curve. It is also extremely popular for many experienced coders because the language contains powerful feature when you need them like multiple inheritance, packaging, introspection, type hints, etc which allow you to be very productive without being limited in what you can produce. At some point you may wish to look beyond rhinscriptsynax to the underlying Python RhinoCommon libraries but that is for another day…

-g

Hello Graham,

Thank you for the information. I will try to figure out if Python is a good solution for programming rhino 3d operations.

Kind regards,

Jaap

You’re welcome :slight_smile: To put it much more simply and to quote the RhinoPython primer:

“Python offers exciting new potentials for programming in Rhino with Object-Oriented functionality, simple syntax, access to the .NET framework and a vast number of user-built libraries to extend Rhino’s functionality. The same powerful methods that were previously in VBscript are still available, as well as a ton of other exciting methods and features available natively with Python.”

1 Like