Saving part via ilogic

Saving part via ilogic

berry.lejeune
Advocate Advocate
415 Views
4 Replies
Message 1 of 5

Saving part via ilogic

berry.lejeune
Advocate
Advocate

Hi all,

 

I've been working on some ilogic rules for my parts.

Now I have a rule that will make the filename of my part "project + partnumber" and it'll save to a specific location which is also in the rule. Now I need to trigger the rule "before save document"

But when I hit save, I get the save as window and my part is not saved on the location that I need.

Is there anything I can do about this?

 

Thanks

0 Likes
416 Views
4 Replies
Replies (4)
Message 2 of 5

Michael.Navara
Advisor
Advisor

This is because the "Before save" (ApplicationEvents.OnSaveDocument) event occurs directly before the files are written to disk. Not after you click Save button or before file dialog is displayed.

You have two possibilities

1) Implement completely custom Save command (including file name construction,  save dialog etc.) and use this rule instead of default save command

2) Handle some another events and push your file name thru its arguments. Some events are FileUIEvents.OnPopulateFileMetadata or FileUIEvents.OnFileSaveAsDialog  

Message 3 of 5

berry.lejeune
Advocate
Advocate

My programming skills are not that good to implement such a custom save 🙈

But what I did now is that I trigger the rule when the "iTrigger" button is hit. This works now for me. What would help me even more is that if I could expand my rule that it would after the save, it would close the part and then it would start a new part from a specific template.

0 Likes
Message 4 of 5

JelteDeJong
Mentor
Mentor

This might work for you. (you have to set the save path en template full file name in the start of the rule)

Dim doc As PartDocument = ThisDoc.Document
Dim saveFolder = "c:\temp\"
Dim templatePath = "c:\PATH\TO\YOUR\TEMPLATE.ipt"

Dim partNumber = iProperties.Value("Project", "Part Number")
Dim project = iProperties.Value("Project", "Project")

Dim fileName = partNumber + "-" + project + ".ipt"
Dim fullFileName = IO.Path.Combine(saveFolder,fileName)

doc.SaveAs(fullFileName, True)
doc.Close(True)

ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, templatePath, True)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 5 of 5

berry.lejeune
Advocate
Advocate

I've bundled some Ilogic rules together which I found overhere.

This is now my code:

When I start a new part with my template it gives me a form where I already fill in my dimensions, partnumber, description and the projectnr.

After hitting the iTrigger button, the part gets saved to my folder and when all my parts are ready I just copy them to the specific customer folder.

Just in case you wonder, the "title" is actually my project number. This is because we work with a single project file.

Our designs all have a specific customer number, like: 2021**** This number is entered in the title section of the iProperties

Dim PartNumber As String

Title = iProperties.Value("Summary", "Title")
PartNumber = iProperties.Value("Project", "Part Number")
oPath = "C:\Users\berry.lejeune\Documents\Berry\Onderdelen\"
ThisDoc.Document.SaveAs(oPath & Title & " " & PartNumber & ".ipt", False)

Dim oPartDoc As Inventor.PartDocument
oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, "C:\Users\Public\Documents\Autodesk\Inventor 2020\Templates\en-US\Metric\gielkens steen.ipt", True)

'Activate the new  PartFile

oPartDoc.Activate()



trigger = iTrigger0

 

0 Likes