iLogic writes unwanted iProperties

iLogic writes unwanted iProperties

ChristianAndersenIsmyname
Advocate Advocate
419 Views
1 Reply
Message 1 of 2

iLogic writes unwanted iProperties

ChristianAndersenIsmyname
Advocate
Advocate

Hello.

 

I have stolen a code from another thread (can't remember exactly where), that makes a copy of .ipt and .idw, and replaces old .ipt with the new one.

 

However, it seems to rewrite the properties from the old .ipt into the new, after I've changed them.

 

Small sample of my code:

' Perform Save As of Part
oDoc.SaveAs(Path & "\" & NewFileName & oExtension, False)

iProperties.Value("Project", "Part Number") = NewFilePartNumber
iProperties.Value("Project", "Description") = NewFileDesc
MessageBox.Show(iProperties.Value("Project", "Part Number") & iProperties.Value("Project", "Description"))
oDoc.Save()	

' Open the current drawing (in same folder location)
Dim DrawingDoc As DrawingDocument = ThisApplication.Documents.Open(Path & "\" & CurrentFilename & DWGType)

'MessageBox.Show(".idw opened, tries to replace model")
' Replace reference to part model
Dim oFD As FileDescriptor
oFD = DrawingDoc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor
oFD.ReplaceReference(Path & "\" & NewFileName & oExtension)
DrawingDoc.Update()
' Perform 'Save As' on the drawing - change this to reflect your drawing type .dwg or .idw
DrawingDoc.SaveAs(Path & "\" & NewFileName & ".idw", False)


' Make the assembly model active again...
question = MessageBox.Show("Open the new part?","Title",MessageBoxButtons.YesNo)
If question = vbYes 
oDoc.Activate()
Else
oDoc.Close()
End If

 

At the beginning of the code above, I change iProperties values to what I want them to be, and the messagebow right below that is showing the correct values. However, when it runs the rest it rewrites those values back to what the old .ipt have.

 

I suspect theres something with FileDescriptor, but I have no knowledge about what oFD exactly does.

So, if anyone want to fix my code, and explain why it happens so I can learn it, I would really appriciate it.

0 Likes
Accepted solutions (1)
420 Views
1 Reply
Reply (1)
Message 2 of 2

ChristianAndersenIsmyname
Advocate
Advocate
Accepted solution

Figured it out.

 

It wasn't writing iprop to the part, but the drawing.

So had to change it to:

iProperties.Value(NewFileName & oExtension, "Project", "Part Number") = NewFilePartNumber
iProperties.Value(NewFileName & oExtension, "Project", "Description") = NewFileDesc

 

0 Likes