Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting document visibility via API

7 REPLIES 7
Reply
Message 1 of 8
noontz
1680 Views, 7 Replies

Setting document visibility via API

Hi..

 

Is it possible to make a document invisible after it´s open? I would like to keep it in memory but not reachable to the user.

 

Making the document view(s) invisible is not what I´m looking for. I need to clear/close/delete all views WITHOUT closing the document..

 

( So it has the same state as if opened through API with the visible parameter set to false, e.g.  Document.VIews.Count = 0

Tags (1)
7 REPLIES 7
Message 2 of 8
jdkriek
in reply to: noontz

Offhand I don't think there is a way to make a document invisible once it's open...

 

But you can open a document invisible with the "Open As Visible Boolean" argument  False of the Documents method Open

 

ThisApplication.Documents.Open(oFile, False)

 

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 8
noontz
in reply to: jdkriek

Hi Jonathan

 

Thx for your reply. And yes: Close > Open was my workaround before, but this was one of those questions that answered it self when asked.

 

I believed the number in the GUI indicating "Open Documents in Session" showed all documents in memory, but an afterthought made me check it out, and to my happy surprise:

 

Closing the last view on a document does NOT close the document. ( hence making it invisible )

 

This thread was my starting point, but I thought it wasn´t working on wrong assumptions as noted above

 

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Visibility/m-p/2135432/highlight/true#...

Message 4 of 8
jdkriek
in reply to: noontz


@noontz wrote:

.... Closing the last view on a document does NOT close the document. ( hence making it invisible )


That makes sense, glad you got it 😉

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 8
noontz
in reply to: noontz

Actually I´m not correct in my statement above:

 

As far as my experiments go I´m concluding that the Document is CLOSED when the documents last view is closed, but it is not TERMINATED. Thus it is still in memory, invisible, and available through API as was what I was looking for.

 

Sorry for the clutter 😉

Message 6 of 8
jdkriek
in reply to: noontz

I know what you meant 😉

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 7 of 8
cadull_rb
in reply to: noontz

I'm finding it difficult to manage documents when applying a mix of open invisible, release reference, view add, view close, document close and document close all. The following are some observations I've made.

 

When using open invisible we can call release reference afterwards so it will be closed with other non-referenced documents at an appropriate time. This seems to be implemented as a simple flag rather than a reference count and can't be used to keep a document open. Similarly, we shouldn't call release reference on a document that was already open.

 

Adding a view allows us to activate a previously invisible document and execute some commands such as Vault check in/out. Closing the view also closes the document and invalidates our reference to it. (As per API documentation: "If only one view exists for a document and the Close method is called it will also cause the Document to close.")

 

If we have added a view we need to leave it as long as we need the document open. However, now our release reference will not allow our document to close with non-referenced documents. It seems we are forced into finding an appropriate time to close the document.

 

Regards,

cadull

Message 8 of 8
noontz
in reply to: cadull_rb

I agree that the API implementation in this matter leaves some space for improvement.

 

On my side there is lots of space for improving my feedback in this topic Smiley Embarassed  I was doing some shotgun experiements and forgot to unsubscribe a certain eventhandler so I´m sad to say that I´m back to my initial workaround & the solution Jonathan also refered to. Your reference to the API documentation is sadly absolutely correct : the document is closed AND terminated when the last view is closed.

 

my wish for an easy API implementation would be changing the ReleaseReference method with a "KeepOpen" boolean property, preventing the document to close when the last view is closed if set to true, and making it act as the ReleaseReference() when set to false.

 

On the good side,opening the document again in the OnClose eventhandler only takes a few milliseconds, and it doesn´t seem to trigger the OnOpen event.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report