Grasshopper

algorithmic modeling for Rhino

Hi,
I'm trying to write a script that gives me a parralellogram shaped section given 3 points of the contour and the centroid of the parralellogram. (So the script has to find the fourth point...).

Input is the aproximate parralellogram (incrv), the centroid (inPt) of the new parralellogram and an offset distance (dist) (to create a hollow section)

I'm new to grasshopper en VB-scripting. As intuiative grasshopper seems, so complex seems VB to me... So far I was able to make an offset of the curve, make a brep of the incrv and the offsetted curve and determine the centroid of that brep. The only thing I still need is to move the vertex of the incrv so I can make a recursive loop until the centroid of the brep coïncides with the inPt.
I'm confused of all the different types of curves and the different actions you can do with them, for example I can move the vertex of an onnurbcurve but I can't offset it. I can offset an oncurve but I can't move a vertex of it...
can anybody help? this is what I have so far (working with oncurve):

Private Sub RunScript(ByVal inCrv As OnCurve, ByVal inPt As On3dPoint, ByVal Dist As Double, ByRef A As Object, ByRef brepout As Object, ByRef cen As Object, ByRef area As Object)

Dim Normal As New On3dVector(0, 0, 1)
Dim outCrv() As OnCurve = Nothing
print("1ste punt: " & incrv.PointAt(0).x & ", " & incrv.PointAt(0).y & ", " & incrv.PointAt(0).z)
RhUtil.RhinoOffsetCurve(inCrv, Dist, inPt, Normal, 0, 0.1, outCrv)
Dim allCrv(1) As OnCurve
allCrv(0) = inCrv
allCrv(1) = outCrv(0)
Dim brep(0) As OnBrep
rhutil.RhinoMakePlanarBreps(allCrv, brep)
brepout = brep(0)
A = allCrv
Dim mp As New OnMassProperties()
brep(0).AreaMassProperties(mp, True, False, False)
cen = mp.Centroid

Views: 1072

Replies to This Discussion

Hallo Piet,

could you post a coarse drawing of what it is you're after? I had a fairly rough day and my brain is no longer equipped to parse alien code.

Also, do you have the possibility to use Grasshopper 0.7 for this? I suspect the code might be much easier if we can use the new Rhino SDK (only available in GH 0.7.X)

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Hallo David and thanks for replying.

In attachement you'll see 3 images that make the intention more clear. We have to make irregular steel collumns to support a building. The forces and dimensions are huge.(1.5 m diameter, made out of steelplates of 45mm thickness)
For us, ingeneers, it is very important that the centroid axes of the collumns comes together in one point in the foundation.
For the archtitects it is important that the collumns come together in a nice way (every edge intersects with an edge of the next collumns).
Starting point for us are the centroid axes and the area and area moments we need for each collumn. Then we choose 3 points and the wall thickness that will define the section of the first collum. Given the centroid, the script searches the fourth point. This defines 3 points for the next section so the script can look for the fourth point of the second section,...
I'll send you in a next post a rhino and grasshopper file that does what I want with a solid section (based on onnurbcurves). The only thing I don't find is the instruction to offset the onnurbcurve and make a brep of the hollow section...
I hope it is a bit clear for you, while I'm writing this I realise it's a simple geometrical problem that is not that simple to explain. I hope your brain had a good night's rest and is ready for this alien talk! I'll install GH 0.7 and start searching the new Rhino SDK
Attachments:
David,

in attachement the rhino and GH file that does what I need with a solid section, it's controled by a treshold value (how close has the calculated centroid has to be to the given point) and a number of iterations. Both of them are mainly to prevent GH from hanging in an endless loop...
Attachments:
Hoi Piet,

zie ge-attached bestand. Een RhinoCommon scriptje (je hebt Grasshopper 0.7.X hiervoor nodig) wat de volgende stappen afwerkt:

1) Maak een polyline van de 4 bestaande punten
2) Begin een loop van maximaal 1000 iteraties
3) Offset de polyline en maak een nieuwe Brep van alle curven
4) Bepaal de Area-centroid van de Brep
5) Bepaal het verschil tussen de huidige centroid en de gezochte centroid
6) Als dit verschil minder is dan 1e-12 breken we af
7) Vermenigvuldig het verschil met vier en pas de polyline aan
8) herhaal (3 - 7)

