Help: using iLogic to copy a parts and assemblies from a library into a separate assembly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am working on a project outlined as follows:
-There is a library of parts, and a library of assemblies that are used as "templates". The libraries are named iLogicParts and iLogicAssems
-In my model "top-level" assembly, the iLogic code written is supposed to grab the file from the source (library), and copy it into a folder within the current assembly (MemberFiles). This way, the parameters that are changed from the user in the form only change the component occurrence being used in this assembly, not the one in the library.
The problems I'm having are are follows:
-When I update a base component and save it into the Library folder, replacing the old one, the part in the model does not update to the new version. I am using the fso.copyFile function and have tried setting the last parameter to "true" which is supposed to overwrite any existing file in the destination (MemberFiles). I cannot get that to work as it's supposed to. I've tried deleting the component from the model tree and MemberFiles folder, but when the code runs, it still somehow pulls in the old version of the component (which has been deleted from everywhere, even the OldVersions folder) instead of the new updated one that is currently in the Library. However, if I close out of Inventor entirely, and delete the part from all the folders mentioned above, then re-open inventor, it works. I've read about people who say they have had similar issues that have been fixed by clearing the cache, but that does not solve the problem for me.
I am going crazy trying to figure out if my code is the problem or if I need to close out of Inventor every single time I make a change.
Any ideas about why the file isn't updating would be GREATLY appreciated. There are other issues in the code I'm working thru, but it's hard to do when I have to close out of inventor every few minutes, so plz ignore the other bugs (if you don't change any parameters there shouldn't be any other bugs).
Code snippet looks like this:
Dim oProjectMgr As DesignProjectManager Dim oProject As DesignProject Dim oLibraryPaths As ProjectPaths Dim oLibraryPath As ProjectPath Dim ProjectPath As String Dim PartFactoryPath As String Dim AssemFactoryPath As String Dim sourceFile As String Dim destFile As String Dim fso = ThisApplication.FileManager.FileSystemObject oProjectMgr = ThisApplication.DesignProjectManager ' Get the active project oProject = oProjectMgr.ActiveDesignProject ProjectPath = oProject.WorkspacePath 'MessageBox.Show(ProjectPath, "Project Path") oLibraryPaths = oProject.LibraryPaths oLibraryPath = oLibraryPaths.Item("iLogicParts") PartFactoryPath = oLibraryPath.Path & "\" oLibraryPath = oLibraryPaths.Item("iLogicAssems") AssemFactoryPath = oLibraryPath.Path & "\" 'MessageBox.Show(PartFactoryPath, "Part Path") 'MessageBox.Show(AssemFactoryPath, "Assem Path") Dim refOffset As Single Dim refPart1 As ComponentArgument
Dim refPart2 As ComponentArgument
sourceFile = AssemFactoryPath & "BaseplateAssem.iam" MessageBox.Show(sourceFile, "source") destFile = ProjectPath & "\MemberFiles\BaseplateAssem" + ".iam" MessageBox.Show(destFile, "dest") '[ Copy file & Test to see if working Try fso.copyFile(sourceFile, destFile, False) Catch 'MessageBox.Show("Copy Fail", "Title") End Try '] Dim Baseplate_Fab = Components.Add("Baseplate_Fab", destFile, position := Nothing, grounded := False, visible := True, appearance := Nothing)