Edit iLogic rule to change save location

Edit iLogic rule to change save location

CherylR001
Advocate Advocate
2,450 Views
10 Replies
Message 1 of 11

Edit iLogic rule to change save location

CherylR001
Advocate
Advocate

Good Afternoon

I am looking for some help with editing the iLogic rule below. I currently have an iLogic rule to save my idw files as pdf and dwg files. It works fine, however I would like to be able to save each format in a different folder on a network drive. Currently they save in the same folder as the Inventor files. I have never written one before and don't even know where to start. 

 

ThisDoc.Document.SaveAs(ThisDoc.ChangeExtension(".dwg"), True)
ThisDoc.Document.SaveAs(ThisDoc.ChangeExtension(".pdf"), True)

 Thanks

Cheryl

0 Likes
Accepted solutions (2)
2,451 Views
10 Replies
Replies (10)
Message 2 of 11

mcgyvr
Consultant
Consultant

@CherylR001  Please tell us about this folder..

Is it a fixed folder each time? If so please let us know the folder path..

Is it a sub folder based on where the current document is?

Would you like a dialog box to come up asking you which folder each time the rule is run?

Or something else?



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 3 of 11

CherylR001
Advocate
Advocate

Hi

 

it would be a fixed folder every time. I don't think it needs sub folders. The folder path would be O:/Inspection Drawings . (O being the network drive).

And yes a dialogue box would be helpful

 

Cheryl

0 Likes
Message 4 of 11

CherylR001
Advocate
Advocate

and yes, the current documents are in subfolders

0 Likes
Message 5 of 11

JhoelForshav
Mentor
Mentor

@CherylR001 

Are you looking for something like this?

 

On Error Resume Next
Dim oDlg As Inventor.FileDialog
ThisApplication.CreateFileDialog(oDlg)
oDlg.Filter = "Inventor Drawing Files (*.dwg)|*.dwg"
oDlg.FileName = System.IO.Path.GetFileName(ThisDoc.ChangeExtension(".dwg"))
oDlg.DialogTitle = "Save dwg"
oDlg.ShowSave

ThisDoc.Document.SaveAs(oDlg.FileName, True)

oDlg.DialogTitle = "Save pdf"
oDlg.Filter = "PDF Files (*.pdf)|*.pdf"
oDlg.FileName = System.IO.Path.GetFileName(ThisDoc.ChangeExtension(".pdf"))
oDlg.ShowSave
ThisDoc.Document.SaveAs(oDlg.FileName, True)
Message 6 of 11

CherylR001
Advocate
Advocate

hi, to be honest, my understanding of iLogic is so limited I wouldn't know what that all meant. Would it save it to a specific folder? The one I''m currently using works fine just doesn't save it to the folder I need it to. 

 

Cheryl

0 Likes
Message 7 of 11

mcgyvr
Consultant
Consultant

@CherylR001 wrote:

hi, to be honest, my understanding of iLogic is so limited I wouldn't know what that all meant. Would it save it to a specific folder? The one I''m currently using works fine just doesn't save it to the folder I need it to. 

 

Cheryl


@CherylR001  That code will just open the save as box and allow you to select where you want your dwg file saved.. Then open another and ask where you want your pdf file saved.. (just paste it into a new ilogic rule and run it to see)

 

You said a dialog box would be helpful but you seemed to also imply there is always a fixed location for the files so I'm not sure why you would want the box to come up all the time. It seems like you just want a pdf and Inventor dwg file saved into your inspection drawings fixed folder..



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 8 of 11

CherylR001
Advocate
Advocate
You are correct. The pdf’s would be going to the Inspection drawing folder, we haven’t quiet decided where the dwg files are going to go yet, but will be on the the same network server but a different folder. So yes a dialogue box would be a bit OTT.



One other thing while on this subject. Is there a way to copy this iLogic rule to all existing files without having to open every file. The plan is to use Task Scheduler to initially create the pdf files but we would need to overwrite them when they are updated. I don’t want to have to try remember to add the rule when I open a file from 5 years ago.



Cheryl


0 Likes
Message 9 of 11

mcgyvr
Consultant
Consultant
Accepted solution

So I think this is all you need..

 

And you can just make it an external ilogic rule and then in the event triggers on the drawing tab set it to run on the after save trigger so anytime you save a file this will run and create the copies.. That takes care if it being available for any existing/new drawing files..

 

On Error Resume Next

'define the folder where you want to save the files
oFolder = "O:\Inspection Drawings\"

'grab the filename
oFileName = ThisDoc.FileName(False) 'without extension

'create the folder if it doesn't exist
If Not System.IO.Directory.Exists(oFolder) Then 
    System.IO.Directory.CreateDirectory(oFolder)
End If

'save as a dwg
ThisDoc.Document.SaveAs(oFolder & oFileName & ".dwg", True)

'save as a pdf
ThisDoc.Document.SaveAs(oFolder & oFileName & ".pdf", True)

 

  



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 10 of 11

CherylR001
Advocate
Advocate
Accepted solution

Thank you so much for your help. Pleased to say worked. 

0 Likes
Message 11 of 11

Anonymous
Not applicable

I have a similar issue I need solving.

 

I am creating a modified part length and trying to save in in our standard Purchased Parts folder for checking into Vault. This is an Internal Rule to the base part.

 

The idea is, any user can check out the base part. Modify the LENGTH. The script will automatically save the modified part with a new name.

 

The problem is, each user has a different hard-drive path based on their user name. This script was only for me (rprivitt), but not for other users.

 

Path = "C:\Users\rprivitt\Documents\Vault\$Working Folder\0-0-ENGINEERING DATA\0-0-ENGINEERING DATA\STANDARD PARTS\PURCHASED PARTS\UNISTRUT"

How can I use the equivalent of:

Path = ".\Documents\Vault\$Working Folder\0-0-ENGINEERING DATA\0-0-ENGINEERING DATA\STANDARD PARTS\PURCHASED PARTS\UNISTRUT"

 This doesn't work either:

Path = ThisDoc.Path

 This is the full context of the script, that only works if I am the user. I want to work for any user:

Parameter("LENGTH") = LENGTH
    
    iProperties.Value("Summary", "Title") = "UNISTRUT " & "FASTINAL NUMBER 48322 " & LENGTH & " in."
    iProperties.Value("Project", "Part Number") = "48322-" & LENGTH
        
    Dim Path, NewFileName As String
    Path = "C:\Users\rprivitt\Documents\Vault\$Working Folder\0-0-ENGINEERING DATA\0-0-ENGINEERING DATA\STANDARD PARTS\PURCHASED PARTS\UNISTRUT"
    NewFileName = Path & "\" & iProperties.Value("Project", "Part Number") & ".ipt"
    
    ThisDoc.Document.SaveAs(NewFileName, False)
0 Likes