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: 

File Save As Dialog wont launch through Command Manager

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
truscher
1261 Views, 8 Replies

File Save As Dialog wont launch through Command Manager

Hi All!

 

I am unable to get this code to launch the File Save As Command. I Think I have the sytax correct, because if I Replace "AppFileSaveAsCmd" with a different command name (i.e. "AppFileNewCmd") it works as expected. I have tried this with "AppFileSaveCmd" and "AppFileSaveCopyAsCmd" and both have also failed. It seems any kind of save command wont work...  I am trying to creat a rule that will fire on "New Document" iTrigger that will  Force a user to save the newly created assembly document in preperation for further iLogic rules that depent on the assembly Filename and path. Maybe there I am not telling it What file to Save? I have pasted the code below... Hope someone can help with this, Its killin me...

 

Format:HTML Format Version:1.0 StartHTML:     165 EndHTML:    3048 StartFragment:     314 EndFragment:    3016 StartSelection:     314 EndSelection:     314
SyntaxEditor Code Snippet

ThisApplication.UserInterfaceManager.UserInteractionDisabled=False

DimoCommandMgrAsCommandManager
oCommandMgr=ThisApplication.CommandManager

DimoDefAsControlDefinition
oDef=oCommandMgr.ControlDefinitions.?Item("AppFileOpenCmd")
Callodef.execute2(True)

8 REPLIES 8
Message 2 of 9
YuhanZhang
in reply to: truscher

Do you have a document opened visibly in Inventor? If not the command does nothing and won't pop up the dialog. You can try below VBA code with a document open first:

Sub CallSaveAsCommand()
    ThisApplication.UserInterfaceManager.UserInteractionDisabled = False
    
    Dim oCommandMgr As CommandManager
    Set oCommandMgr = ThisApplication.CommandManager
    
    Dim oDef As ControlDefinition
    Set oDef = oCommandMgr.ControlDefinitions.Item("AppFileSaveCopyAsCmd")
    Call oDef.Execute2(True)
End Sub

 



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 3 of 9
truscher
in reply to: truscher

Thank you for the reply. I am having the same behavior if I run the rule manually  on a new assembly document, or an existing assembly document. The save dialog is not launched in either instance. I tried to use the code you provided in an external rule (.ilogicVb) and some errors werer flagged. The Ilogic editer requires a sub Main() before any subs, so I Commented out the Sub Declaration and end sub lines. The editor also "No longer supoorts the use of "let" and "set" statements", so I edited the Lines by deleting the "set"  word from the beginning. I think that format is equivelent, but I do not know for sure. At this point I added a message box so I could tell if the rule fired. The rule runs but does not launch the Save as Dialog box... I will  attach the rule as it is now, but hopefully someone can tell me why this does not work!

Message 4 of 9
YuhanZhang
in reply to: truscher

Sorry I pasted VBA code but not iLogic code, yes you should remove the Set key words for iLogic. I tried with iLogic for the same code(changed the Sub name to Main), and see it works fine here. Can you share more info about your Inventor version? And you can see the code I use from the picture attached.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 5 of 9
truscher
in reply to: YuhanZhang

Thanks again for your help. I can see the attachment fine, and I typed in the rule exactly as you have it shown. This still does not open the dialog on my machine. I am Running Inventor 2013 64-bit sp 1.1, Build 176 on a Hp Z400 workstation. I Have found a way around this for now, But would still like to understand what is happening here!

Message 6 of 9
YuhanZhang
in reply to: truscher

I double checked with the same build as yours, and see same problem and a bug 1494089 is reported you can check the status of this issue with providing this number to us.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 7 of 9
akosi
in reply to: YuhanZhang

this  launch the save as window for me but

 

can i launch vault datacards with this code.

 

what is the item name for datacards?

Message 8 of 9
ekinsb
in reply to: akosi

Every command in Inventor has a unique name.  Even add-ins that add their own commands will have a unique name for each of their commands, which will be the case with Vault.  The following sample, which is from the Inventor API Help, will create a list of all of the commands in Inventor, including add-in commands.

 

Sub PrintCommandNames()
    Dim oControlDefs As ControlDefinitions
    Set oControlDefs = ThisApplication.CommandManager.ControlDefinitions

    Dim oControlDef As ControlDefinition  
    Open "C:\temp\CommandNames.txt" For Output As #1
    Print #1, Tab(10); "Command Name"; Tab(75); "Description"; vbNewLine
  
    For Each oControlDef In oControlDefs
        Print #1, oControlDef.InternalName; Tab(55); oControlDef.DescriptionText       
    Next
    Close #1
End Sub

 

You can run the VBA program above and then search the output file "C:\Temp\CommandNames.txt" for the command you're looking for.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 9 of 9
akosi
in reply to: ekinsb

thank you sooooo much !!!Smiley LOL

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

Post to forums  

Autodesk Design & Make Report