Detecting exclamation point (error) in the tree, flag name?

Need help, or want to share a macro? Post here!
freedman
Posts: 498
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Detecting exclamation point (error) in the tree, flag name?

Postby freedman » Sat Jan 12, 2019 10:30 pm

Writing some macro test routines and I want to monitor when (red exclamation point in the tree) an error occurs so I can stop the macro. Can someone tell me the name of the flag or variable name. I did a search and got nothing. I don't have a clue where to start.

Thank you
wandererfan
Posts: 2162
Joined: Tue Nov 06, 2012 5:42 pm

Re: Detecting exclamation point (error) in the tree, flag name?

Postby wandererfan » Sun Jan 13, 2019 4:02 am

freedman wrote:
Sat Jan 12, 2019 10:30 pm
Writing some macro test routines and I want to monitor when (red exclamation point in the tree) an error occurs so I can stop the macro. Can someone tell me the name of the flag or variable name.
I think you want 'State'.

Code: Select all

>>> v = App.ActiveDocument.View
>>> v.State
['Up-to-date']
>>> v.State
['Touched']
>>> v.State
['Invalid']
>>> 
The list can contain more than 1 value - ['Touched', 'Invalid'].
chrisb
Posts: 12660
Joined: Tue Mar 17, 2015 9:14 am

Re: Detecting exclamation point (error) in the tree, flag name?

Postby chrisb » Sun Jan 13, 2019 9:51 am

Is there a possibility to set the status?

For an error in a (deeply) nested tree I would like to propagate the state up the tree, because it might be difficult to find. Furthermore a feature or object based on an invalid item is invalid anyway and should be marked as such. See issue #3760.
wandererfan
Posts: 2162
Joined: Tue Nov 06, 2012 5:42 pm

Re: Detecting exclamation point (error) in the tree, flag name?

Postby wandererfan » Sun Jan 13, 2019 3:06 pm

chrisb wrote:
Sun Jan 13, 2019 9:51 am
Is there a possibility to set the status?
:(

Code: Select all

>>> v = App.ActiveDocument.View
>>> v.State = ['Invalid']
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: Attribute 'State' of object 'DocumentObject' is read-only
>>> 
chrisb
Posts: 12660
Joined: Tue Mar 17, 2015 9:14 am

Re: Detecting exclamation point (error) in the tree, flag name?

Postby chrisb » Sun Jan 13, 2019 5:13 pm

That's what I had tried, it's the same for items in the tree.
wandererfan
Posts: 2162
Joined: Tue Nov 06, 2012 5:42 pm

Re: Detecting exclamation point (error) in the tree, flag name?

Postby wandererfan » Sun Jan 13, 2019 5:46 pm

chrisb wrote:
Sun Jan 13, 2019 5:13 pm
That's what I had tried, it's the same for items in the tree.
There are C++ functions to test & set the StatusBits (see App/DocumentObject.cpp), but I've never had any luck setting/unsetting the error bit. There is something in the background that overrides what I set.