Extend or Shorten multiple curves at once


(Willem Derks) #1

Hi,

As an example of a topic with the intent of sharing a script I present this script:

Description:

This script will allow for multiple curves at once to be extended (or shortened) smoothly on both ends.
a negative Extension Length will shorten the curves.

Tags:
Extend Shorten Multiple Curves

wd_ExtendCurvesSmooth.rvb(1.3 KB)

When drag-dropping the script over Rhino it will automatically register an alias equal to the filename (without extension) Example: ScriptfileName.rvb will create the alias ScriptfileName
So you can change the filename at will. Do make sure the file remains in the folder you initially drag-dropped it from.

Option Explicit
'Script written by willemderks.com
'This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
'Script version Wednesday, May 15, 2013 11:20:43

'this script will allow for multiple curves at once to be extended (or shortened) smoothly on both ends.
'a negative Extension Length will shorten the curves

Call Rhino.AddAlias(Split(Split(Rhino.LastLoadedScriptFile, "\")(Ubound(split(Rhino.LastLoadedScriptFile, "\"))), ".")(0), "!_NoEcho _-Loadscript " & Chr(34) & Rhino.LastLoadedScriptFile & Chr(34))
Call Rhino.Print("Alias " & Split(Split(Rhino.LastLoadedScriptFile, "\")(Ubound(split(Rhino.LastLoadedScriptFile, "\"))), ".")(0) & " added to Rhino")

Private OLDdblCurveSmoothExtension
If isEmpty(OLDdblCurveSmoothExtension) Then OLDdblCurveSmoothExtension = 1

Call Main()
Sub Main()
	Dim arrCrv : arrCrv = Rhino.GetObjects("Curves to extend", 4, True, True, True)
	If IsNull(arrCrv) Then Exit Sub
	
	Dim dblLength : dblLength = Rhino.GetReal("Extension Length", OLDdblCurveSmoothExtension)
	If IsNull(dblLength) Then Exit Sub
	OLDdblCurveSmoothExtension = dblLength
	Call Rhino.EnableRedraw(False)
	Dim i
	For i=0 To Ubound(arrCrv)
		Call Rhino.ExtendCurveLength(arrCrv(i), 2, 2, dblLength)
	Next
	Call Rhino.EnableRedraw(True)	
	
End Sub

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

HTH
-Willem

PS
Can anyone tell me how to properly create a syntax highlighted code block that does not wrap lines?


Sharing Scripts
#2

Actually, it only appears to wrap with the display, if you copy/paste into a text editor, the lines unwrap correctly. However, @sam the addition of a horizontal scroll in code blocks could be an improvement to Discourse.

–Mitch