hi,
most of time i issue hundreds of idw.
if i need to rename or change anything in the iproperties of ipt, im doing it from the vault.
my problem is that, when i change something in iproperties of an ipt thru vault, i have to open the idw to update it.
as most of the iproperties in ipt shows in the idw.
its easy to change the properties in vault. but its deleting its purpose if i have to each idw to make sure i have the updated idw.
is there a code where i can open all idw and save the same file and checkin to the vault automatically?
thanks
inventor 2011
vault pro 2012
Solved! Go to Solution.
Solved by jdkriek. Go to Solution.
Checking in and out of Vault automatically in the manner you want requires a .NET Add-in that includes the Vault Add-in. It's not possible to include the Vault Add-in DLL via VBA. You can access most of the features programmatically through the command manager, but it requires user input on all the dialogs so it would require a lot more custom programming for something already available via .NET. So, yes it's possible, but it's a custom application add-in.
I had a minute to put a script together.
As noted in the script you need to include a refrence to the Microsoft Scripting Runtime
From the VBA Editor > Tools > Refrences > Check Microsoft Scripting Runtime > Ok
Public Sub OpenAndSave() 'JDK 4-30-13 'Include REF to Microsoft Scripting Runtime Dim oApp As Application Dim oDoc As Document Set oApp = ThisApplication Dim FSO As New FileSystemObject Dim oFld As Scripting.Folder Dim oFile As Scripting.File Path = "C:\myFolder" If FSO.FolderExists(Path) Then Set oFld = FSO.GetFolder(Path) Else MsgBox ("Folder Does Not Exist") Exit Sub End If oApp.SilentOperation = True For Each oFile In oFld.Files getExt = Split(oFile, ".") sExt = getExt(1) If InStr(sExt, "idw") Then 'Debug.Print oFile Set oDoc = oApp.Documents.Open(oFile, True) oDoc.Save oDoc.Close End If Next oApp.SilentOperation = False Set oFile = Nothing Set oFld = Nothing Set FSO = Nothing End Sub
hi,
ive checked the scripting tool but i have all these error?
what should i do?
Rule Compile Errors in Rule2, in Part6.ipt
Error on Line 6 : 'Let' and 'Set' assignment statements are no longer supported.
Error on Line 7 : Type 'FileSystemObject' is not defined.
Error on Line 8 : Type 'Scripting.Folder' is not defined.
Error on Line 9 : Type 'Scripting.File' is not defined.
Error on Line 10 : 'Path' is a type and cannot be used as an expression.
Error on Line 11 : 'Path' is a type and cannot be used as an expression.
Error on Line 12 : 'Let' and 'Set' assignment statements are no longer supported.
Error on Line 12 : 'Path' is a type and cannot be used as an expression.
Error on Line 23 : 'Let' and 'Set' assignment statements are no longer supported.
Error on Line 29 : 'Let' and 'Set' assignment statements are no longer supported.
Error on Line 30 : 'Let' and 'Set' assignment statements are no longer supported.
Error on Line 31 : 'Let' and 'Set' assignment statements are no longer supported.
Error on Line 34 : Statement cannot appear outside of a method body.
This is not iLogic; it's VBA and need to be put into a module in the Visual Basic Editor.
1. In Inventor got to Tools > VBA Editor
2. Once in the VBA Editor got to File > New Project
3. You will see UserProject in the browser, click on it and hit save from the menu.
You will be prompted where to save the project and what name you want.
4. Now the project is loaded. Expand the [+] sign and you will see Module1.
5. Double click on Module1 and paste the code into it.
6. Click on the play button from the menu to run the script.
Don't forget the Microsoft Scripting Runtime
(From the VBA Editor > Tools > Refrences > Check Microsoft Scripting Runtime > Ok)
Note, VBA (Visual Basic For Applications) is very similar to iLogic which is more or less simplified VB.NET (Add-ins that I was talking about before), but certain syntax and methods are different. I didn't attempt this in iLogic, because that would require you to have a document open whereas VBA doesn't.
thank you so much for replying immediately and giving time to my problem.
ive done what you mentioned but its giving me a compile error "variable not defined"
attached is a screenshot.
Remove Option Explicit at the top of the script. Option Explicit is used to avoid incorrectly typing the name of an existing variable or to avoid confusion in code where the scope of the variable is not clear, but for my script it's not needed.
Are there drawings in the folder you specified for the Path?
You can trigger the VBA script with iLogic by doing this in a rule:
(Make sure you change NameOfUserProject to the name that you gave it when you created the project earlier.)
InventorVb.RunMacro("NameOfUserProject", "Module1", "OpenAndSave")
it doesnt do anything if i put the path where my idw are
C:\Vault Projects\Projects\000111123J89\DRAWINGS\PARTS
but if i put C:\1 for the folder and copy some of the idw it works with have some error
i attached a print screen.
Not exactly sure why you are having problems.
I tested the code on Inventor 2011 - same version as you and it worked fine.
Try this:
Public Sub OpenAndSave() 'JDK 4-30-13 'Include REF to Microsoft Scripting Runtime Dim oApp As Application Set oApp = ThisApplication Dim oDoc As DrawingDocument Dim FSO As New Scripting.FileSystemObject Dim oFld As Scripting.folder Dim oFile As Scripting.File Dim Path As String Path = "C:\myFolder\blah" If FSO.FolderExists(Path) Then Set oFld = FSO.GetFolder(Path) Else MsgBox ("Folder Does Not Exist") Exit Sub End If oApp.SilentOperation = True For Each oFile In oFld.Files getExt = Split(oFile, ".") sExt = getExt(1) If InStr(sExt, "idw") Then 'Debug.Print oFile Set oDoc = oApp.Documents.Open(oFile, True) If oDoc.DocumentType = kDrawingDocumentObject Then With oDoc .Activate .Update .Save .Close End With End If End If Next oApp.SilentOperation = False Set oFile = Nothing Set oFld = Nothing Set FSO = Nothing End Sub
it works now.!!!
thank you so much...
this is my path where i get an error, sorry i forgot to put the dots.
C:\Vault Projects\Projects\000111123...J89\DRAWINGS\\PARTS
when i removed the dots , it works perfectly..
you helped me so much ..thanks a lot..
you really are a mentor