Public Function VectorUnitize(v)
VectorUnitize = Null
If Not IsArray(v) Or (UBound(v)<>2) Then Exit Function
Dim dist, x, y, z, x2, y2, z2
x = v(0) : y = v(1) : z = v(2)
x2 = x * x : y2 = y * y : z2 = z * z
dist = x2 + y2 + z2
If (dist< 0.0) Then Exit Function
dist = Sqr(dist)
x = x / dist
y = y / dist
z = z / dist
VectorUnitize = Array(x, y, z)
End Function
Public Function VectorNegate(v)
VectorNegate = Null
If Not IsArray(v) Or (UBound(v) <> 2) Then Exit Function
VectorNegate = Array(-v(0), -v(1), -v(2))
End Function
Public Function VectorCrossProduct(v1, v2)
VectorCrossProduct = Null
If Not IsArray(v1) Or (UBound(v1)<> 2) Then Exit Function
If Not IsArray(v2) Or (UBound(v2)<> 2) Then Exit Function
Dim x, y, z
x = v1(1)* v2(2) - v1(2)* v2(1)
y = v1(2)* v2(0) - v1(0)* v2(2)
z = v1(0)* v2(1) - v1(1)* v2(0)
VectorCrossProduct = Array(x, y, z)
End Function
Public Function VectorScale(v, d)
VectorScale = Null
If Not IsArray(v)Or (UBound(v)<> 2) Then Exit Function
If Not IsNumeric(d) Then Exit Function
VectorScale = Array(v(0) * d, v(1) * d, v(2) * d)
End Function
Public Function PointAddVector(p, v)
PointAddVector = Null
If Not IsArray(p) Or (UBound(p)<> 2) Then Exit Function
If Not IsArray(v) Or (UBound(v)<> 2) Then Exit Function
PointAddVector = Array(p(0)+ v(0),p(1)+ v(1),p(2)+ v(2))
End Function
------------------------------------------------------------------------------
who are you MArch n'umeplyed...I can tell from your name because the equivalent phrase "unemployed MArch1" pretty much describes 97% the global student body
oh haha I know now..yeah...I was torn between the rhinoscipting and the grasshopper workshop ... those people have no idea how much money they coudl have made doing these workshops ...such high demand for it here on the west coast
Ff30 I will check it as soon as I get home. it worked fine last time I ran it. I will check as soon as I get by my computer. I am actually posting from cell phone. As for the workshop in SF. I will be there as well- I decided to sit in the advance grasshopper. I have a few friends who decided to sit in the scripting as well.
I dont know how familiar you are with grasshopper, but I figure grasshopper would be much easier to create as well as to change sizes parametrically. So Hear you go....and let me know if you have any issues with it.
As a member of the aforementioned ucla nerd posse and former Potrero Hill resident, Im totally juiced about a possible Archinect meetup in the old 'hood! For a coffee/pastry sort of deal, we could hit up Farley's on 18th st & Texas, or if were looking for drinks theres the Connecticut Yankee @ 17th & Connecticut...
Perhaps a separate posting is in order so as to not intrude on Cruzer's pipes?
diff,
Your the man... yeah I am familiar with Grasshopper..I just never caught wind of this definition before now is all. Thanks a heap.
I definitely owe you a beer or coffee when I see you!
witty,
why is that everyone I meet from San Franciso, always spends like 20 minutes rattling off favorite places to eat and drink , when I mention I am going to visit. You people are out of control with your knowledge of the "best spots"...LOL . Bay Area ppl are crazy about their restaurants!
I am sure we will have the best food tour of our life that weekend.
I was only able to figure out how to apply it to single curves, which is probably not what you are looking for (since that would be the same as modeling individually on rhino). But if you still wanted -here is what I got
When I get home tonight I will see how I can apply it to multiple curves.
Feb 16, 09 2:41 pm ·
·
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.
Rhinoscript: Square Pipes
Cant get this to work:
http://en.wiki.mcneel.com/default.aspx/McNeel/RsSquarePipe.html
anyone have this already?...(I'll share some other scripts with you, if you do)
by definition, aren't pipes cylindrical, tubes can be cylindrical or rectangular?
ff33
here you go it should work now
--------------------------------------------------------
Option Explicit
Call SquarePipe()
Sub SquarePipe
Dim strCrv
strCrv = Rhino.GetObject("Select curve", 4)
If IsNull(strCrv) Then Exit Sub
Dim dblLength
dblLength = Rhino.GetReal("Length of sides",1.0,0.0)
If Not IsNumeric(dblLength) Or dblLength <= 0 Then Exit Sub
Dim arrStart
arrStart = Rhino.CurveStartPoint(strCrv)
Dim dblParam
dblParam = Rhino.CurveClosestPoint(strCrv,arrStart)
Dim arrCurvature
arrCurvature = Rhino.CurveCurvature(strCrv,dblParam)
Dim arrX, arrY, arrZ
arrZ = VectorUnitize(arrCurvature(1))
arrX = VectorUnitize(arrCurvature(4))
arrY = VectorUnitize(VectorCrossProduct(arrZ,arrX))
arrX = VectorScale(arrX,dblLength)
arrY = VectorScale(arrY,dblLength)
Dim x0, x1, y0, y1
x0 = PointAddVector(arrStart,arrX)
x1 = PointAddVector(arrStart,VectorNegate(arrX))
y0 = PointAddVector(arrStart,arrY)
y1 = PointAddVector(arrStart,VectorNegate(arrY))
Dim arrPoints(4)
arrPoints(0) = PointAddVector(x0,VectorNegate(arrY))
arrPoints(1) = PointAddVector(y1,VectorNegate(arrX))
arrPoints(2) = PointAddVector(x1,arrY)
arrPoints(3) = PointAddVector(y0,arrX)
arrPoints(4) = arrPoints(0)
Dim strSqr
strSqr = Rhino.AddPolyline(arrPoints)
Rhino.ExtrudeCurve strSqr, strCrv
Rhino.DeleteObject strSqr
End Sub
Public Function VectorUnitize(v)
VectorUnitize = Null
If Not IsArray(v) Or (UBound(v)<>2) Then Exit Function
Dim dist, x, y, z, x2, y2, z2
x = v(0) : y = v(1) : z = v(2)
x2 = x * x : y2 = y * y : z2 = z * z
dist = x2 + y2 + z2
If (dist< 0.0) Then Exit Function
dist = Sqr(dist)
x = x / dist
y = y / dist
z = z / dist
VectorUnitize = Array(x, y, z)
End Function
Public Function VectorNegate(v)
VectorNegate = Null
If Not IsArray(v) Or (UBound(v) <> 2) Then Exit Function
VectorNegate = Array(-v(0), -v(1), -v(2))
End Function
Public Function VectorCrossProduct(v1, v2)
VectorCrossProduct = Null
If Not IsArray(v1) Or (UBound(v1)<> 2) Then Exit Function
If Not IsArray(v2) Or (UBound(v2)<> 2) Then Exit Function
Dim x, y, z
x = v1(1)* v2(2) - v1(2)* v2(1)
y = v1(2)* v2(0) - v1(0)* v2(2)
z = v1(0)* v2(1) - v1(1)* v2(0)
VectorCrossProduct = Array(x, y, z)
End Function
Public Function VectorScale(v, d)
VectorScale = Null
If Not IsArray(v)Or (UBound(v)<> 2) Then Exit Function
If Not IsNumeric(d) Then Exit Function
VectorScale = Array(v(0) * d, v(1) * d, v(2) * d)
End Function
Public Function PointAddVector(p, v)
PointAddVector = Null
If Not IsArray(p) Or (UBound(p)<> 2) Then Exit Function
If Not IsArray(v) Or (UBound(v)<> 2) Then Exit Function
PointAddVector = Array(p(0)+ v(0),p(1)+ v(1),p(2)+ v(2))
End Function
------------------------------------------------------------------------------
or use grasshopper
diff,
Thanks a million...I can't thank you enough..I am still green on debugging..Maybe teh workshop in March with Mark Fornes will get me jump started .
I still get an error message = "Line 27 Type mismatch arrCuvature"
doesn't work for me yet!?
MC - you got into the scripting workshop? i missed out, but will be there for the advanced grasshopper - see you there
who are you MArch n'umeplyed...I can tell from your name because the equivalent phrase "unemployed MArch1" pretty much describes 97% the global student body
you taught me revit...
oh haha I know now..yeah...I was torn between the rhinoscipting and the grasshopper workshop ... those people have no idea how much money they coudl have made doing these workshops ...such high demand for it here on the west coast
i know, $50 is a felony...see you there!
Ff30 I will check it as soon as I get home. it worked fine last time I ran it. I will check as soon as I get by my computer. I am actually posting from cell phone. As for the workshop in SF. I will be there as well- I decided to sit in the advance grasshopper. I have a few friends who decided to sit in the scripting as well.
Maybe some type of meetup would be cool
good idea
are you going too anti?
word
Sounds like an archinect meet up
nice..I 'll be there with my posse form UCLA....all kinds of nerdz...lets do an archinect meetup...never technically done one before.
nor have i, i'll have a berkeley group of 5
ff33º
I dont know how familiar you are with grasshopper, but I figure grasshopper would be much easier to create as well as to change sizes parametrically. So Hear you go....and let me know if you have any issues with it.
you can download the grasshopper file here
As a member of the aforementioned ucla nerd posse and former Potrero Hill resident, Im totally juiced about a possible Archinect meetup in the old 'hood! For a coffee/pastry sort of deal, we could hit up Farley's on 18th st & Texas, or if were looking for drinks theres the Connecticut Yankee @ 17th & Connecticut...
Perhaps a separate posting is in order so as to not intrude on Cruzer's pipes?
diff,
Your the man... yeah I am familiar with Grasshopper..I just never caught wind of this definition before now is all. Thanks a heap.
I definitely owe you a beer or coffee when I see you!
witty,
why is that everyone I meet from San Franciso, always spends like 20 minutes rattling off favorite places to eat and drink , when I mention I am going to visit. You people are out of control with your knowledge of the "best spots"...LOL . Bay Area ppl are crazy about their restaurants!
I am sure we will have the best food tour of our life that weekend.
now I am trying to get it to work with curves that are not straight....any thoughts
ff33º
I was only able to figure out how to apply it to single curves, which is probably not what you are looking for (since that would be the same as modeling individually on rhino). But if you still wanted -here is what I got
When I get home tonight I will see how I can apply it to multiple curves.
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.