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)
Solved! Go to Solution.
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()
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()
Great, thanks.