Grasshopper

algorithmic modeling for Rhino

Debug.jpgcode%20editor.jpgHi, I am try to build this components which will para-metrically control the floor to floor height, number of floor in a tower.

Imagine you have a tower with 2 or more sector, one is office and the other one is hotel for example.

 - a list will control the points height

 - to each of this point I am attaching a plane 

 - this plane will intersect the skin of the tower

 - from this intersection I am try to take out the floor plate (as Curve) and the area ( as Data)

I think I've got most of the script. but I have some error that I can't figure it out.

Please if you have time can you look to this code?

thank you very much

Private Sub RunScript(ByVal skin As Brep, ByVal f1 As Integer, ByVal DELTAh1 As Double, ByVal Lobby1h As Double, ByVal f2 As Object, ByVal DELTAh2 As Object, ByVal Lobby2h As Object, ByRef A As Object, ByRef C As Object)
'Declare the list of Point on which attach the planes for intersections
Dim p As New List(Of Point3d) 'first sector office
Dim q As New List(Of Point3d) ' second sector hotel
Dim floorPlate As New List(Of Curve) 'Declare a list for storing the curve

'for loop condition statement
Dim i As Integer ' for the office
Dim j As Integer ' for the hotel
For i = Lobby1h To f1 + Lobby1h
For j = f1 + Lobby1h + Lobby2h To f2 + (f1 + Lobby1h + Lobby2h)

p.Add(New Point3d(0, 0, i * DELTAh1)) ' points

Dim pl As New Plane(New Point3d(0, 0, i * DELTAh1), Vector3d.ZAxis) 'Planes
Dim iCurves As curve() 'temporary store the curves
Dim not_used_pt As Point3d() 'points needed only for the Intersect function

Intersect.Intersection.BrepPlane(skin, pl, 0.1d, iCurves, not_used_pt)
floorPlate.Add(iCurves(0)) 'if you assume only once curve for each intersection

Next
Next

Dim Areas As New list (Of Double)
'I will try to have a summ of all te areas
'Dim Areatot As Double

Dim k As Integer ' for loop to iterate the floorplates
For K = 0 To floorPlate.Count - 1
Areas = AreaMassProperties.Compute(floorPlate)

Next

A = Areas.Area
C = floorPlate

 End Sub 

Views: 368

Attachments:

Replies to This Discussion

The compiler errors you got should tell you exactly what and where the problems are.

Error: Overload resolution failed because no accessible 'Compute' can be called with these arguments: (line 119)

Let's pull this apart piece by piece:

Error: meaning the compilation failed because the compiler ran into an error. Sometimes there are warnings which indicate a problem with the code, however in those cases the compiler made an assumption about how to solve it and ended up with valid runtime code.

Overload resolution failed...: When two methods have the same name but different arguments, they are said to overload each other. This happens quite a lot as SDK developers often provide dumbed down overloads for complicated methods. When the resolution of overloads fails, it means that the compiler cannot find an overload that matches the arguments you've provided. 

(line 119): This is obvious I hope. The error occured on line 119. It would seem that there is no overload of the AreaMassProperties.Compute method that accepts a single List(Of Curve). In fact there are two overloads that accept curves, Compute(Curve) and Compute(Curve, Double).

You're already iterating over all the floorPlates (are they all closed, planar curves?) but the code looks a bit weird.

For K = 0 To floorPlate.Count - 1

  Areas = AreaMassProperties.Compute(floorPlate)

Next

The code inside the loop doesn't change, so every time this loop runs the exact same code executes. In this case, that makes no sense because there is no cumulative effect. You're going to have to use K somewhere inside the loop to make it do something different each time:

For K = 0 To floorPlate.Count - 1

  Areas = AreaMassProperties.Compute(floorPlate(K))

Next

But this is not enough. Areas is declared as a List(Of Double) and the Compute() method returns an AreaMassProperties instance. These two are not the same type and therefore cannot be assigned. The loop should probably look like this:

For K = 0 To floorPlate.Count - 1

  Dim am As AreaMassProperties = AreaMassProperties.Compute(floorPlate(K))

  If (am Is Nothing) Then Continue For 'Curve was probably open or non-planar or both.

  Areas.Add(am.Area)

Next

The second compiler error complains that there is no method/property called Area on the type List(Of Double). If you want to output all areas, just say A = Areas. If you want to sum together all areas, you'll need to loop over the list and add all values together (in fact, you could sum them all together inside the loop you already have).

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Great!

It worked,

Thanks David!

M

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service