It looks like you're new here. If you want to get involved, click one of these buttons!
Guys,
My problem is very simple and I've been wondering whats going on!!
In the start of the script I delete every shapes on a single layer. It's works.
In the middle of the script I create a layer (same earlier) and add shapes... that's works too!
But, when I combine theses two parts of the code, only delete function works.. the layer is not recreated.
For information:
def delete_objetcs(lv, view, menu, s_layer, s_datatype)
hs_all_layers(view, false)
hs_layer(view, s_layer, s_datatype, true)
menu.action("edit_menu.select_menu.unselect_all").trigger
menu.action("edit_menu.select_menu.select_all").trigger
lv.each_object_selected do |sel|
shape = sel.shape
shape.delete
end
menu.action("edit_menu.select_menu.unselect_all").trigger
menu.action("file_menu.save").trigger
end
Create a Layer
layer2 = RBA::LayerInfo::new(37, 66)
layer_index2 = layout.insert_layer(layer2)
layer_info2 = layout.get_info(layer_index2)
Can anyone help me ?
Comments
Hi,
First of all, you can use Markdown markup to format your code - just put four blanks in front of every line.
Regarding your code, I cannot help given that little input. What does "hs_all_layers" and "hs_layer" do? Could you please paste a full sample code which demonstrates the problem? The discussion topic indicates that you think a layer is being removed once all shapes are removed. But that's not true. The layer will remain, it's just empty.
And you don't need to select all objects just to delete them.
Layout#clear
andCell#clear
do this job smoothly.Matthias
Sorry for the little input, but I got it!
This code search a layer and if it exists it will delete it!
I need delete the layer, not only erase the shapes, and in GUI when I erased all shapes the layer disapear, that's beacause i think that erasing all shape should do! But thanks for help, and sorry for the possible mistakes on english.
The comands Layout#clear and Cell#clear only erase every shapes there are on visible layers ?
Hi,
very good you found a solution!
Just to clarify this: all changes you apply to a layout object are not reflected in the layer list and vice versa. The layer list is independent from the layout - if you want a layer to disappear from the list, you have to modify the layer list through the methods of
LayoutView
. The same way the layout object does not know about the layer's state, specifically not about layer visibility.Layout#clear
will remove all shapes from a layer, not just when the layer is visible. After this, the layer exists, but it is empty.Layout#delete_layer
will not only clear, but also remove the layer.Since you say the "layer disappears" I guess you have enabled "Hide empty layers" in the Layer list's context menu. Only then a layer will disappear from the layer list when you empty or delete a layer. Without this option, the layer will be still there even though it's empty or even missing in the layout object.
Matthias