Archinect
anchor

rhinoscript.... multiple curve offset (have script, doesnt work)

i'm looking for a script, that i found, but doesnt work. i found it on the rhino wiki to offset multiple curves a set distance (either inwards, outwards, or both sides). the script is:

______________________________

Option Explicit
'Script written by G. C. Webster� (aka Guilherme Cozer Webster) in December, 2005, for Rhinoceros 3.0
' --> Based on Emilio Morello's ClosedCrvOffset script
' Contact: gcwebster@pop.com.br
' RhinoScript June 16, 2005
' Designed to offset more than one curve at the same time.
' Last revision: Jan 06
'-------------------------------------------------------------------------------------------------------------------------------------------------------

Function Inwards (strCrv, arrCrv, dblRadius, dblValue, strCorner, dblTol, arrTan, strLine, arrStartPt, arrEndPt, dblLineLength, dblExtend, arrDivPts, arrOffPt)
Inwards = Null

If Rhino.IsCircle (strCrv) Or Rhino.IsArc (strCrv) Then
dblRadius = Rhino.CurveRadius (strCrv, arrTan (0))
If dblRadius Rhino.DeleteObject (strLine)
Rhino.EnableRedraw (VBTrue)
Rhino.print "Unable to offset inwards, please choose a smaller value for this option."
Exit Function
End If
End If

If Rhino.IsPolyline (strCrv) Then

If dblLineLength dblExtend = dblValue - dblLineLength
Rhino.ExtendCurveLength strLine, 2, 1, dblExtend
arrEndPt = Rhino.CurveEndPoint (strLine)
Rhino.RotateObject strLine, arrEndPt, -90
arrOffPt = Rhino.CurveStartPoint (strLine)

ElseIf dblLineLength > dblValue Then
Rhino.RotateObject strLine, arrEndPt, -90
Rhino.ReverseCurve strLine
arrDivPts = Rhino.DivideCurveLength (strLine, dblValue)
If IsNull (arrDivPts) Then
arrOffPt = Rhino.CurveEndPoint (strLine)
Else
arrOffPt = arrDivPts (1)
End If

ElseIf dblLineLength = dblValue Then
Rhino.RotateObject strLine, arrEndPt, -90
arrOffPt = Rhino.CurveStartPoint (strLine)

End If

Else
Rhino.RotateObject strLine, arrStartPt, 90

If dblLineLength dblExtend = dblValue - dblLineLength
Rhino.ExtendCurveLength strLine, 2, 1, dblExtend
arrOffPt = Rhino.CurveEndPoint (strLine)

ElseIf dblLineLength > dblValue Then
arrDivPts = Rhino.DivideCurveLength (strLine, dblValue)
If IsNull (arrDivPts) Then
arrOffPt = Rhino.CurveEndPoint (strLine)
Else
arrOffPt = arrDivPts (1)
End If

ElseIf dblLineLength = dblValue Then
arrOffPt = Rhino.CurveEndPoint (strLine)

End If

End If

End Function

Function Outwards (strCrv, arrCrv, dblRadius, dblValue, strCorner, dblTol, arrTan, strLine, arrStartPt, arrEndPt, dblLineLength, dblExtend, arrDivPts, arrOffPt)
Outwards = Null

Rhino.RotateObject strLine, arrStartPt, -90

If dblLineLength dblExtend = dblValue - dblLineLength
Rhino.ExtendCurveLength strLine, 2, 1, dblExtend
arrOffPt = Rhino.CurveEndPoint (strLine)

ElseIf dblLineLength > dblValue Then
arrDivPts = Rhino.DivideCurveLength (strLine, dblValue)
If IsNull (arrDivPts) Then
arrOffPt = Rhino.CurveEndPoint (strLine)
Else
arrOffPt = arrDivPts (1)
End If

ElseIf dblLineLength = dblValue Then
arrOffPt = Rhino.CurveEndPoint (strLine)

End If

End Function

Function AddTanLine (arrTan, strCrv, arrStartPt, arrEndPt, strLine, dblLineLength)
AddTanLine = Null

arrTan = Rhino.CurveTangent (strCrv, 0)
arrStartPt = arrTan (0)
arrEndPt = arrTan (1)
strLine = Rhino.AddLine (arrStartPt, arrEndPt)
dblLineLength = Rhino.CurveLength (strLine)

End Function

Function AddOffset (strCrv, dblTol, strCorner, arrOffPt, arrResult, strResult, strLine)
AddOffset = Null

Rhino.UnselectAllObjects
Rhino.SelectObject (strCrv)
Rhino.command "NoEcho", False
Rhino.command "Offset Tolerance "&dblTol&" Corner "&Cstr(strCorner)&" ThroughPoint w"&Rhino.Pt2Str(arrOffPt), False
Rhino.UnselectAllObjects

