Grasshopper

algorithmic modeling for Rhino

Hi,

How can I correctly add Volume Goal in Kangaroo2 using C#?

I tried this function:

  public IGoal volume(Mesh M){

    double v = Rhino.Geometry.VolumeMassProperties.Compute(M).Volume;
    return new Volume(M, v, 1.01);

  }

error after this line in Runscript: One or more errors occurred. (line: 0)

GoalList.Add(volume(m)); // Mesh Volume Goal

Full C# script is attached below.

Thank you,

Petras

Views: 641

Attachments:

Replies to This Discussion

Hello again Petras

Seems like you forgot to call AssignPIndex for the volume goal :)

IGoal volumeGoal = volume(m);
PS.AssignPIndex(volumeGoal, 0.01);
GoalList.Add(volumeGoal);

Hi Long Nguyen,

Thanks, it works.

But I would like to ask several questions about Kangaroo2:

1. When defining simple Goals like Springs, Anchors I can work with indexing:

GoalList.Add(new Spring(particle_index1, particle_index2, 1.1, 1));

But when working with more complicated goals I have to use PS.AssignPIndex :

PS.AssignPIndex(volumeGoal, 0.01);
GoalList.Add(volumeGoal);

It just how it works? One goal can use particle indexes (Anchors, Springs, etc.) others PS.AssignPIndex? Otherwise If I want to use particle indexes, I would need to make my own custom goal ?

2. I compared c# script with Kangaroo definition. The geometry in c# script moves in Z axis, the geometry in Kangaroo2 definition stays in the same positions and is inflated gradually.

How to make c# geometry stable?

I attached printscreen and definition.

Attachments:

Here's the recommended way to play with the Volume IGoal and K2 on meshes.

Notify if you want a full translation to C#

Attachments:

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