NCF参数化建筑论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 7949|回复: 17
打印 上一主题 下一主题

[网络资源] ListLength的原代码

[复制链接]
跳转到指定楼层
1m
发表于 2011-5-24 00:42:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 1235813 于 2011-5-24 00:44 编辑

推荐反编译软件
http://www.reflector.net/
  1. Public Class Component_ListLength
  2. Inherits GH_Component
  3. ' Methods
  4. Public Sub New()
  5. MyBase.New("List Length", "Lng", "Measure the length of a list.", "Sets", "List")
  6. End Sub

  7. Protected Overrides Sub RegisterInputParams(ByVal pManager As GH_InputParamManager)
  8. pManager.Register_GenericParam("List", "L", "Base list", GH_ParamAccess.list)
  9. End Sub

  10. Protected Overrides Sub RegisterOutputParams(ByVal pManager As GH_OutputParamManager)
  11. pManager.Register_IntegerParam("Length", "L", "Number of items in L")
  12. End Sub

  13. Protected Overrides Sub SolveInstance(ByVal DA As IGH_DataAccess)
  14. Dim list As New List(Of IGH_Goo)
  15. If DA.GetDataList(Of IGH_Goo)(0, list) Then
  16. DA.SetData(0, list.Count)
  17. End If
  18. End Sub


  19. ' Properties
  20. Public Overrides ReadOnly Property ComponentGuid As Guid
  21. Get
  22. Return New Guid("{1817FD29-20AE-4503-B542-F0FB651E67D7}")
  23. End Get
  24. End Property

  25. Public Overrides ReadOnly Property Exposure As GH_Exposure
  26. Get
  27. Return GH_Exposure.primary
  28. End Get
  29. End Property

  30. Protected Overrides ReadOnly Property HelpDescription As String
  31. Get
  32. Return (Me.Description & " Elements in a list are identified by their index. The first element is stored at index zero, the second element is stored at index one and so on and so forth. The highest possible index in a list equals the length of the list minus one.")
  33. End Get
  34. End Property

  35. Protected Overrides ReadOnly Property Internal_Icon_24x24 As Bitmap
  36. Get
  37. Return Resources.Default_24x24_ListLength
  38. End Get
  39. End Property

  40. End Class


复制代码

评分

参与人数 1照度 +22 收起 理由
董羽天 + 22 感谢分享

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享
2m
 楼主| 发表于 2011-5-24 00:46:21 | 只看该作者
把gha文件改为dll文件格式,在用reflector打开就可以看到所有的grasshopper的代码,以此作参考,希望能提高大家的编程能力。
3m
 楼主| 发表于 2011-5-24 00:47:41 | 只看该作者
Series的代码


  1. Public Class Component_Series
  2. Inherits GH_Component
  3. Implements IGH_InitCodeAware
  4. ' Methods
  5. Public Sub New()
  6. MyBase.New("Series", "Series", "Create a series of numbers.", "Sets", "Sequence")
  7. End Sub

  8. Protected Overrides Sub RegisterInputParams(ByVal pManager As GH_InputParamManager)
  9. pManager.Register_DoubleParam("Start", "S", "First number in the series", CDbl(0))
  10. pManager.Register_DoubleParam("Step", "N", "Step size for each successive number", CDbl(1))
  11. pManager.Register_IntegerParam("Count", "C", "Number of values in the series", 10)
  12. End Sub

  13. Protected Overrides Sub RegisterOutputParams(ByVal pManager As GH_OutputParamManager)
  14. pManager.Register_DoubleParam("Series", "S", "Series of numbers")
  15. End Sub

  16. Public Sub SetInitCode(ByVal code As String) Implements IGH_InitCodeAware.SetInitCode
  17. Me.AssignInitCodeToInputParameter(2, code)
  18. End Sub

  19. Protected Overrides Sub SolveInstance(ByVal DA As IGH_DataAccess)
  20. Dim destination As GH_Integer = Nothing
  21. Dim number As GH_Number = Nothing
  22. Dim number2 As GH_Number = Nothing
  23. If ((((DA.GetData(Of GH_Number)(0, number) AndAlso DA.GetData(Of GH_Number)(1, number2)) AndAlso DA.GetData(Of GH_Integer)(2, destination)) AndAlso number.IsValid) AndAlso number2.IsValid) Then
  24. If (destination.Value < 0) Then
  25. MyBase.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Series with negative count ignored.")
  26. ElseIf (Not destination.Value Is 0) Then
  27. Dim data As New List(Of GH_Number)
  28. Dim num As Double = number.Value
  29. Dim num3 As Integer = destination.Value
  30. Dim i As Integer = 1
  31. Do While (i <= num3)
  32. data.Add(New GH_Number(num))
  33. num = (num + number2.Value)
  34. i += 1
  35. Loop
  36. DA.SetDataList(0, data)
  37. End If
  38. End If
  39. End Sub


  40. ' Properties
  41. Public Overrides ReadOnly Property ComponentGuid As Guid
  42. Get
  43. Return New Guid("{E64C5FB1-845C-4ab1-8911-5F338516BA67}")
  44. End Get
  45. End Property

  46. Public Overrides ReadOnly Property Exposure As GH_Exposure
  47. Get
  48. Return GH_Exposure.secondary
  49. End Get
  50. End Property

  51. Protected Overrides ReadOnly Property HelpDescription As String
  52. Get
  53. Return (Me.Description & " The numbers are spaced according to the {Step} value. If you need to distribute numbers inside a fixed numeric range, consider using the [Range] component instead.")
  54. End Get
  55. End Property

  56. Protected Overrides ReadOnly Property Internal_Icon_24x24 As Bitmap
  57. Get
  58. Return Resources.Default_24x24_Series
  59. End Get
  60. End Property

  61. End Class