arrResult = Rhino.LastCreatedObjects
strResult = arrResult (0)
Rhino.UnselectAllObjects
Rhino.DeleteObject (strLine)

End Function

'-------------------------------------------------------------------------------------------------------------------------------------------------------

Sub OffsetCrvs

Dim strCrv, arrCrv, dblRadius
Dim dblValue, arrSide(), strSide, arrCorner(), strCorner, dblTol
Dim arrTan, strLine, arrStartPt, arrEndPt, dblLineLength
Dim dblExtend, arrDivPts, arrOffPt, arrResult, strResult
Dim dblCrvLength, dblResultLength, dblVerify

arrCrv = Rhino.GetObjects ("Select curves to offset", 4, True, True, True)
If IsNull(arrCrv) Then Exit Sub

dblValue = Rhino.GetReal ("Enter distance to offset")
If IsNull(dblValue) Then Exit Sub

ReDim arrSide(2)
arrSide (0) = "Inwards"
arrSide (1) = "Outwards"
arrSide (2) = "Both"

strSide = Rhino.GetString ("Side to offset", "Outwards", arrSide)
If IsNull(strSide) Then Exit Sub

ReDim arrCorner(3)
arrCorner(0) = "Sharp"
arrCorner(1) = "Round"
arrCorner(2) = "Smooth"
arrCorner(3) = "Chamfer"

strCorner = Rhino.GetString ("Corner", "Sharp", arrCorner)
If IsNull(strCorner) Then Exit Sub

dblTol = Rhino.GetReal("Tolerance", Rhino.UnitAbsoluteTolerance, 0.000001)
If IsNull(dblTol) Then Exit Sub

Rhino.EnableRedraw (VBFalse)

Select Case strSide
Case "Inwards"

For each strCrv in arrCrv
AddTanLine arrTan, strCrv, arrStartPt, arrEndPt, strLine, dblLineLength
Inwards strCrv, arrCrv, dblRadius, dblValue, strCorner, dblTol, arrTan, strLine, arrStartPt, arrEndPt, dblLineLength, dblExtend, arrDivPts, arrOffPt
AddOffset strCrv, dblTol, strCorner, arrOffPt, arrResult, strResult, strLine
dblCrvLength = Rhino.CurveLength (strCrv)
dblResultLength = Rhino.CurveLength (strResult)
If dblCrvLength Rhino.ReverseCurve strCrv
Rhino.DeleteObject strResult
AddTanLine arrTan, strCrv, arrStartPt, arrEndPt, strLine, dblLineLength
Inwards strCrv, arrCrv, dblRadius, dblValue, strCorner, dblTol, arrTan, strLine, arrStartPt, arrEndPt, dblLineLength, dblExtend, arrDivPts, arrOffPt
AddOffset strCrv, dblTol, strCorner, arrOffPt, arrResult, strResult, strLine
Rhino.ReverseCurve strCrv
End If
Next

Case "Outwards"

For each strCrv in arrCrv
AddTanLine arrTan, strCrv, arrStartPt, arrEndPt, strLine, dblLineLength
Outwards strCrv, arrCrv, dblRadius, dblValue, strCorner, dblTol, arrTan, strLine, arrStartPt, arrEndPt, dblLineLength, dblExtend, arrDivPts, arrOffPt
AddOffset strCrv, dblTol, strCorner, arrOffPt, arrResult, strResult, strLine
dblCrvLength = Rhino.CurveLength (strCrv)
dblResultLength = Rhino.CurveLength (strResult)
If dblCrvLength > dblResultLength Then
Rhino.ReverseCurve strCrv
Rhino.DeleteObject strResult
AddTanLine arrTan, strCrv, arrStartPt, arrEndPt, strLine, dblLineLength
Outwards strCrv, arrCrv, dblRadius, dblValue, strCorner, dblTol, arrTan, strLine, arrStartPt, arrEndPt, dblLineLength, dblExtend, arrDivPts, arrOffPt
AddOffset strCrv, dblTol, strCorner, arrOffPt, arrResult, strResult, strLine
Rhino.ReverseCurve strCrv
End If
Next

Case "Both"

For each strCrv in arrCrv
AddTanLine arrTan, strCrv, arrStartPt, arrEndPt, strLine, dblLineLength
Inwards strCrv, arrCrv, dblRadius, dblValue, strCorner, dblTol, arrTan, strLine, arrStartPt, arrEndPt, dblLineLength, dblExtend, arrDivPts, arrOffPt
AddOffset strCrv, dblTol, strCorner, arrOffPt, arrResult, strResult, strLine
AddTanLine arrTan, strCrv, arrStartPt, arrEndPt, strLine, dblLineLength
Outwards strCrv, arrCrv, dblRadius, dblValue, strCorner, dblTol, arrTan, strLine, arrStartPt, arrEndPt, dblLineLength, dblExtend, arrDivPts, arrOffPt
AddOffset strCrv, dblTol, strCorner, arrOffPt, arrResult, strResult, strLine
Next

