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

Need help, or want to share a macro? Post here!
freedman
Posts: 779
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: 2772
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: 16850
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: 2772
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: 16850
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: 2772
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.
freedman
Posts: 779
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

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

Postby freedman » Sat Feb 02, 2019 8:20 pm

wandererfan » Sat Jan 12, 2019 7:02 pm

>>> v = App.ActiveDocument.View
>>> v.State
['Up-to-date']
>>> v.State
['Touched']
>>> v.State
['Invalid']
>>>

I have a file open and typing into console but I can't seem to make it work, I get this:
>>> v=App.ActiveDocument.View
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'App.Document' object has no attribute 'View'
>>> v.State
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'v' is not defined
>>>

Could this be close? This has no attribute "State".
v=Gui.ActiveDocument.activeView
Thanks
wandererfan
Posts: 2772
Joined: Tue Nov 06, 2012 5:42 pm

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

Postby wandererfan » Sun Feb 03, 2019 1:42 am

freedman wrote:
Sat Feb 02, 2019 8:20 pm
I have a file open and typing into console but I can't seem to make it work, I get this:
>>> v=App.ActiveDocument.View
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'App.Document' object has no attribute 'View'
>>> v.State
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'v' is not defined
>>>
Ah, sorry, my TD-centric world view coming out.

The "View" in "App.App.ActiveDocument.View " is any valid DocumentObject name - Box, Sphere, Body001, etc.
freedman
Posts: 779
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

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

Postby freedman » Sun Feb 03, 2019 8:12 pm

y wandererfan » Sat Feb 02, 2019 4:42 pm

The "View" in "App.ActiveDocument.View " is any valid DocumentObject name - Box, Sphere, Body001, etc.
Thanks, got it. It appears that "View->State" is really just the status of GUI tree icon. I'm still looking for something that I can use to detect when that exclamation point pops up.

Anyone know what the red exclamation point is called in the source, maybe I can track it down.
Thanks