复制代码
4m
 楼主| 发表于 2011-5-24 00:50:38 | 只看该作者
DivideInterval


  1. Public Class Component_DivideInterval
  2. Inherits GH_Component
  3. ' Methods
  4. Public Sub New()
  5. MyBase.New("Divide Domain", "Div", "Divide an domain into equal segments.", "Math", "Domain")
  6. End Sub

  7. Protected Overrides Sub RegisterInputParams(ByVal pManager As GH_InputParamManager)
  8. pManager.Register_IntervalParam("Domain", "I", "Base domain")
  9. pManager.Register_IntegerParam("Count", "C", "Number of segments", 10)
  10. End Sub

  11. Protected Overrides Sub RegisterOutputParams(ByVal pManager As GH_OutputParamManager)
  12. pManager.Register_IntervalParam("Segments", "S", "Division segments")
  13. End Sub

  14. Protected Overrides Sub SolveInstance(ByVal DA As IGH_DataAccess)
  15. Dim destination As GH_Integer = Nothing
  16. Dim interval As GH_Interval = Nothing
  17. If (((DA.GetData(Of GH_Interval)(0, interval) AndAlso DA.GetData(Of GH_Integer)(1, destination)) AndAlso interval.IsValid) AndAlso (destination.Value >= 1)) Then
  18. Dim num As Integer = destination.Value
  19. Dim data As New List(Of GH_Interval)
  20. Dim num7 As Integer = num
  21. Dim i As Integer = 1
  22. Do While (i <= num7)
  23. Dim normalizedParameter As Double = (CDbl((i - 1)) / CDbl(num))
  24. Dim num6 As Double = (CDbl(i) / CDbl(num))
  25. Dim num2 As Double = interval.Value.ParameterAt(normalizedParameter)
  26. Dim interval2 As Interval = interval.Value
  27. Dim num3 As Double = interval2.ParameterAt(num6)
  28. interval2 = New Interval(num2, num3)
  29. data.Add(New GH_Interval(interval2))
  30. i += 1
  31. Loop
  32. DA.SetDataList(0, data)
  33. End If
  34. End Sub


  35. ' Properties
  36. Public Overrides ReadOnly Property ComponentGuid As Guid
  37. Get
  38. Return New Guid("{75EF4190-91A2-42d9-A245-32A7162B0384}")
  39. End Get
  40. End Property

  41. Public Overrides ReadOnly Property Exposure As GH_Exposure
  42. Get
  43. Return (GH_Exposure.dropdown Or GH_Exposure.primary)
  44. End Get
  45. End Property

  46. Protected Overrides ReadOnly Property Internal_Icon_24x24 As Bitmap
  47. Get
  48. Return Resources.Default_24x24_DivideInterval
  49. End Get
  50. End Property

  51. End Class