End Select

Rhino.EnableRedraw (VBTrue)

End Sub

SetLocale("en-us")

OffsetCrvs

________________

it goes through all the inputs and then gives me an error on line 104 saying "array required". this had to be made for rhino 3 so i dont know if it'll work on v4, will it?

i dont know scripting enough and havent done it in long enough to know the solution to this. can anyone fix this script (or recommend me another script that does the same thing?)


THANK YOU!!!!!

 
Apr 24, 08 6:45 pm
Antisthenes

u know PASCAL is the master right?

Apr 24, 08 7:01 pm  · 
 · 
beefeaters

Can you tell us what line 104 is? the lines of the script arent numbered and some get put onto the next line in this formatting.

Apr 24, 08 7:17 pm  · 
 · 
alucidwake

anti: i assume that PASCAL is a person? no i dont

sorry, i thought i put that in there.

LINE 104 =

strLine = Rhino.AddLine (arrStartPt, arrEndPt)

Apr 24, 08 8:14 pm  · 
 · 
FOG Lite

Might be better to ask the master over at McNeel, David Rutten.

Post it to the newsgroup and he'll probably have it back to you by tomorrow.


Rhino support

Apr 24, 08 11:47 pm  · 
 · 
Antisthenes

PASCAL is the tech support at the Rhinoceros newsgroups who has made many Rhino scripts for me that make my life wonderful, or David also.

Apr 25, 08 11:37 am  · 
 · 
aseid

doesnt andrew s know? i thought he was the scripting man

lol

man im really nervous about where rpi is going

Apr 28, 08 8:14 am  · 
 · 
aseid

sorry, just some weekend pent up anger over thesis work and the current state of architectural education

ill digress

Apr 28, 08 8:17 am  · 
 · 
alucidwake

um ngai would know more than saunders and honestly to make a script to do this in rhino 4 isnt hard, i just dont know scripting enough (i tried to make a script, didnt work)

on a what seems to be a completely unrelated note... why are you nervous about where rpi is going?

its in a serious state of transition. the future for us is COMPLETELY unknown, it all depends on who gets the reigns

honestly im nervous/pissed at where rpi is right now. every professor if they're something in the school is either domineering and imposing on their students or doesnt care because theyre too preoccupied with something else

austin: are you a thesis student currently? you work with fareh?

Apr 28, 08 8:19 am  · 
 · 
alucidwake

