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: 

Possibility to sort open documents in documents tab via iLogic

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ReneRepina
417 Views, 4 Replies

Possibility to sort open documents in documents tab via iLogic

Hello.

 

Is it possible to "sort" open documents (by name for example) in the documents tab via iLogic?

 

ReneRepina_0-1691733923183.png

 

 

Best regards,

Rene Repina

4 REPLIES 4
Message 2 of 5
WCrihfield
in reply to: ReneRepina

Hi @ReneRepina.  I have not tried to do this before, but it does sound possible, but would likely not be as simple as it sounds.  Those tabs you see are ViewTab objects.  And there is an API sample code available (in VBA, not iLogic) which shows how to move them around.  If trying to sort them alphabetically by their names View.Caption or View.Document.DisplayName, and all those values are different, you could try putting those values into a List(Of String), then use the List.Sort method, then loop the List and retrieve the associated objects that they represent, then move them as needed using the techniques shown in the sample.  Just some thoughts.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5
ReneRepina
in reply to: ReneRepina

Hello @WCrihfield .

 

Thank you for the explanation and suggestion.

Hmmm. I have an iLogic code with some functionality and I would have to implement this sorting functionality in that code.

I though the same as you with the list, I just did not know on how to proceed with sorting.

To maybe not complicate things with VBA, I was thinking, if I should create a list (also as you suggested), sort it and then close all those documents and reopen them via sorted list and file access. It will take more time, but at least it is iLogic.

 

I will suggest document tab sort via iLogic into the idea station.

Message 4 of 5
WCrihfield
in reply to: ReneRepina

I am not sure if closing all documents, then reopening them would be possible via an iLogic rule.  You may not be able to close the last document, because I believe iLogic may require at least one to be open.  And if the rule itself was an internal one (saved within a document), it might not allow you to close that one.

Also, I am now thinking that it might be better to use something like a Dictionary to store them, instead of a List, because you can store 2 objects in each entry of a Dictionary, such as a String and the ViewTab it represents.  Then sort the Dictionary by its Keys (the first object in each entry).  Then you would not have to re-associate the String with the object it represents after the sort step.

 

Anyways, if you do create a working code for this process, that would be interesting to see, and maybe a first.  I would also Like that idea if you posted it, so post a link to it here if you do create an idea station post for it.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 5
ReneRepina
in reply to: ReneRepina

I see your point. In our situation, we have at least 1 document open (on which that iLogic code is ran), so basically we have that covered, BUT if we would not have it covered, there can still be a "dummy" document open, until everything is done and close it at the end.

I have just tried to ran iLogic on a document, close it and open some other document. It worked OK. So I guess that works. But, it is true you do not have access to run iLogic, if no document is open.

You are correct. If 2 values needs to be stored to properly sort, "Dictionary" is also a way to go.

 

Not sure, if I will use VBA for this case, because the main code is ran in iLogic and this would have to be in VBA. Or can this be connected somehow, that iLogic "calls" VBA for this part?

 

Link to idea station about sorting documents tab via iLogic (and thank you for the vote):

https://forums.autodesk.com/t5/inventor-ideas/possibility-to-quot-sort-quot-open-documents-by-name-f...

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

Post to forums  

Autodesk Design & Make Report