复制代码
5m
 楼主| 发表于 2011-5-24 00:58:59 | 只看该作者
  1. <Serializable, StructLayout(LayoutKind.Sequential, Size:=&H18, Pack:=8), DebuggerDisplay("({m_x}, {m_y}, {m_z})"), DefaultMember("Item")> _
  2. Public Structure Point3d
  3. Friend m_x As Double
  4. Friend m_y As Double
  5. Friend m_z As Double
  6. Public Sub New(ByVal x As Double, ByVal y As Double, ByVal z As Double)
  7. Public Sub New(ByVal vector As Vector3d)
  8. Public Sub New(ByVal point As Point3f)
  9. Public Sub New(ByVal point As Point3d)
  10. Public Sub New(ByVal point As Point4d)
  11. Public Shared ReadOnly Property Origin As Point3d
  12. Public Shared ReadOnly Property Unset As Point3d
  13. Public Shared Operator *(ByVal point As Point3d, ByVal t As Double) As Point3d
  14. Public Shared Function Multiply(ByVal point As Point3d, ByVal t As Double) As Point3d
  15. Public Shared Operator *(ByVal t As Double, ByVal point As Point3d) As Point3d
  16. Public Shared Function Multiply(ByVal t As Double, ByVal point As Point3d) As Point3d
  17. Public Shared Operator /(ByVal point As Point3d, ByVal t As Double) As Point3d
  18. Public Shared Function Divide(ByVal point As Point3d, ByVal t As Double) As Point3d
  19. Public Shared Operator +(ByVal point As Point3d, ByVal point2 As Point3d) As Point3d
  20. Public Shared Function Add(ByVal point As Point3d, ByVal point2 As Point3d) As Point3d
  21. Public Shared Operator +(ByVal point As Point3d, ByVal vector As Vector3d) As Point3d
  22. Public Shared Function Add(ByVal point As Point3d, ByVal vector As Vector3d) As Point3d
  23. Public Shared Operator +(ByVal point As Point3d, ByVal vector As Vector3f) As Point3d
  24. Public Shared Function Add(ByVal point As Point3d, ByVal vector As Vector3f) As Point3d
  25. Public Shared Operator +(ByVal vector As Vector3d, ByVal point As Point3d) As Point3d
  26. Public Shared Function Add(ByVal vector As Vector3d, ByVal point As Point3d) As Point3d
  27. Public Shared Operator -(ByVal point As Point3d, ByVal vector As Vector3d) As Point3d
  28. Public Shared Function Subtract(ByVal point As Point3d, ByVal vector As Vector3d) As Point3d
  29. Public Shared Operator -(ByVal point As Point3d, ByVal point2 As Point3d) As Vector3d
  30. Public Shared Function Subtract(ByVal point As Point3d, ByVal point2 As Point3d) As Vector3d
  31. Public Shared Operator =(ByVal a As Point3d, ByVal b As Point3d) As Boolean
  32. Public Shared Operator <>(ByVal a As Point3d, ByVal b As Point3d) As Boolean
  33. Public Shared Widening Operator CType(ByVal pt As Point3d) As ControlPoint
  34. Public Shared Narrowing Operator CType(ByVal pt As Point3d) As Vector3d
  35. Public Shared Narrowing Operator CType(ByVal vec As Vector3d) As Point3d
  36. Public Shared Widening Operator CType(ByVal pt As Point3f) As Point3d
  37. Public Property X As Double
  38. Public Property Y As Double
  39. Public Property Z As Double
  40. Public Default Property Item(ByVal index As Integer) As Double
  41. Public ReadOnly Property IsValid As Boolean
  42. Public ReadOnly Property MinimumCoordinate As Double
  43. Public ReadOnly Property MaximumCoordinate As Double
  44. Public Overrides Function Equals(ByVal obj As Object) As Boolean
  45. Public Overrides Function GetHashCode() As Integer
  46. Public Sub Interpolate(ByVal pA As Point3d, ByVal pB As Point3d, ByVal t As Double)
  47. Public Overrides Function ToString() As String
  48. Public Function DistanceTo(ByVal other As Point3d) As Double
  49. Public Sub Transform(ByVal xform As Transform)
  50. Public Shared Function ArePointsCoplanar(ByVal points As IEnumerable(Of Point3d), ByVal tolerance As Double) As Boolean
  51. Public Shared Function CullDuplicates(ByVal points As IEnumerable(Of Point3d), ByVal tolerance As Double) As Point3d()
  52. Public Shared Function SortAndCullPointList(ByVal points As IEnumerable(Of Point3d), ByVal minimumDistance As Double) As Point3d()
  53. End Structure


  54. Expand Methods

复制代码
6m
发表于 2011-5-24 01:54:51 | 只看该作者
谢谢lz  我之前都在问好多朋友  那些电池代码什么看呢?你好猛哈。。。
7m
发表于 2011-5-24 02:42:44 | 只看该作者
本帖最后由 panhao1 于 2011-5-24 02:43 编辑

5# 1235813
说实在的你这公开吧代码贴出来实在是不好

我大概2年前在grasshopper3d网站上看到版主说用反编译可以看代码~

不过还是不要这么赤裸裸的贴出来,其实大家都知道reflector的,不过都很低调
8m
发表于 2011-5-24 07:42:43 | 只看该作者
非常给力啊,果断下载了
9m
发表于 2011-5-24 08:58:06 | 只看该作者
一直就想看看它的的代码,苦于无法下手,谢谢LZ了。。。。
10m
发表于 2011-5-24 09:51:07 | 只看该作者
大家心照不宣就好了
11m
发表于 2011-5-24 11:02:17 | 只看该作者
hhhhhhhhhhhhhhhhhhhhh
12m
发表于 2011-5-24 12:24:31 | 只看该作者
说实话,建筑的真还不知道这个。贴出来也看不太懂。
13m
 楼主| 发表于 2011-5-24 14:35:29 | 只看该作者
{:3_49:}算我无知吧
14m
发表于 2011-5-25 13:24:08 | 只看该作者
很给力支持支持!
15m
发表于 2011-5-26 09:57:59 | 只看该作者
let me see
16m
发表于 2011-5-26 10:03:09 | 只看该作者
7# panhao1
嗯 我以前干过这事情····
17m
发表于 2011-6-6 08:54:14 | 只看该作者
强大啊!!!!!!!!
18m
发表于 2016-7-11 12:55:45 | 只看该作者
谢谢,编程确实是快,高效运用

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

GMT+8, 2024-4-27 09:26 , Processed in 0.150861 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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