NCF参数化建筑论坛

标题: 关于自动切片脚本 [打印本页]

作者: 没碗    时间: 2010-2-6 21:15
标题: 关于自动切片脚本
我从rhinoscriptingresources.blogspot.com/上找到的切片的脚本,欣喜若狂……没想到出现了这样的问题。。。
第一个这是这个脚本视频演示的截图[attach]4220[/attach]
会出现3角的面,然后出现编码在每一个三角的切片上

这是我的尝试的截图:[attach]4221[/attach]

我不知道问题出在哪。。。有时候不出现这个错误了,可以进行了,但是每一个算出来的切片都重叠在一个范围内,并且没有切片上的编码……

哪位高手出来帮我解决下啊~小弟不胜感激……

下面是这个脚本:
[attach]4220[/attach]


Call Main
Sub Main

Dim div
div = Rhino.IntegerBox("Numero de Divisiones: ")
Call crearMalla(div)

End Sub

Function crearMalla(divisions)

'min,max in u direction
Dim umin, umax
'min,max in v direction
Dim vmin, vmax
'variable for surface domain
Dim superficiedomain
'how many divisions on surface
'variable for surface
Dim superficie
Dim i,j
Dim uDir, vDir

ReDim puntos(divisions, divisions)

'get surface
superficie = Rhino.GetObject ("dame una superficie!!!",8)
'get surface domain in u direction
superficieUdomain = Rhino.surfacedomain (superficie,0)
'get surface domain in v direction
superficieVdomain = Rhino.surfacedomain (superficie,1)

umin = superficieUdomain(0)
umax = superficieUdomain(1)

vmin = superficieVdomain(0)
vmax = superficieVdomain(1)

'looping
For i = 0 To divisions
  For j = 0 To divisions
  
  'get parameter location in grid
  uDir = (i * (umax - umin)/divisions) + umin
  vDir = (j * (vmax - vmin)/divisions) + vmin
  
  'get 3d location in scene using parameters
  punto = Rhino.evaluatesurface (superficie, Array(uDir, vDir))
  
  puntos(i,j) = punto
  
  'add 3d location to scene
  Rhino.addpoint punto
  
  Next

Next

Rhino.Print "Coordenada Z de punto 0,0: " & puntos(divisions,0)(2)

Call moveAroundCenter(puntos, divisions)


End Function

Function moveAroundCenter(pt, div)

'Esta funcion toma una reticula de puntos y los levanta todos un valor aleatorio entre 0 y 4

Dim center
Dim largo, ancho
Dim distancia, delta
ReDim newPts(div, div)

'Distancia entre el punto 0,0 del arreglo y el punto 0,div

ancho = Rhino.Distance ( pt(0,0), pt(0,div) )
Rhino.Print "Ancho de la base de la nube de puntos: " & ancho

largo = Rhino.Distance ( pt(0,0), pt(div,0) )
Rhino.Print "Largo de la base de la nube de puntos: " & largo
  
center = Rhino.GetPoint("Seleccione Centro")

ReDim npt(2)

  For i = 0 To div
   For j = 0 To div
   
   distancia = Rhino.Distance(center, pt(i,j))
   delta = 2/distancia*100
   
   npt(0) = pt(i,j)(0)
   npt(1) = pt(i,j)(1)
   npt(2) = pt(i,j)(2) + delta
   newPts(i,j) = npt
   Rhino.AddPoint(npt)
     
   Next
  Next
  
Call creategeom(newPts,div)

End Function

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

'------------------------------------------------------
'create geometry using point--------------------------
Function creategeom(npt,div)
Dim triLinesUno(2)
Dim triLinesDos(2)
ReDim triArrayUno(div, div)
ReDim triArrayDos(div, div)

For i=0 To div -1
For j=0 To div -1

Rhino.Print"HERE======================="
Rhino.Print npt(i,j)(0)
triLinesUno(0) = Rhino.addline (npt(i,j), npt(i+1,j+1))
triLinesUno(1) = Rhino.addline (npt(i,j), npt(i+1,j))
triLinesUno(2) = Rhino.addline (npt(i+1,j),npt(i+1,j+1))

triLinesDos(0) = Rhino.addline (npt(i,j), npt(i,j+1))
triLinesDos(1) = Rhino.addline (npt(i,j), npt(i+1,j+1))
triLinesDos(2) = Rhino.addline (npt(i,j+1),npt(i+1,j+1))


triArrayUno(i,j) = Rhino.AddPlanarSrf (triLinesUno)
triArrayDos(i,j) = Rhino.AddPlanarSrf (triLinesDos)
Next
Next

Dim boundingBox
Dim lstObj
Dim tempBound
For i= 0 To div -  1
For j= 0 To div - 1

If i = 0 And j = 0 Then
Rhino.SelectObject triArrayDos(i,j)(0)
Rhino.Command "UnrollSrf " & " Enter"
Rhino.UnSelectAllObjects()
lstObj = Rhino.LastObject()
boundingBox = Rhino.BoundingBox(lstObj)
Rhino.UnSelectAllObjects()
Else
Rhino.SelectObject triArrayDos(i,j)(0)
Rhino.Command "UnrollSrf " & " Enter"
Rhino.UnSelectAllObjects()
lstObj = Rhino.LastObject()
boundingBox = tempBound
Rhino.MoveObject lstObj, Array(0,0,0), BoundingBox(3)
End If
Rhino.SelectObject triArrayUno(i,j)(0)
Rhino.Command "UnrollSrf " & " Enter"
lstObj = Rhino.LastObject()
Rhino.MoveObject lstObj, Array(0,0,0), BoundingBox(1)
tempBound = Rhino.BoundingBox(lstObj)

Rhino.UnSelectAllObjects()
Next

Next


End Function
作者: panhao1    时间: 2010-2-6 22:23
本帖最后由 panhao1 于 2010-2-6 22:27 编辑

不好意思 同学 近几天我出门在外 没太多时间看脚本 你能等我下么 可以把有疑问的脚本通过qq发给我
我qq29347213

如果比较急的话也可以请教一下其他师兄
愿大家能够尽量帮下忙
作者: 没碗    时间: 2010-2-6 22:34
2# panhao1

没关系panhao,我不急~感谢你的热心~麻烦你等有时间帮我解答下。。。谢谢~
作者: Avalon    时间: 2010-2-7 09:26
哎 完全不懂脚本……在犹豫要不要学……
作者: 咸鱼空间    时间: 2010-2-7 13:34
我怎么觉得好像没回一个贴,都像是在看热闹!
作者: 没碗    时间: 2010-2-7 14:20
{:3_54:}{:3_54:}{:3_54:}
作者: scott    时间: 2010-2-7 14:53
本帖最后由 scott 于 2010-2-7 16:30 编辑

你好,我下了你的代码看看出现什么问题,之后再通知你,你也可以加我们的rs群103630652,一起交流学习!~
作者: 没碗    时间: 2010-2-7 16:30
103630652  lz写错了……
作者: cjsyzwsh    时间: 2010-2-9 22:16
貌似不太难呀,怎么会弄不出来……
作者: 没碗    时间: 2010-2-11 22:26
9# cjsyzwsh

同学……能帮我修改下么??我rs是小朋友阶段
作者: cjsyzwsh    时间: 2010-2-13 11:19
只是感觉而已,我这两天试试吧~~
作者: 没碗    时间: 2010-2-13 14:41
11# cjsyzwsh

555555谢谢~
作者: yndlzzx    时间: 2011-4-29 21:58
脚本啊脚本~




欢迎光临 NCF参数化建筑论坛 (http://bbs.ncf-china.com/) Powered by Discuz! X3.2