austin: sorry to hear it didnt go so well :( i dont know what you feel about our professors or our direction (basically bell vs saunders in terms of style) but i agree with you in your anger towards education. the beauracracy is killing me

Apr 28, 08 8:22 am  · 
 · 
aseid

yes i work with fareh, ive sat on reviews there, ive seen a lot of great work, ive seen some eh work, but when i was in school, i had good work, great work and EH work as well so im not commenting on that, everyone has a moment or moments where they do some amazing things, some people are just amazing all the time, other projects are COOL! some are IMPORTANT

you say

"its in a serious state of transition. the future for us is COMPLETELY unknown, it all depends on who gets the reigns", i think it depends on the student, your cycle is too short for you to let the school be the only factor affecting where you go

when i was in school, and i hate to be nostalgic and imposing, so ill try not to do that, because every class is somewhat different and responsive to a specific form of curriculum and spirit of the times in which that schools pedagogy is somewhat shaping the student body

I didnt even talk to my dean, i didnt ever associate with my teachers other than during crit, i dont think any of us did outside of class, we did work, we presented, we got critted, we came back, we did more, then it was all over

our styles or processes grew as per our own will to discover, to experiment with medium and method, moving from one concept and transforming the notion through the use of the tools in the shop, and in our boxes, the teacher never told us how to do something, they "hinted" at where to go and they lightly shoved us around to get to that place, if we were getting tangential they roped us in.

i went to UPENN between 2000-2003 and we were also in a state of transiton, its changed so much since we were there, and you know i am not in anyway saying that the technology is bad, I think its great, but I am unsure how students are working with eachother to use it. I am marveled everyday about how new processes are changing our business.

im not a scripting hater! so please dont label me as that, some people really just dont like the stuff, and i think thats a poor attitude and a resistant one, and its really not going to get anyone anywhere, but when you dont know a piece of code or something like this occurs, what do you do, do you sit around and try to figure it out, ask everyone you know, go on grouups to find the answer, shit if I sat here and waited to find someone to help me figure out everything i needed to do, i would be out of a job and my clients would be walking away

you have to drive the work, dont let some piece of code make your work happen, you have to be the creator, not the code, if you cant code it, freaking draw it, get it done, get it out, find another medium



Apr 28, 08 8:45 am  · 
 · 
aseid

well maybe not another medium, because I know that once you start a model in the computer and youre in the groove, youre working with these networks of geometries and they are all dependent on each other, but i and once you divert your attention from the model to a sketch or drawings, you lose the interactivity and you cant drive a CNC machine or lasercutter which every student is so attached to these days....I dont want to learn about code, i want to learn about architecture, the lines are so blurry, one might say, well code is architecture and its effects are the virtual work and when we build it it is a tangible manifestation of the code, totally agree, but as Eric Owen Moss said in that recent interview, are we a trade school? are we teaching code? no, i dont think so, just like we are not teaching drafting

Apr 28, 08 8:54 am  · 
 · 
alucidwake

austin, i either agree with what you say or have a similar experience

i make sure i don't associate myself with any specific stylistic features. scripting is an amazing TOOL, a means, not an ends.

i do associate with my teachers, ive had a good relationship with a professor from last year and a very good relationship with my current professor

i'm confused as to what you are, a thesis student, grad student, guest reviewer?

on the topic of the student vs who gets the reins, i'd like to state something that has made me eternally hate the professors at this school. we had our awards ceremony the other day. i have never been one to follow a teacher, and have had some amazing projects because of that on multiple occasions. last semester i spent in rome with saunders. ive never worked so hard in my life. it was a very tumultuous studio experience but in the end i came out with a simply amazing project. it was a scripting studio but it was the only project to not be dominated by scripting, but to have it as an element (structural column system). the professors who have seen it loved it. saunders in the end really liked it. people i have interviewed with said it was "poetry". at the end of that semester i ended up with my best gpa yet, ranking #1 in the class (due to an a- in studio, i honestly feel like he grades based on what he wants to give you, not what you deserve, as he said my first project was "beautiful" and truly pushed the "experiment" to its limits, a compliment very rarely given by him).

so the awards ceremony came around. i have a very good relationship with my current professor; we talk outside of studio, we're very friendly towards each other. normally a professor recommends people for awards each year.

this year, two other people who went to rome with me, and are in my section got awards. both of these people did not expect to get these awards. both of them have slacked severely this semester (thus causing my professor to lose the liking he once had for them) and last semester slacked as well and had mediocre projects (as per their reviews and general consensus)

i fail to see the logic aside from that they are both, as well as EVERY other student who got an award from my year a vocal favorite of professor bell. they have all relied greatly and have gone to him whenever they need help. i never have. i have always viewed him as just another professor who has a very specific style, pushes it on his students to an extent where they feel like their project isnt theirs, but is very wise and smart in terms of spatial planning. he was my second choice for studios this semester. i dont worship him

im sorry for all this ranting as it really has no point. nothing can come of my situation aside from "try again next year". ive been so fucking pissed about this blatant favoritism in clear sight that if you have even read this far i thank you and an curious if you have any comments on this situation

Apr 28, 08 9:20 am  · 
 · 
alucidwake

oh RPI's immense downfall is that we skip the fundamentals of architecture and run head first into the wall of scripting where we make shit because it looks cool but thats all it is.

i hate it. i cant stand it. i wish there was a word i could think of to explain my disgust for this (but after about 4 weeks of approximately 5 hours of sleep a night but recently MUCH less, i am lost for words, i.e. slept maybe 8 hours in the past 5 days)

i vowed never to do it. i stand by my words

as soon as the lecture posted for the AA's symposium "critique of the new" came up i took it. technology is pushing architecture to places its never been pushed before. but how are we supposed to be architects when its what were told is good and taught is right so early, without having a true appreciation and understanding of the fundamentals of architecture (but of course this is all assumed that we know already by everyone of this school of thought)

Apr 28, 08 9:24 am  · 
 · 
aseid

lucid, i didnt mean to hijack your script thread, i think you are lucky to be at RPI, you have a group of amazing professors, and the situation you describe is similar at all unis, politics and stuff, Ive met many of the RPI professors and they are all on top of their game and work very hard and go to great lengths to educate you all, no matter what the students think they do care about you guys, I was just saying that dont let a line of code stand in the way of you being an architect, find a workaround

thats all,

good luck and enjoy the rest of your semester

Apr 28, 08 9:44 am  · 
 · 
alucidwake

oh hah. the reason why i wanted the code is so i wouldnt have to manually offset each line :p scripting is great when it works. when it doesnt its not worth it.

yes i know we have some great professors. parsons is retiring, which is going to be rough. we are getting some new visiting people, my current professor, who is an AMAZING professor. some other new people are good in some areas lacking in others.

thanks for the wishes. now lets hope i can stay up for as long as i need to

Apr 28, 08 9:48 am  · 
 · 

Block this user


Are you sure you want to block this user and hide all related comments throughout the site?

Archinect


This is your first comment on Archinect. Your comment will be visible once approved.

  • ×Search in: