Grasshopper

algorithmic modeling for Rhino

Hi, I'm trying to make some operation with objects and layers.
I have succefully created a C# script that can create a list of layers with given name and bake given objects on the first layer of the current rhino document; I also have the list of layerIndexes for the given layers.

What I'm trying to do next is to select these objects and test some conditions from other data:
for the objects that have the same referenced value as the target value, do nothing, leave them in their current layer;
for the objects that have an higher referenced value than the target value, select these object and put them in the next layer (a sort of: current Objects' Layer IN current layerIndexID+1 );
for the objects that have an lower referenced value than the target value, select these object and put them in the previous layer (a sort of: current Objects' Layer IN current layerIndexID-1 ).

With this 
 Rhino.DocObjects.RhinoObject[] srf;
    srf = doc.Objects.FindByLayer(layerName[0]);
    List<Rhino.DocObjects.RhinoObject> srfs = new 
List<Rhino.DocObjects.RhinoObject>();
    foreach(Rhino.DocObjects.RhinoObject obj in srf)
    {
      obj.Select(true);
      srfs.Add(obj);
    }
A = srfs;

I get Rhino.DocObjects.BrepObject but they are nothing, I don't really select them.

I also tryed to translate this C# code http://wiki.mcneel.com/developer/sdksamples/sellayer but there are things I can't find in the RhinoCommon, like lookUpObjects or MRhinoObject, m_doc(I thought it was a variable but I can't see the declaration).

Thank you, bye.
Andrea

Views: 4164

Replies to This Discussion

I made a little piece of the code working.


List <int < srfs = new Listi <int <();
System.Collections.Generic.List < Guid < ids = new System.Collections.Generic.List <Guid<();
foreach(Rhino.DocObjects.RhinoObject obj in srf)
{
//obj.Select(true); //select objects in the layer
ids.Add(obj.Id);
}
if(del == true) //bool input
{
for(int i = 0; i < ids.Count; i++)
{
doc.Objects.Delete(ids[i], false);
}
} else
return;


This part retrieve the Guid of selected objects on a layer (srf is the list of object in layer) and delete them. It was so simple...
What do you mean by "referenced value"?

--
David Rutten
david@mcneel.com
Seattle, WA
Ok, i'll try to make it simple. I know that "referenced value" is the wrong name, referenced is totally another thing. Maybe it was better saying external value.
I have a list of points. Each point has a value associated from another list. I have a list of surfaces above these points. I made some scripted components that tell me wich points are affected by each panel and perform the mean value on the associated values. Depending on this mean value (external value) and a target value I have to choose in which layer I have to bake each panel (I have 5 or 6 different layer). At the moment I'm working with 76 panels, but in the near future I have to work with thousands of panels.
I get this values from daylight simulation in Radiance and the layers are the radiance material that I have to apply to the panels, so this process will be repeated n times.

It's quite difficult to explain in words, I know.
Bye
Sorry, still don't get it. Is the following correct:

You have a list of points {P}. And you have a list of values {V} (numbers?). These two lists are the same length, and the point at P[i] is 'linked' to the value at V[i].

You also have a list of panels {S} (Surfaces of Breps I assume), but I'm not sure how this ties into it.

Then you have a "target value" (single number? a list of numbers?).

In your bake operation, you want to see if the value in {V} is less than or greater than the target value and bake (the points?, the panels?) to a different layer accordingly.

Am I correct so far?

--
David Rutten
david@mcneel.com
Seattle, WA
Exactly. The list of points and the list of values are the same length. List of values are rounded doubles. I have a mean of the values that are linked to the points that are exactly under each panel. I created a branch for each panel that has as items the values that are linked to the points.

The panels are rectangular surfaces. They are above the points.

The target value is a single number, a slider.



Maybe, this discussion could help you to understand the process.


Thank you for your help.

i cannot run such codes. and i terribly need one of those. can you give me an example how to put entry etc and send?

THNX

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service