Is dit min of meer wat je wilde? Het lijkt dat er ~50 iteraties nodig zijn voor een antwoord dat accuraat is binnen de 1e-12 eenheden.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Attachments:
dag David,

dit was inderdaad precies wat ik zocht!
Bedankt voor de snelle hulp, ik heb nog altijd veel moeite met de vb syntax, ik heb ook geen ervaring in het object gericht programmeren. Maar een uitgewerkt voorbeeld als dit help mij veel verder. Ik slaag er ook niet in om de SDK help te instaleren, ik krijg steeds volgende melding:
"Navigatie naar de webpagina is geannuleerd
Mogelijke acties:
Geef het adres opnieuw op. "
ligt dit aan onze firewall/virusscanner?

Ik zal nu proberen het script verder uit te werken in 3d, de sectie ligt immers niet in het xy vlak maar in het vlak loodrecht op de assen. Ik denk dat ik dit allemaal kan doen in GH zelf door een coordinaat transformatie toe te passen voor ik de punten geef aan de VB module.

Nogmaals heel erg bedankt voor de snelle en accurate hulp!

groeten

Piet
Hoi Piet,

de SDK help file staat op deze locatie: http://download.mcneel.com/s3/mcneel/grasshopper/1.0/sdk/en/Grassho...

Het kan zijn dat een firewall hier niet blij mee is. Alle Grasshopper installaties staan echter op dezelfde server, dus wellicht is er iets anders aan de hand.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
Dag David,
het is mij gelukt om jouw script aan te passen om zo automatisch de kolommen te genereren. Ik stuur het je door voor het geval het je interesseert. Alhoewel je met alle voorbeelden die ik ondertussen gezien heb van grasshopper projecten waarschijnlijk niet meer zo snel onder de indruk bent. Ik vernam dit weekend van een andere gebruiker dat jij de schrijver bent van grasshopper en daarom wil ik je nogmaals bedanken, niet alleen voor de hulp bij dit script maar vooral voor het schrijven en delen van deze fantastische tool!

ivm het script:
input:
* 3 punten die je kan verschuiven,
* de aslijnen van de kolommen
* de wanddikte
* een parameter om de kolommen te 'taperen'
* aantal itteraties en toelaatbare deviatie (om rekentijd te beperken)
* een parameter die de oppervlakte van de 2de kolom regelt (hoogte van het snijpunt met eerste kolom

output:
* de kolommen
* de secties van de kolommen
* de traagheidsmomenten van de kolommen relatief tov de richting van de assen

resultaat:
nu kunnen we samen met de architecten de geometrie van de kolommen vast leggen die beantwoord aan onze opgelegde randvoorwaarde

groet
Piet

PS het is een beetje een warboel geworden, maar het werkt wel :)
Attachments:
inderdaad een beetje een warboel :)

goed om te zien dat GH ook zijn toepassing vindt bij 'serieuze' ingenieurs.

:)

tot binnekort,
corneel
Hoi Piet,

fantastisch! Erg blij dat het allemaal zo soepel gelopen is.

--
David Rutten
david@mcneel.com
Poprad, Slovakia
David,
het was met Corneel (die hierboven reply-de) dat ik dit weekend over grasshopper bezig was. Hij vertelde me dat er vroeger een functie zat in grasshopper om verschillende componenten te groeperen in een soort functie maar dat je die er weer uitgehaald hebt omdat dit conflicten gaf. Is er een alternatieve manier om alles overzichtelijk te houden? kan je componenten een kleur geven bv?

groeten
Piet
hey Piet,

best per vraag een nieuw tpoic openen...

enige tips die ik kan geven: compact maar duidelijk werken, dingen goed uitlijnen en groeperen per logish blok, veel comments en tekstvensters.

meer tips hier:
http://www.nzarchitecture.com/blog/index.php/2010/07/31/untangling-...

http://www.nzarchitecture.com/blog/index.php/2010/08/11/untangling-...

vg,
corneel
Componenten hebben al een aantal mogelijke kleuren die worden toegeschreven a.d.h.v solution-state. Ik denk dat het onoverzichtelijk wordt als er ook nog gebruikers kleuren bovenop worden gegooid.

Wat wel kan is dat je bepaalde componenten groepeerd, en dan de groep een kleur geeft.

De optie om meerdere objecten te compacteren komt wel een keer terug (vrij hoge prioriteit).

--
David Rutten
david@mcneel.com
Poprad, Slovakia

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service