Select to view content in your preferred language

Can I prevent automatic model generation when changing user attributes with python?

3164
2
Jump to solution
03-29-2016 02:29 PM
LR
by
Frequent Contributor

I'm trying to change an attribute in a bunch of shapes and then generate all the models at once after the shapes had their attribute set. However CE generates each model separately while running through the loop, resulting in a rather slow process. Can I somehow prevent this?

My code:

    shapes = getObjectsFrom(ce.selection, ce.isShape)
    for shape in shapes:
        ce.setAttributeSource(shape, "/ce/rule/someAttribute", "USER")
        ce.setAttribute(shape, "/ce/rule/someAttribute", "hello")
    ce.generateModels(shapes, False, True)
0 Kudos
1 Solution

Accepted Solutions
ThomasFuchs
Esri Regular Contributor

Yes, this is possible!

Python Scripting Interface Reference

noUIupdate(f) Decorator to mark a function as non-UI updating.
By decorating a function with @noUIupdate: the function
will be executed on the UI thread thus preventing UI updates.

Note: # mark setAttributes() to run faster without UI updates

@noUIupdate
 def setAttributes():
     for shape in ce.getObjectsFrom(ce.selection, ce.isShape):
          ce.setAttribute(shape, 'height', 15)

 if __name__ == '__main__':
      setAttributes()

View solution in original post

0 Kudos
2 Replies
ThomasFuchs
Esri Regular Contributor

Yes, this is possible!

Python Scripting Interface Reference

noUIupdate(f) Decorator to mark a function as non-UI updating.
By decorating a function with @noUIupdate: the function
will be executed on the UI thread thus preventing UI updates.

Note: # mark setAttributes() to run faster without UI updates

@noUIupdate
 def setAttributes():
     for shape in ce.getObjectsFrom(ce.selection, ce.isShape):
          ce.setAttribute(shape, 'height', 15)

 if __name__ == '__main__':
      setAttributes()
0 Kudos
LR
by
Frequent Contributor

Great, thanks.

0 Kudos