Active selection contains one selection but its entity is/becomes None on acces

Active selection contains one selection but its entity is/becomes None on acces

ltomuta
Advisor Advisor
370 Views
4 Replies
Message 1 of 5

Active selection contains one selection but its entity is/becomes None on acces

ltomuta
Advisor
Advisor

Right click on the NC Programs item in Browser and hit Post Process then attempt to handle the command starting event for this command. In it, examine the UI's active selections list.

I've seen one of two things happening:
a) list has one item, its entity is valid and is name is "NC Program" (as queried in the debug window) but when I attempt to make a copy of the list, the copied entity resolves to None and from that point on object in active selections also resolves to none

b) list has one item but its entity resolves to none from start

It is either that once a) happens next debug attempts lead to b) or b) happens a lot more. Once thing appears to be sure, I cannot make a copy of the "NC Programs" selection and restore it after I do some other processing in that command starting event.

It all works fine if the selection is an NC Program object, but not for its parent node.

Any ideas?



0 Likes
371 Views
4 Replies
Replies (4)
Message 2 of 5

BrianEkins
Mentor
Mentor

If the selection returns null, that usually means that the item selected does not have a representation in the API.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 5

ltomuta
Advisor
Advisor

But I was able to query it once and it was of "OperationBase" type. So shouldn't that Browser node be represented by an NCPrograms object? 

0 Likes
Message 4 of 5

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

I can't follow your case because when I right-click on a NC Program and choose PostProcess it executes the post processor assigned to it; so I don't understand what you mean by "... then attempt to handle the command starting event ...".

 

But, regarding the empty selection on SelectionCommandInput objects it happen to me quite frequently that they lose the user selections if the event make some operations to the design; so, what I use to do is to save the selections for late use as the first thing in the event handler.

 

Could it be your case?  I hope this can help.

 

Regards,

Jorge Jaramillo

 

0 Likes
Message 5 of 5

ltomuta
Advisor
Advisor

My case is about not allowing the Post Processing to happen until certain checks are passed and some bits are updated programmatically. So I use the API to know when the processing is about to happen and run my code. Except some of the CAM APIs, if called in that context, will dirty the active selection so by the time I let the native post processing code execute, it gets wrong input.

Therefore I am trying to make a copy of the selections to restore them later, and that fails in this particular case.

So there are two issues here:
- CAM APIs polluting the selections
- The "NC Programs" node in the browser not being [correctly] mapped to [a CAM] API object

In an ideal world we would get two bug reports out of this and some idea on when/how they will be fixed. 

0 Likes