Wish: Shorten Curve

Does this already exist? It would work in the same way as ‘SubCrv’ but only require one input and shorten the curve by removing the portion between the pick point and the closest end.

Maybe a separate command, but an option to remove a set distance would be useful too, opposite to the way ‘Extend’ works.

Hi Brian,

This is possible, yet indeed somewhat hidden:
If you run Extend, ( no pre-selection and hit enter to skip boundary object selection)
Now just input a negative number to shorten.

Sorry, I re-read your post and there is indeed no way to pick a point, just numerical input.

Functionality imo would be sightly different:

shorten the curve by removing the portion between the pick point and the selected end.
The user would have to “select curve at end to shorten” and next pick a point
That way one could shorten beyond the curve middle.

_Willem

Brian/Willem, doesn’t this describe the way deletesubcrv works? Sure you’ve got two inputs normally, but your numerical is there as well.

Hi Brian
Try the below VBScript:
Ciao VittorioShort_Extend_Line.txt (2.4 KB)

-runscript (
'************************ estende curva (linea) senza join alla Megacad*************************
sub rtn
la=“asd34gd”
do
do
Rhino.command(“pointsOff”),0
re=rhino.getcurveobject(“seleziona linea vicino all’estremo che vuoi estendere per terminare”) '********** restituisce un’array di informazioni sulla curva
if vartype(re)=vbnull then exit sub

if isnull(re) then exit sub
cu=re(0) '***** id della curva
if not Rhino.isline(cu) then exit sub
u=re(4) '****** parametro che dà la posizione del punto in cui si è cliccato rispetto al dominio della curva

dm=rhino.curvedomain(cu) '************** restituisce 2 valori estremi della curva il minore dm(0) corrisponde allo Start Point
'msgbox "dominio = “&dm(0)&” "&dm(1)
vmedio=(dm(0)+dm(1))/2 '************ punto di mezzo del dominio ***************
'msgbox “vmedio=”&cstr(vmedio)
if u<=vmedio then p1=rhino.curvestartpoint(cu) else p1=rhino.curveendpoint(cu) '******* controlla se il punto in cui si è cliccato è più vicino
'******** allo Start o End point della curva e restituisce il punto p1
if u<=vmedio then
u=dm(0)
setdir=0
else
u=dm(1) '********* restituisce il parametro(relativo al dominio) dell’estremo della curva scelto
setdir=1 '********* setta l’orientamento della curva per selezionare lo Start o End point della linea
end if
'msgbox cstr(u)

ps=rhino.curvetangent(cu,u) '****** restituisce un versore (array di tre valori x,y,z) tangente all’estremo scelto della curva
'*************** determino il secondo punto per stabilire la direzione tangente della linea di prolungamento
ps1=p1
ps1(0)=ps1(0)+ps(0)
ps1(1)=ps1(1)+ps(1)
ps1(2)=ps1(2)+ps(2)

'******************** disegna il segmento di prolungamento****************
Rhino.EnableObjectGrips re(0), true

la=rhino.firstobject
rhino.command"line angled w"&rhino.pt2str(p1)&" w"&rhino.pt2str(ps1)&" 0",0
rhino.enableredraw vbfalse
lu=rhino.firstobject
'msgbox la&vbnewline&lu
loop while la=lu
'if la=lu then exit do
if rhino.isline(lu) then
pu=rhino.curveEndpoint(lu)
newcu=Rhino.ObjectGripLocation (re(0), setDir, pu)

End if

rhino.deleteObject lu
Rhino.EnableObjectGrips re(0), false
rhino.enableredraw vbtrue
loop
end sub
rtn
Rhino.command(“pointsOff”),0
)

Thanks Carvecream, that command fulfills the wish nicely… wish withdrawn,

and thanks for sharing Vittorio, your script makes line adjustment in both directions very efficient. There seems to be a small problem with the grips losing alignment from the line where the angle is neither 45 or 90?

Hi Brian
in the line 43 you must modfy rhino.pt2str(p1) with rhino.pt2str(p1,10) for increase the precision

Line 43 ok is: rhino.command"line angled w" & rhino.pt2str(p1, 10) & " w" & rhino.pt2str(ps1, 10) & " 0", 0
Ciao Vittorio

Grazie Vittorio, perfect now, this is a really nice script.

How do I load this?