找回密码
 注册
搜索
查看: 16046|回复: 12

[工作记录] 关于自动切片脚本

[复制链接]
发表于 2010-2-6 21:15:37 | 显示全部楼层 |阅读模式
我从rhinoscriptingresources.blogspot.com/上找到的切片的脚本,欣喜若狂……没想到出现了这样的问题。。。
第一个这是这个脚本视频演示的截图 11.jpg
会出现3角的面,然后出现编码在每一个三角的切片上

这是我的尝试的截图: 222.jpg

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

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

下面是这个脚本:



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

切片.rvb

4.01 KB, 下载次数: 21, 下载积分: 照度 -1 lux

发表于 2010-2-6 22:23:20 | 显示全部楼层
本帖最后由 panhao1 于 2010-2-6 22:27 编辑

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

如果比较急的话也可以请教一下其他师兄
愿大家能够尽量帮下忙
回复

使用道具 举报

 楼主| 发表于 2010-2-6 22:34:54 | 显示全部楼层
2# panhao1

没关系panhao,我不急~感谢你的热心~麻烦你等有时间帮我解答下。。。谢谢~
回复

使用道具 举报

发表于 2010-2-7 09:26:09 | 显示全部楼层
哎 完全不懂脚本……在犹豫要不要学……
回复

使用道具 举报

发表于 2010-2-7 13:34:31 | 显示全部楼层
我怎么觉得好像没回一个贴,都像是在看热闹!
回复

使用道具 举报

 楼主| 发表于 2010-2-7 14:20:17 | 显示全部楼层
{:3_54:}{:3_54:}{:3_54:}
回复

使用道具 举报

发表于 2010-2-7 14:53:49 | 显示全部楼层
本帖最后由 scott 于 2010-2-7 16:30 编辑

你好,我下了你的代码看看出现什么问题,之后再通知你,你也可以加我们的rs群103630652,一起交流学习!~
回复

使用道具 举报

 楼主| 发表于 2010-2-7 16:30:50 | 显示全部楼层
103630652  lz写错了……
回复

使用道具 举报

发表于 2010-2-9 22:16:32 | 显示全部楼层
貌似不太难呀,怎么会弄不出来……
回复

使用道具 举报

 楼主| 发表于 2010-2-11 22:26:55 | 显示全部楼层
9# cjsyzwsh

同学……能帮我修改下么??我rs是小朋友阶段
回复

使用道具 举报

发表于 2010-2-13 11:19:53 | 显示全部楼层
只是感觉而已,我这两天试试吧~~
回复

使用道具 举报

 楼主| 发表于 2010-2-13 14:41:16 | 显示全部楼层
11# cjsyzwsh

555555谢谢~
回复

使用道具 举报

发表于 2011-4-29 21:58:25 | 显示全部楼层
脚本啊脚本~
回复

使用道具 举报

NCFZ微信公众号

手机版|小黑屋|NCF参数化建筑论坛 ( 浙ICP备2020044100号-2 ) 辽公网安备21021102000973号

GMT+8, 2026-11-23 19:21 , Processed in 0.048450 second(s), 28 queries , Gzip On.

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表