找回密码
 注册
搜索
查看: 38083|回复: 26

[VB & C#] 关于grasshopper_vb_scripting的问题

[复制链接]
发表于 2011-10-4 22:44:50 | 显示全部楼层 |阅读模式
刚刚学习vb scripting,看到教程上的例子,不太懂,于是拿出来希望大家能解答解答。直接上图 11.png 这是程序的vb电池图,外面的一些输入数据和输出数据 以下是vb的代码 Private Sub RunScript(ByVal int_line As Line, ByVal r As Double, ByVal celltype As List(Of String), ByVal A_ang As Object, ByVal B_ang As Object, ByVal C_ang As Object, ByVal D_ang As Object, ByRef A As Object, ByRef B As Object, ByRef C As Object, ByRef D As Object, ByRef E As Object, ByRef F As Object, ByRef G As Object) 'defines output parameters ////////////////////////////////////////////////////////////////////////////////////// Dim pivot_cell_list As New list(Of circle) Dim pivot_pt_list As New List(Of point3d) Dim start_leg_list As New List(Of Line) Dim start_leg_pt_list As New List(Of point3d) Dim end_leg_list As New List(Of Line) Dim end_leg_pt_list As New List(Of point3d) Dim end_crv_list As New List(Of Line) 'defines output parameters of "component" subroutine ///////////////////////////////////////////////////////////// Dim pivot_cell As circle Dim pivot_pt As point3d Dim start_leg As line Dim start_leg_pt As point3d Dim end_leg As line Dim end_leg_pt As point3d Dim end_crv As line 'defines rotation_ang /////////////////////////////////////////////////////////////////////////////////////////// Dim rotation_ang As Double 'checks component types and computes output based on the types ///////////////////////////////////////////////// For i As Integer = 0 To celltype.Count - 1 If i = 0 Then If celltype(i) = "A" Then rotation_ang = A_ang Else If celltype(i) = "B" Then rotation_ang = B_ang Else If celltype(i) = "C" Then rotation_ang = C_ang Else If celltype(i) = "D" Then rotation_ang = D_ang End If component(int_line, r, rotation_ang, pivot_cell, pivot_pt, start_leg, start_leg_pt, end_leg, end_leg_pt, end_crv) Else If celltype(i) = "A" Then rotation_ang = A_ang Else If celltype(i) = "B" Then rotation_ang = B_ang Else If celltype(i) = "C" Then rotation_ang = C_ang Else If celltype(i) = "D" Then rotation_ang = D_ang End If int_line = end_crv component(int_line, r, rotation_ang, pivot_cell, pivot_pt, start_leg, start_leg_pt, end_leg, end_leg_pt, end_crv) End If pivot_cell_list.Add(pivot_cell) pivot_pt_list.Add(pivot_pt) start_leg_list.Add(start_leg) start_leg_pt_list.Add(start_leg_pt) end_leg_list.Add(end_leg) end_leg_pt_list.Add(end_leg_pt) end_crv_list.Add(end_crv) Next 'output ///////////////////////////////////////////////////////////////////////////////////////////////////////////// A = pivot_cell_list B = pivot_pt_list C = start_leg_list D = start_leg_pt_list E = end_leg_list F = end_leg_pt_list G = end_crv_list End Sub ' Sub component(ByVal start_crv As Line, ByVal pivot_cell_radius As Double, ByVal pivot_ang As Double, ByRef pivot_cell As Object, ByRef pivot_pt As Object, ByRef start_leg As Object, ByRef start_leg_pt As Object, ByRef end_leg As Object, ByRef end_leg_pt As Object, ByRef end_crv As Object) 'defines start_leg_pt ////////////////////////////////////////////////////////////////////////////////////////// Dim s_pt As New point3d(start_crv.PointAt(0.5)) start_leg_pt = s_pt 'defines start_leg ///////////////////////////////////////////////////////////////////////////////////////////// Dim start_crv_start As New Point3d(start_crv.PointAt(0.0)) Dim start_crv_end As New Point3d(start_crv.pointat(1.0)) Dim original_vector As New Vector3d(start_crv_start - start_crv_end) Dim rotation_ang_start_leg As Double = math.PI / 2 Dim rotation_axis_start_leg As New Vector3d(0, 0, 1) original_vector.Rotate(rotation_ang_start_leg, rotation_axis_start_leg) Dim line_start As New line(start_leg_pt, original_vector, pivot_cell_radius) start_leg = line_start 'defines pivot_pt ////////////////////////////////////////////////////////////////////////////////////////////// Dim p_pt As New point3d(line_start.PointAt(1.0)) pivot_pt = p_pt 'defines pivot_cell //////////////////////////////////////////////////////////////////////////////////////////// Dim pivot_circle As New Circle(line_start.PointAt(1.0), pivot_cell_radius) pivot_cell = pivot_circle 'defines end_leg /////////////////////////////////////////////////////////////////////////////////////////////// Dim rot As transform = transform.Rotation(pivot_ang * math.PI / 180, vector3d.ZAxis, line_start.PointAt(1.0)) Dim rotated_leg As line = line_start rotated_leg.Transform(rot) end_leg = rotated_leg 'defines end_leg_pt //////////////////////////////////////////////////////////////////////////////////////////// s_pt.Transform(rot) end_leg_pt = s_pt 'defines end_crv /////////////////////////////////////////////////////////////////////////////////////////////// Dim st_line As line = start_crv st_line.Transform(rot) Dim end_line_st_pt As New Point3d(st_line.PointAt(1.0)) Dim end_line_end_pt As New Point3d(st_line.PointAt(0.0)) Dim end_line As New line(end_line_st_pt, end_line_end_pt) end_crv = end_line End Sub 现在是我的问题,代码前半部分,就是sub component前面那部分的循环,到了最后那个component后面带括号的那部分是什么意思,还有在循环末尾,出现int_line=end_crv这是什么意思,希望高手能用通俗的话解释以下这个循环,谢谢了。
发表于 2011-10-5 09:29:01 | 显示全部楼层
component后面括号里的就是最后类似rhinoscript的function的参数吧--不是很清楚要如何表达~~
回复

使用道具 举报

发表于 2011-10-5 09:29:43 | 显示全部楼层
你到底是在说神马?
回复

使用道具 举报

发表于 2011-10-5 09:33:14 | 显示全部楼层
VB什么的看不懂啊~等高手~
回复

使用道具 举报

发表于 2011-10-5 10:27:30 | 显示全部楼层
看不懂啊{:3_47:}
回复

使用道具 举报

发表于 2011-10-5 12:04:53 | 显示全部楼层
我表示我先败给VB了。
回复

使用道具 举报

 楼主| 发表于 2011-10-5 12:34:54 | 显示全部楼层
我觉得也是。其实我主要就是不太懂这个循环是怎么回事,看了vb的语法但是还是在实际的例子中很难理解 2# zdjdevil
回复

使用道具 举报

 楼主| 发表于 2011-10-5 12:35:43 | 显示全部楼层
就是关于第一部分的循环,我还不是很清楚,为什么要再循环的末尾写上那么一行函数,总是就是循环不太懂。 3# benchenzebin
回复

使用道具 举报

发表于 2011-10-5 18:20:22 | 显示全部楼层
这个。。。真难帮得了{:3_65:}
回复

使用道具 举报

发表于 2011-10-5 18:31:27 | 显示全部楼层
我刚学完了C# 的基础 还没有时间 来看 VB 呢 等我掌握C#好了 才来帮你把!!!!!!
回复

使用道具 举报

发表于 2011-10-5 18:32:01 | 显示全部楼层
我刚学完了C# 的基础 还没有时间 来看 VB 呢 等我掌握C#好了 才来帮你把!!!!!!
回复

使用道具 举报

发表于 2011-10-5 20:18:30 | 显示全部楼层
放过撒旦的发生奥斯丁
回复

使用道具 举报

发表于 2011-10-5 23:07:53 | 显示全部楼层
学习 学习 学习 学习 学习 学习 学习 学习 学习 学习 学习 学习 学习 学习 学习 学习 学习 学习
回复

使用道具 举报

发表于 2011-10-6 14:49:42 | 显示全部楼层
这个应该是最新的woojsung教程里的例子吧,后一段“Sub component——End Sub”这部分是你自己定义的名称为“component”的一个过程,而在循环里面“component()”这是在调用你后面定义的过程,括号里面是参数部分,是一一对应的关系,ByVal是传值,也就是“输入参数”,不改变原参数,ByRef是传址,也就是“输出参数”,原参数也改变。int_line=end_crv是把变量end_crv的直线赋予到int_line中去,可以这样理解:每个循环中的“int_line”都是上一个循环中运算得到的结果“end_crv”。不知道我说的是不是清楚,多交流!:)
回复

使用道具 举报

发表于 2011-10-6 15:32:53 | 显示全部楼层
楼上正解。。。。。。。
回复

使用道具 举报

发表于 2011-10-6 22:09:49 | 显示全部楼层
不懂。。。
回复

使用道具 举报

发表于 2011-10-7 16:15:24 | 显示全部楼层
这个不好学。。。
回复

使用道具 举报

发表于 2011-10-8 01:40:00 | 显示全部楼层
正在研究。。。。。。。。。
回复

使用道具 举报

 楼主| 发表于 2011-10-9 18:49:47 | 显示全部楼层
说得太到位了。真的,那个int_line=end_crv我想了好久可能是你说的那个意思,但是自己也不知道想的对不对,你这么一说就明白了! 真是多谢! 15# 射手明
回复

使用道具 举报

发表于 2011-10-9 20:09:00 | 显示全部楼层
哭····学习中的哇···
回复

使用道具 举报

NCFZ微信公众号

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

GMT+8, 2026-11-23 20:46 , Processed in 0.048629 second(s), 28 queries , Gzip On.

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

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