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: 

iLogic command ThisApplication.Documents.Open("fullFileName", False) does not open the file

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
ReneRepina
2080 Views, 6 Replies

iLogic command ThisApplication.Documents.Open("fullFileName", False) does not open the file

Hello,

 

I am trying to use command ThisApplication.Documents.Open("fullFileName", False) to open the file silently, but it does not want to open it. If I use boolean as True (to open it visible), it works ok. Any idea what is happening, a bug?

If I remember correctly I tried the same thing with version 2016 or some version older than 2020.3.4 - not sure which one exacly and this worked.

 

Currently I am using Inventor 2020.3.4.

 

 

Best regards,

Rene Repina

Labels (7)
6 REPLIES 6
Message 2 of 7
ReneRepina
in reply to: ReneRepina

Hello again,

 

nevermind about upper post. I just figured out that it opens the file silently (not visible) and I can read properties from it. One thing that is still bothering me is that when I open the file silenty, it does not count it in bottom right corner. Is this normal? As far as I know, all documents should be counted in bottom right corner - visible and not visible. Correct?

 

Best regards,

Rene

Message 3 of 7
WCrihfield
in reply to: ReneRepina

That number in the lower right corner of the screen can be a little unpredictable.  Sometimes you have to update the document, before the number in the corner of the screen will be updated after using one of these techniques.

When you open a document invisibly (in the background) using this process:

 

Dim oDoc As PartDocument = ThisApplication.Documents.Open("C:\\Temp\Part3.ipt",False)

 

, it does not seem to add to the total number of open documents.

However when you create a new document like this:

 

Dim oDoc As PartDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , False)

 

(which is also 'invisible'), it does add it to the total number of open documents.

 

There are several other scenarios that can leave behind invisible and/or 'unreferenced' documents too.

Here are a couple tools available to help clean up those documents, which are invisibly open in the background, to help free up system memory & help performance in high number situations.

You can release the reference to an invisible document, as long as it is, in fact, not being referenced by anything.

 

oDoc.ReleaseReference

 

You can also use this following line to close all invisible unreferenced documents that may be in memory.  When you specify True, it releases all the unreferenced documents, and when you specify False, it works like normal to close all regular open documents.

 

ThisApplication.Documents.CloseAll(True)

 

 

Here is a simple iLogic rule to test this, that incorporates all the above code.  To test the Add technique, un-comment that first line, then comment out the secont (Open) line, then run the rule.  Then reverse the commented lines to test the Open line.  Of course you may have to change the path and file name of the part is attemting to open.

 

'Dim oDoc As PartDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , False)
Dim oDoc As PartDocument = ThisApplication.Documents.Open("C:\\Temp\Part3.ipt",False)
ThisApplication.ActiveDocument.Update
MsgBox("ThisApplication.Documents.Count = " & ThisApplication.Documents.Count & vbCrLf & _
"Check the number in the lower right corner of the Inventor screen to see if this is the same.",vbOKOnly," ")
'oDoc.Close(True) 'skip save
oDoc.ReleaseReference
ThisApplication.Documents.CloseAll(True)
MsgBox("ThisApplication.Documents.Count = " & ThisApplication.Documents.Count & vbCrLf & _
"Check the number in the lower right corner of the Inventor screen to see if this is the same.",vbOKOnly," ")

 

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

If you have time, please... Vote For My IDEAS :light_bulb:and Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 7

@ReneRepina,

 

Usually, iLogic rule runs in a document. Can you please explain whole idea to open the document as invisible? 

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 5 of 7

@chandra.shekar.g In our company, there's a certain (configuration) tool that opens parts invisibly, because it needs to read some custom iproperties from it.  The part is not placed in the assembly in which the tool is run and 'we' don't want to open, read and close the part visibly because that looks bad (especially when multiple parts are to be read).
If there's a different solution, I'm very interested.

P.S. In early versions, the tool didn't read iproperties from parts. But users complained they had no indication of the result (size) during configuration. The custom info could have been stored in a config file or be hard coded in the tool, but it was decided it would be easier to manage this custom info by storing it in the part itself.

Message 6 of 7

@_dscholtes_,

 

Hoping that suggestions in the belwo link may be helpful.

 

https://modthemachine.typepad.com/my_weblog/2010/03/iproperties-without-inventor-apprentice.html

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 7 of 7
ReneRepina
in reply to: ReneRepina

Hello everybody (after 2,5 - 3,5 years lol).

 

@WCrihfield 

You are correct. The number is update, when we update the document. If it is updated right away due to some code, probably that code has automatic run for updating the document (or similar).


Also thank you for the other suggestions.

 

@chandra.shekar.g 

As stated in the original post, we use the "silent" open, to read from the properties (we do not have to see the model visually) and it is faster.

Also as @_dscholtes_  stated.

 

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

Post to forums  

Autodesk Design & Make Report