Grasshopper

algorithmic modeling for Rhino

Hi all,

To import all layers in grasshopper i use the following code in c#

Rhinoceros.DocObjects.Tables.LayerTable layertable = doc.Layers;

A = layertable;


A is the output of the very short script, and works properly.

If i however delete a layer in rhinoceros and recompute the solution it still shows the deleted layer. In later stages of my program this results in problems as the layer exists no more.


If i completely close off Rhinoceros and open the file again, the layer is deleted. this is however not very user-friendly...

Is there a way, with some sort of clear command to resolve this problem ?

Views: 1059

Replies to This Discussion

I Have came into the same problem.

Andrew's plug-in Human has a Layer Table component that will handle this with an Update Toggle.

It also has an Auto Update input but there is a word of caution as this can cause loops if Grasshopper is producing layers based on what it reads.

Human's layer has no information of Father and children.That's no what I want!!

Then why not include that in your post?

If you would like people to be helpful don't complain when you don't give them the whole picture.

Agree.

Hi Flat Tyre,

This is because the LayerTable contains all layers that have been created. The deleted layers still exist in the table due to Undo purposes. The deleted layers have the property IsDeleted set to true. They don't show up in the Layer Manager in Rhino though.

Adapting your lines of code will handle the output of layers, that are not deleted:

List<Layer> layertable = new List<Layer>(RhinoDocument.Layers.Where(delegate(Layer l){return !l.IsDeleted;}));
A = layertable;

I don't know what you're doing, but if you're messing around a lot with layers you should purge unused layers (deleted but still in the LayerTable) once a while.

Cheers

FF

OH,Cheers,That's what I want,Thank you.

I like linq--

Share What I have done.

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