Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SaveAs in Inventor - Inconsistent in assemblies when replacing parts

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
179 Views, 3 Replies

SaveAs in Inventor - Inconsistent in assemblies when replacing parts

In the lower portion of this routine (starting at ElseIf @ line 11), when saving a part (in edit mode) from an assembly document - The save-as is very inconsistent. Sometimes, the file is saved and replaced in the assembly, and sometimes it is not replaced and only saved on our server. The question is, what is a better way to control this? Thanks in advance for any help you can provide! If ThisApplication.ActiveDocumentType = kPartDocumentObject Then If oPartDoc2.FullFileName = "" Then Call oPartDoc2.SaveAs(JobPath & PN & ".ipt", False) Else Dim ans As Integer ans = MsgBox("The Current File will be Lost if not Saved, Continue? ", vbYesNo) If ans = 6 Then Call oPartDoc2.SaveAs(JobPath & PN & ".ipt", False) End If End If ElseIf ThisApplication.ActiveDocumentType = kAssemblyDocumentObject Then ans = MsgBox("The Current File will be Replaced if not Saved, Continue? ", vbYesNo) If ans = 6 Then Call oPartDoc2.SaveAs(JobPath & PN & ".ipt", False) MsgBox "The Part has been changed - the new Part Number is: " & PN & ". An Update will show the effected change." End If End If
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

What are you trying to accomplish exactly? (what steps do you want to make) I don't see any replacement taken place in the code, only SaveAs-routines. If you want to "save-copy-as & replace" you should use the "ComponentDefinition.Occurrences.ItemByName("Part:1").Replace("C:\NewPart.ip t", False)" (IV 8 only) to replace parts/sub-assemblies within an Assembly (or use the "oRefFileDesc.PutLogicalFileNameUsingFull("C:\NewPart.ipt")" when using Apprentice). And perhaps it is better to use "If ans = vbYes Then" (or am I mistaken???) Cheers, Teun "Stephen Anderson" wrote in message news:406b2462_1@newsprd01... > In the lower portion of this routine (starting at ElseIf @ line 11), when > saving a part (in edit mode) from an assembly document - The save-as is very > inconsistent. Sometimes, the file is saved and replaced in the assembly, > and sometimes it is not replaced and only saved on our server. The question > is, what is a better way to control this? > > Thanks in advance for any help you can provide! > > > If ThisApplication.ActiveDocumentType = kPartDocumentObject Then > If oPartDoc2.FullFileName = "" Then > Call oPartDoc2.SaveAs(JobPath & PN & ".ipt", False) > Else > Dim ans As Integer > ans = MsgBox("The Current File will be Lost if not Saved, > Continue? ", vbYesNo) > If ans = 6 Then > Call oPartDoc2.SaveAs(JobPath & PN & ".ipt", False) > End If > End If > ElseIf ThisApplication.ActiveDocumentType = kAssemblyDocumentObject Then > ans = MsgBox("The Current File will be Replaced if not Saved, > Continue? ", vbYesNo) > If ans = 6 Then > Call oPartDoc2.SaveAs(JobPath & PN & ".ipt", False) > MsgBox "The Part has been changed - the new Part Number is: " & > PN & ". An Update will show the effected change." > End If > End If > >
Message 3 of 4
Anonymous
in reply to: Anonymous

I'd like to know how to control if a replace occurrs or not in the assembly. I am in an assembly, and I am doing a save-as of a new part (generated by code with new part number read from an Access database). Everything works fine, however sometimes the part is replaced with the new one, and sometimes the old part (which the new part was created from) is kept. I would like to know how to better control this! "Teun Ham" wrote in message news:406bc31c$1_3@newsprd01... > What are you trying to accomplish exactly? (what steps do you want to make) > I don't see any replacement taken place in the code, only SaveAs-routines. > > If you want to "save-copy-as & replace" you should use the > "ComponentDefinition.Occurrences.ItemByName("Part:1").Replace("C:\NewPart.ip > t", False)" (IV 8 only) to replace parts/sub-assemblies within an Assembly > (or use the "oRefFileDesc.PutLogicalFileNameUsingFull("C:\NewPart.ipt")" > when using Apprentice). > > And perhaps it is better to use "If ans = vbYes Then" (or am I mistaken???) > > Cheers, > > Teun > > "Stephen Anderson" wrote in message > news:406b2462_1@newsprd01... > > In the lower portion of this routine (starting at ElseIf @ line 11), when > > saving a part (in edit mode) from an assembly document - The save-as is > very > > inconsistent. Sometimes, the file is saved and replaced in the assembly, > > and sometimes it is not replaced and only saved on our server. The > question > > is, what is a better way to control this? > > > > Thanks in advance for any help you can provide! > > > > > > If ThisApplication.ActiveDocumentType = kPartDocumentObject Then > > If oPartDoc2.FullFileName = "" Then > > Call oPartDoc2.SaveAs(JobPath & PN & ".ipt", False) > > Else > > Dim ans As Integer > > ans = MsgBox("The Current File will be Lost if not Saved, > > Continue? ", vbYesNo) > > If ans = 6 Then > > Call oPartDoc2.SaveAs(JobPath & PN & ".ipt", False) > > End If > > End If > > ElseIf ThisApplication.ActiveDocumentType = kAssemblyDocumentObject > Then > > ans = MsgBox("The Current File will be Replaced if not Saved, > > Continue? ", vbYesNo) > > If ans = 6 Then > > Call oPartDoc2.SaveAs(JobPath & PN & ".ipt", False) > > MsgBox "The Part has been changed - the new Part Number is: " > & > > PN & ". An Update will show the effected change." > > End If > > End If > > > > > >
Message 4 of 4
lothar.maier
in reply to: Anonymous

I also found .saveas in assemblies not very stable 😞
The only way I found to change filenames / references was to use apprentice and to reopen the assembly.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report