Deleting entities on a layer doesn't work
-
But isn't that exactly the code I already used?
-
@kiesewetter said:
But isn't that exactly the code I already used?
Not exactly the same.
It works.
Try it and see if you can any errors...
Why do you have geometry that is connected separated onto different layers.
As I explained layers do not separate geometry only its visibility.
Use groups or components of geometry - all on Layer0 [or its equivalent in your locale] - and set the group/instance layer to control visibility.
I fail to see the wider issues here -
The geometry isn't disconected. I wrote a scribt that should display some information, that is saved as an attribute of the faces, in a diagramm an text on a different layer ("balkenlayer"). Then it should be possible to go on working on the model and to invoke the scribt that shows the information on "balkenlayer" again. So far the diagramm and the text is displayed on the layer and the geometry of it seems to be erased. But when I invoke the scribt one more time, Sketchup still tells me, that:
"your recent operation has caused visible geometry to merge with existing geometry on a hidden layer"
Although I meanwhile use the following code:
layer = layer_array["Balkenlayer"] return nil if not layer mod.entities.to_a.each{|e| next if not e.valid?; e.erase! if e.layer==layer}
I don't understand why.Though there is no geometry to see if only the "Balkenlayer" is visible.
Any idea? -
Instead of erasing things check what they are...
mod=Sketchup.active_layer layer = mod.layers["Balkenlayer"] return nil if not layer mod.entities.to_a.each{|e|next if not e.valid?; puts e if e.layer==layer}
Now the Ruby Console will show a list of everything in the model's entities on layer 'Balkenlayer'.
Another way is to highlight them...mod=Sketchup.active_layer layer = mod.layers["Balkenlayer"] return nil if not layer ss=mod.selection ss.clear mod.entities.to_a.each{|e|next if not e.valid?; ss.add(e) if e.layer==layer}
OR even color them...
mod=Sketchup.active_layer layer = mod.layers["Balkenlayer"] return nil if not layer ss=mod.selection ss.clear mod.entities.to_a.each{|e|next if not e.valid?; e.material='Red' if e.layer==layer}
If the layer is 'off' switch in 'on' !
I can't understand what it is exactly that you are doing, and therefore what the problem might be.
Can you write a simple step by step list of what you do - you 'narrative' format is not fully clear to me... -
I'd recommend you add your geometry to a group and place that group on your layer. That way you ensure your temporary layer doesn't merge with existing geometry. Also, it's easier to erase it, just erase the group.
-
tt
It's as I tried to explain earlier in this thread...You should never put 'raw geometry' on a layer other than Layer0.
All geometry in the same context 'sticks together' irrespective of its layer.If you want to use layers to control visibility then use groups or components placed on those layers.
To add a face that is on a specific layer use this to put it into a group and then set the group's layer etc###... gp=mod.entities.add_group() gp.entities.add_face(p0,p1,p2,p3) gp.layer=layer ###...
-
Step by step what I want to do:
- a scribt assigns information to selected faces of the model as attributes.
- another one creates a bar chart (the entities that should be erased later) based on the attributes of the faces on a layer called "balkenlayer".
- a selection observer is used to go back to the model to go on working on it. that observer should delete the bar chart (everything on the layer "balkenlayer").
- later it schould be possible to invoke the script that created the bar chart once more.
it is working so far. in the 3. step every entity on that layer seems to be erased. but if i invoke the scribt once more as mentioned in step 4, sketchup tells me:
"your recent operation has caused visible geometry to merge with existing geometry on a hidden layer"
although the is nothing to see.
do know now what i am trying to receive?
is there maybe an array that stores the entity although it got erased or something like that?thank you guys for your time.
-
Maybe we can have a look at the whole script?
-
IF your 'barchart' were made inside a group [all text/geometry etc] then there would be no need to use layers for these unless you want to hide that group at some point before it's finally erased.
Using a @@ [or $] variable to point at the group it is then easily deleted using e.g. @@group.erase! rather than messing on with layers...
Let's see the code - if it's too 'sensitive' PM it to thomthom [or me] and we can be discreet about it...
-
I study civil engineering and the script is some kind of homework. I'll talk to my tutor in two days. After that I'll know wether I'm allowed to give you the code.
Thanks so far.
Tim
Advertisement