Wednesday, April 18, 2007

density points based pattern







this is a little simple script that allows to output different radii circles based on a point set input.my aim was to map a density values from some environmental numerical datas. with this code i can have a circle based pattern that changes its dimension according to the distance between every point and all the other ones. in this first phae of developping i implemented also an extrusion value based on the distance too. every circle will generate inscripted polygons with different height, and will print the smallest distance from the center of the nearest circle. basic, i mean beginner's all purpose symbolic instruction code , but useful. in progress...




Option Explicit
'This Script Generate Different Circles and Boxes based on Points set and their Relative Distances
'Transformation of the Compartments into Tube or Spine in IL 38 Diatom II
'Code by Edmondo Occhipinti Architect [codesign.lab] 2007
MsgBox "Code by Edmondo Occhipinti Architect edmondo@co-design-lab.net"

Sub Circles
Dim arrpts
Dim dbdist, dbtotdist
Dim i, u
arrpts = Rhino.GetPointCoordinates ("Select Points to Create Skeleton Pattern")
If IsNull (arrpts) Then
Exit Sub
End If
for i = 0 To UBound (arrpts)
dbtotdist = 1000000
For u = 0 To UBound (arrpts)
dbdist = Rhino.Distance (arrpts(i), arrpts(u))
If u = UBound (arrpts) And dbdist = 0 Then
exit Sub
End If
If dbdist = 0 Then
u = u+1
dbdist = Rhino.Distance (arrpts(i), arrpts(u))
End If
If dbdist <>
dbtotdist = dbdist
End If
Next
Dim arrPlane, crv, text
text = Rhino.AddText (dbtotdist, arrpts(i), dbtotdist/5)
arrPlane = Rhino.PlaneFromFrame (arrpts (i), Array(1.0,0.0,0.0), Array(0.0,1.0,0.0))
crv = Rhino.AddCircle (arrPlane, dbtotdist/2.1)
Dim arrone, arrtwo, arrthree, arrfour, arrpolyline
Dim base, height, basept, heightpt, secondpt
Dim strbox, strpath, two, three, four, deletepts
Rhino.EnableObjectGrips crv
arrone = Rhino.ObjectGripLocation(crv, 0)
arrtwo = Rhino.ObjectGripLocation(crv, 2)
arrthree = Rhino.ObjectGripLocation(crv, 4)
arrfour = Rhino.ObjectGripLocation(crv, 6)
Rhino.EnableObjectGrips crv, vbFalse
basept = Rhino.AddPoint (arrone)
two = Rhino.AddPoint (arrtwo)
three = Rhino.AddPoint (arrthree)
four = Rhino.AddPoint (arrfour)
base = Array (0, 0, 0)
height = Array (0, 0, 300/dbtotdist)
heightpt = Rhino.CopyObject (basept, base, height)
secondpt = Rhino.PointCoordinates (heightpt)
strpath = Rhino.Addline (arrone, secondpt)
deletepts = Array (basept, two, three, four)
arrpolyline = Array (arrone, arrtwo, arrthree, arrfour, arrone)
strbox = Rhino.AddPolyline (arrpolyline)
Rhino.ExtrudeCurve strbox, strpath
Rhino.DeleteObject strpath
Rhino.DeleteObject heightpt
Rhino.DeleteObjects deletepts

Next
End Sub
Circles

edmondo occhipinti

2 comments:

Anonymous said...

...dal sito si capisce che per lo meno fino a ieri eri vivo...
vedi un po se trovi due millisecondi "para os da foz" ..@tt javascript:void(0)
Publish Your Comment

xin said...

the script doesn't work the way you aimed. it is way too simple. the diagram in the beginning is much more interesting then the actual work you developed.