update part number on save as with ilogic

update part number on save as with ilogic

Anonymous
Not applicable
879 Views
4 Replies
Message 1 of 5

update part number on save as with ilogic

Anonymous
Not applicable

I am using ilogic to generate different assembly files. I am doing this by opening a template file then save as (this bit is working fine)

Dim oDoc As AssemblyDocument = ThisApplication.Documents.Open(CurrentFilename & ".iam")
oDoc.SaveAs(oNewName & ".iam", False)

But now i want to change the part number too. I need something like

iProperties.Value(CurrentFilename & ".iam",Project","Part Number") = oNewName

 Any ideas? 

0 Likes
Accepted solutions (1)
880 Views
4 Replies
Replies (4)
Message 2 of 5

clutsa
Collaborator
Collaborator
Accepted solution

I had to add document paths to get this to work on my machine but I just change the part number before I SaveAs

oNewName = InputBox("Prompt", "Title", "AssyTemplateSaveTest_")
Dim oDoc As AssemblyDocument = ThisApplication.Documents.Open(ThisDoc.Path & "\AssyTemplateSave.iam")
oDoc.PropertySets("Design Tracking Properties").Item("Part Number").Value = oNewName
oDoc.SaveAs(ThisDoc.Path & "\" & oNewName & ".iam", False)
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 5

acanx21
Enthusiast
Enthusiast

If you're just changing it to be the new name, the code should just be:

iProperties.Value("Project", "Part Number") = oNewName

you could also use to get the current model name for the part name

modelFullFileName = ThisDoc.ModelDocument.FullFileName
modelDirectoryName = IO.Path.GetDirectoryName(modelFullFileName)
modelFileName = IO.Path.GetFileName(modelFullFileName)
modelFileNamewithoutextentionsion = IO.Path.GetFileNameWithoutExtension(modelFullFileName)

iProperties.Value("Project", "Part Number") = modelFileNamewithoutextentionsion
0 Likes
Message 4 of 5

Anonymous
Not applicable

Thanks @clutsa That worked a treat.

Do you know if there is a similar command for creation date? something like:

oDoc.PropertySets("Design Tracking Properties").Item("Creation Date").Value = Now

...and how do i learn this stuff without having to post to the forums? I can't find anything in the API Help. Is there an equivalent of vb locals window that lets you browse your objects and variables?

0 Likes
Message 5 of 5

clutsa
Collaborator
Collaborator

Probably looking for...

oDoc.PropertySets("Design Tracking Properties").Item("Creation Time").Value = Now

 VBA local windows are spot-on for how I look most of this up. 

https://www.youtube.com/watch?v=MFU_QaGdIDA I believe this video covers what you're asking and then some (it's a bit long but if my memory serves it's worth watching)  I couldn't get it to play just now to verify (our network is $#!t this morning). If it's not helpful let me know and I'll throw together a screen cast. 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes