Rhino Script

I wanna pick two points and finaly must be like the picture

  1. draw 3d line
  2. Arrow head(line transform to arrow line)
  3. Meausere length
  4. M. Length value write with Dot to midpoint of the line

please help me

1 Like

hi Hakan,

here is a sample RhinoScript to do it:

    Option Explicit
    Call Main()
    Sub Main()
       
    	Dim arrP : arrP = Rhino.GetPoints(True,,,, 2)
    	If isnull(arrP) Then Exit Sub
    	If Ubound(arrP) <> 1 Then Exit Sub

    	Dim idL : idL = Rhino.AddLine(arrP(0), arrP(1))
    	Call Rhino.CurveArrows(idL, 3)

    	Dim idDot : idDot = Rhino.AddTextDot(Round(Rhino.CurveLength(idL), 2), Rhino.CurveMidPoint(idL))

    	Call Rhino.SelectObjects(array(idL, idDot))
    	
    End Sub

–jarek

2 Likes

thank you so much Jarek,
How can I use it ? how it working ? Sorry I dont now.

hi Hakan,

You can save the script file: DotArrow.rvb (515 Bytes)
anywhere on your HD and just drag-and-drop into Rhino viewport to run it.

It can also be placed on a button or added as Alias / command (let me know if you need help with that).
Another option is to open RhinoScript editor and paste the above code there (_EditScript command), and run the script from there.

It’s a simple one so maybe by looking at the code you can figure out what each steps does, and modify the script as needed (like number of digits for rounding the number - currently: 2).

cheers,

–jarek

2 Likes

yeeeeeeeees. this is it !.thanks so much.
Can I make Button.

sure, assume you know how to make/edit a new button (if not, take a look here: http://docs.mcneel.com/rhino/5/help/en-us/index.htm#toolbarsandmenus/toolbar_button_editor.htm#OpenButtonEditor)

In one of the Edit Button Command fields (left or right), paste this:
(it’s basically the script, but framed by _-Runscript ( … ) statement. That’s in general how you put scripts on buttons.

    _-Runscript (

    Option Explicit
        Call Main()
        Sub Main()
           
        	Dim arrP : arrP = Rhino.GetPoints(True,,,, 2)
        	If isnull(arrP) Then Exit Sub
        	If Ubound(arrP) <> 1 Then Exit Sub

        	Dim idL : idL = Rhino.AddLine(arrP(0), arrP(1))
        	Call Rhino.CurveArrows(idL, 3)

        	Dim idDot : idDot = Rhino.AddTextDot(Round(Rhino.CurveLength(idL), 2), Rhino.CurveMidPoint(idL))

        	Call Rhino.SelectObjects(array(idL, idDot))
        	
        End Sub

    )
2 Likes

I wouldn’t have done it without you. You are a great man.

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

1 Like