Forum

Author Topic: remove shape layers  (Read 2762 times)

tkwasnitschka

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
remove shape layers
« on: August 24, 2018, 04:50:28 PM »
My shapes are organized in layers, or, groups. Right-click allows you to remove the layer and its shapes, which is what I want.

How do you do that in python?

or, looking at my code:
Code: [Select]
for i in camgroups:
newchunk = chunk.copy()
newchunk.label = chunk.label+"_group_"+str(i)
# delete the other cameragroups
newchunk.remove(newchunk.camera_groups[i+1:])
newchunk.remove(newchunk.camera_groups[:i])
# delete the other shapegroups (this is the part that does not work)
newchunk.remove(newchunk.shapes.groups[i+1:])
newchunk.remove(newchunk.shapes.groups[:i])

And, please: Why are they called layers in the gui and in Alexeys scripts but groups in the python API?
Many thanks!
Tom
« Last Edit: August 24, 2018, 05:09:23 PM by tkwasnitschka »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15074
    • View Profile
Re: remove shape layers
« Reply #1 on: August 24, 2018, 10:22:34 PM »
Hello Tom,

You need to remove the shapes from the layer first, then remove the layers.

For example, the following code remove the last shape layer in the chunk:

Code: [Select]
for shape in list(chunk.shapes):
    if shape.group == chunk.shapes.groups[-1]:
        chunk.shapes.remove(shape)
chunk.shapes.remove(chunk.shapes.groups[-1])
Best regards,
Alexey Pasumansky,
Agisoft LLC