- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm essentially performing a copy design on on an assembly by going through all the occurences, and copying them using the SaveAs command in ilogic. It is working well except for when i have the same part in 2 different assemblies. It will copy the first, and all the parts in it. This also does the parts in the second assembly, before it does a save as of that. The end result is it copies everything fine, However, when i come to open the original second assembly, it has the new copied parts in it.
I have not told inventor to save this file. I have also tried copying the assemblies first, and the parts second, but this also doesn;t seem to work.
Does anyone have any ideas how i can get around this problem? I somehow need to refresh the file from vault, but it doesn;t even know it's changed, so i have to delete it, and get it again... but i cant do that with ilogic because it's read only!
Im looping through all my occurences with this sub
SaveAsComponentAndDrawing(oOcc As ComponentOccurrence, TemplateFolder As String) i = i+1 oProgressBar.Message = ("Performing Copy Design on Part " & i & " of " & iStepCount & vbCrLf & oOcc.Name) '...and increase the progress bar scale oProgressBar.UpdateProgress 'full file name with extension CurrentFullFilename = oOcc.ReferencedFileDescriptor.FullFileName 'file name without extension CurrentFilename = TemplateFolder & IO.Path.GetFileNameWithoutExtension(CurrentFullFilename) 'file extension only oExtension = CurrentFullFilename.Substring(CurrentFullFilename.Length - 4) CheckIfDrawingExists(CurrentFilename) oNewFileName = ReturnNewFileName(oOcc) oNewDrawingName = oNewFileName.Substring(0,oNewFileName.Length - 4) & ".dwg" 'True opens visible, False opens invisible ooDoc = ThisApplication.Documents.Open(CurrentFullFilename, True) ' opens ipt file 'set part number ooDoc.PropertySets("Design Tracking Properties").Item("Part Number").Value = IO.Path.GetFileNameWithoutExtension(oNewFileName) ooDoc.SaveAs(oNewFileName, False) ' false means open new file 'ooDoc.Update() ooDoc.Close 'Open the current drawing (In same folder location) Dim DrawingDoc As DrawingDocument = ThisApplication.Documents.Open(CurrentFilename & ".dwg",True) 'Perform 'Save As' on the drawing DrawingDoc.SaveAs(oNewDrawingName, False) ' false means open new file 'Replace reference to assembly model Dim oFD As FileDescriptor oFD = DrawingDoc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor oFD.ReplaceReference(oNewFileName) DrawingDoc.Update() Try DrawingDoc.Parameters.Item("i").Value = 1 Catch End Try DrawingDoc.Update DrawingDoc.Save DrawingDoc.Close 'ooDoc.Close ComponentArray.Add(oNewName & oExtension) For Each subOcc As ComponentOccurrence In oOcc.SubOccurrences If subOcc.Name.Contains(TemplateCode) SaveAsComponentAndDrawing(subOcc, TemplateFolder) End If Next End Sub
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I got a same trouble few days ago.
Document.SaveAs Method in the API Document is written as following :
> Saves this document into a file of the specified name. None of the dependent documents get saved.
But as far as I tried, every related documents will be saved.
In my case, the assembly had only part occurrences (no sub assemblies). So I copied (kept) Dirty flag of each Documents of the occurrences, set them false, SaveAs top assembly, and restored Dirty flags.
Even if the assembly has sub assemblies, you will be able to do this. (But you have to write a bit complex code.)
=====
Hideo Yamada
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I pointed to the behavior of SaveAs method. I'm sorry if your problem is not there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi,
save copy as works like this when used in code. if savecopyas is set to true it only saves new copy of file. if is set to false it saves and replace file in all opened documents. also in your scenario it open it in background as invisible file. my proposoal for you is use savecopyas with true value, then use replace functionality in assembly file. Whats about vault you can determine if file is in vault and you even can refresh it by ilogic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So I've found a work around. Seen as the Refresh Files function does not work, I delete all the template files using
My.Computer.FileSystem.DeleteFile(oFile)
Then i get all my files before i bring them into my assembly using
oVaultConnection.FileManager.AcquireFiles(oSettings)