Grasshopper

algorithmic modeling for Rhino

surface divide

Views: 1441

Comment

You need to be a member of Grasshopper to add comments!

Comment by Rogozinski Wladimir on July 5, 2012 at 11:26am

Option Explicit

'Script written by Rogozinski Wladimir
'Script copyrighted Rogozinski Wladimir
'Script version 5 июля 2012 г. 17:07:04

Call UniformSurfasePoints()

Sub UniformSurfasePoints()

Dim strObject,arrEdgeCurve,ListText(0),ListValue(0),ListResult,Rows,dblLength,arrPointsX,arrPointsY

Dim arrParameter,i,j,IsoCurveX(),IsoCurveY(),arrSurfPnt()

strObject = Rhino.GetObject("Select surface or polysurface", 24)

Rhino.EnableRedraw(False)

Rows = 10

ListText(0) = "Number rows in structure"

ListValue(0) = CStr(Rows)

ListResult = Rhino.PropertyListBox(ListText, ListValue, "Settings: ","Surfase Properties")

If Not IsArray(ListResult) Then Exit Sub

If IsNumeric(ListResult(0)) Then

Rows = CInt(ListResult(0))

Else

Rows = 10

End If

Rows = Rows - 1

If Not IsNull(strObject) Then

arrEdgeCurve = Rhino.DuplicateEdgeCurves (strObject)

dblLength = Rhino.CurveLength(arrEdgeCurve(0)) / Rows

arrPointsX = Rhino.DivideCurveLength(arrEdgeCurve(0), dblLength)

End If

If Not IsNull(strObject) Then

arrEdgeCurve = Rhino.DuplicateEdgeCurves (strObject)

dblLength = Rhino.CurveLength(arrEdgeCurve(1)) / Rows

arrPointsY = Rhino.DivideCurveLength(arrEdgeCurve(1), dblLength)

End If

For i=0 To Rows

arrParameter = Rhino.SurfaceClosestPoint(strObject, arrPointsX(i))

ReDim Preserve IsoCurveX(i)

IsoCurveX(i) = Rhino.ExtractIsoCurve (strObject, arrParameter , 1)

Next

Rhino.DeleteObjects arrEdgeCurve

For i=0 To Rows

arrParameter = Rhino.SurfaceClosestPoint(strObject, arrPointsY(i))

ReDim Preserve IsoCurveY(i)

IsoCurveY(i) = Rhino.ExtractIsoCurve (strObject, arrParameter , 0)

Next

For i=0 To Rows

For j=0 To Rows

ReDim Preserve arrSurfPnt(j)

arrSurfPnt(j) = Rhino.CurveCurveIntersection(IsoCurveX(i)(0), IsoCurveY(j)(0))

Rhino.AddPoint arrSurfPnt(j)(0,1)

Next

Next

For i=0 To Rows

Rhino.DeleteObjects IsoCurveX(i)

Rhino.DeleteObjects IsoCurveY(i)

Next

Rhino.EnableRedraw(True)

End Sub

Comment by Daniel Kautz on January 31, 2012 at 10:53pm

Why dont you just rebuild?

Comment by Behnood Eghbali on January 30, 2012 at 1:09am

nice, thx ;)

Comment by Jonah Hawk on January 29, 2012 at 12:26pm

Here is my go at it.

  1. Divide one edge in U and V directions.
  2. Surface CP which will return the uv of the points from step 1
  3. ISO Curves at the uv from step 2
  4. Curve|Curve intersect

Comment by Behnood Eghbali on January 29, 2012 at 8:33am

thx ;)

Comment by Wieland Schmidt on January 29, 2012 at 3:13am

Great work! Can you tell us a little how your new definition works?

Comment by Yoann Mescam (Systemiq) on January 29, 2012 at 2:03am

Yeah, extracting dimensions isnt the good way (and can bug anyway), probably better just use surface domains.

Although it doesnt work with surfaces like this one:

Comment by Behnood Eghbali on January 29, 2012 at 1:31am

hi systemiq,

yeah, kinda.. but i didn't use surface dimensions because this component approximates surface dimensions, it's not that accurate. this new definition works on every surface. something like this..

Comment by Yoann Mescam (Systemiq) on January 28, 2012 at 4:12pm

Something like that so ?

Comment by Nay Soe on January 28, 2012 at 1:34pm

how does this work? wow

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service