How create a button with a script?

Hi everybody!
I’m serching a way to edit a new button so that the command run a script but it seems to not work anyway…
can someone help me?
thks a lot,
Marco

Hi marco- for RhinoScipt the macro to use will be something like one of these:

! _-Runscript (
full script text in here
)

! _-Runscript "Path to script file in double quotes"

! --Runscript ("name of script subroutine")

What to use depends upon how the script is designed - do you have an example script?

For a Python script use ! _-RunPythonScript ( "Path to scriptFile.py)

Any of that work?

-Pascal

Hi Pascal!
here I copy the text of the script:

Option Explicit

Call Main()
Sub Main()

Dim strSrf, arrPt, arrParam, arrNormal, arrScale, arrAdd

strSrf = Rhino.GetObject("select srf", 8, True, False)
If IsNull(strSrf) Then Exit Sub	

arrPt = Rhino.GetPointOnSurface(strSrf)
If IsNull(arrPt) Then Exit Sub

' get surface uv parameter at this point
arrParam = Rhino.SurfaceClosestPoint(strSrf, arrPt)

' get surface normal vector at this paramter
arrNormal = Rhino.SurfaceNormal(strSrf, arrParam)

' scale normal vector to desired line length eg. 10.0
arrScale = Rhino.VectorScale(arrNormal, 10.0)

' add scaled vector to point on surface
arrAdd = Rhino.VectorAdd(arrScale, arrPt)

' create line between both points
Call Rhino.AddLine(arrPt, arrAdd)

End Sub

so to insert in a command of a new button It’s correct so:

! _-Runscipt (Option Explicit

Call Main()
Sub Main()

Dim strSrf, arrPt, arrParam, arrNormal, arrScale, arrAdd

strSrf = Rhino.GetObject("select srf", 8, True, False)
If IsNull(strSrf) Then Exit Sub	

arrPt = Rhino.GetPointOnSurface(strSrf)
If IsNull(arrPt) Then Exit Sub

' get surface uv parameter at this point
arrParam = Rhino.SurfaceClosestPoint(strSrf, arrPt)

' get surface normal vector at this paramter
arrNormal = Rhino.SurfaceNormal(strSrf, arrParam)

' scale normal vector to desired line length eg. 10.0
arrScale = Rhino.VectorScale(arrNormal, 10.0)

' add scaled vector to point on surface
arrAdd = Rhino.VectorAdd(arrScale, arrPt)

' create line between both points
Call Rhino.AddLine(arrPt, arrAdd)

End Sub)

??
thks,
Marco

1 Like

but in this way It seems to not work… :frowning:

Hi Marco - yes, but is

! _-Runscript , and not ! _-Runscipt as I wrote… I’ll fix my post, sorry.

-Pascal

1 Like

Perfect! you are Great! :slight_smile:

1 Like