Grasshopper

algorithmic modeling for Rhino

Hello,

I am developing a custom component where one of the intermediary steps in the calculation could be performed by calling a few grasshopper components in turn.

I realise that this could likely be acheived by using Rhino Common commands, but there is a sufficient number of corner cases and error checking that it would be great if I could stand on the shoulders of David's hard work.

The components I am interested in are:

  • Intersect>Shape>Intersect Region
  • Surface>Freeform>Planar Srf
  • Surface>Analysis>Area

Any information on how to access them would be greatly appreciated!

Hugh

Views: 1024

Replies to This Discussion

It's so difficult as to almost be impossible.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Ah that is dissapointing, I had seen a few commands in Grasshopper.Kernel.Geometry and was hoping that it was just a case of knowing the correct command to call.

Out of curiosity why is it so difficult?

Components are just difficult to use. The GH_Document has a lot of code that allows it to use components but none of this is available as a stand-alone function. I probably could write an SDK function that allows people to run a specific component and harvest the results, but I haven't so far.

The three functions you mentioned above are all fairly trivial as they are available in the RhinoCommon SDK. Why not just call those functions instead?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

It would definitely be nice to be able to access those function from within our custom code.

I appreciate the functions I am after are not the hardest, it was just a case of trying not to re-invent the wheel (and evidently your implementations are nice and robust so it would remove a bit of a headache!).

Actually in addition I am having a bit of trouble implementing my own version of Intersect region.

I am taking two breps and trying to calculate the area of where they overlap (the opposite of trim solid I guess?)

The problem I am having is that when the two breps overlap the Intersection.BrepBrep command I am using spits out two curves rather than one closed curve.

Is there an elegant way to solve this problem?

Are they always rectangles? Do you want to compute the result as quickly as possible or are you willing to wait 10ms longer and write a lot less code?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

They are not always rectangles although they are always planar.

They can be any shape and could intersect with one another multiple times (see below for example of potential input).

Am quite happy for the code to be inefficient if it saves me effort (can always go back to the problem if it proves to be a bottleneck).

This VB script component code will work for 2 curves:

Private Sub RunScript(ByVal x As Curve, ByVal y As Curve, ByRef A As Object)
Dim regions As Curve() = Rhino.Geometry.Curve.CreateBooleanIntersection(x, y)
If (regions Is Nothing) Then Return
If (regions.Length = 0) Then Return

Dim area As Double = 0.0
For Each crv As Curve In regions
Dim ap As AreaMassProperties = AreaMassProperties.Compute(crv)
area += ap.Area
Next

A = area
End Sub

--

David Rutten

david@mcneel.com

Poprad, Slovakia

That seems to have done the trick - thanks very much David!

I have come across a funny problem with Curve.CreateBooleanIntersection.

I pass two curves to the method, say A and B. A and B do not intersect in any way. CreateBooleanIntersection should return no result at all, however it returns me A and B in an array.

Operating on the same two curves manually in Rhino gives the correct result. This problem also only seems to rear its head after the document I have been working in has gone through a fair amount of changes (i.e. the method that calls CreateBooleanIntersection has been called a fair few times) making me think its maybe something to do with how the results are stored/retrieved in memory.

It has been a very elusive and hard to replicate bug and any help or suggestions would be extremely welcome.

Some additional information curves A and B that are passed to the method are both PolyCurves.

Just going to bump this as I've not heard anything - is there a member of the Rhino team I can contact directly?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service