- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @WCrihfield ,
thanks for replying to this. i had looked at a couple of the links you sent, but the ones i looked at dealt with copying an assembly and components and got overwhelmed by the coding... but dissecting code from @Curtis_Waguespack , by adding the path to the new file name, it works and file is saved!!
thanks to you (and Curtis) for helping out with this, it is much appreciated!
but, of course, i now have another issue...
basic program is...
- input paramters
- delete components from assembly (save assembly)
- insert new components
- delete component from directory if it exists
- rename and save component
- adds mates, etc, repeat
the program works fine the first time thru. but if i go to run it again, i get an error with the 1st component 'SaveAs' as shown here. if i save the assembly, close it and open it up again, it runs the way it should. any idea what the issue might be, something stuck in memory that gets cleared out when i close the file...
again, really appreciate your help on this. these forms are (work)life savers!!
iLogicVb.RunRule("delete old plates") Dim PLATE_PRE =PROJECT_NUMBER &"-P" Sentence = PLATE_LAYOUT Words = Sentence.Split(Separators) NUM_PLATES = (UBound(Words) + 1) Logger.Debug(NUM_PLATES) If NUM_PLATES > 16 Then MessageBox.Show("TOO MANY PLATES - 16 MAX") GoTo OVEROUT Else GROUND = False i = 0 For i = 1 To NUM_PLATES PLATE_NAME = PLATE_PRE & (i) Logger.Debug(PLATE_NAME) 'MessageBox.Show(PLATE_NAME, "PLATE #") If i = 1 Then GROUND = True Dim componentB = Components.Add(PLATE_PRE & i, "SC-H-2R-P1.ipt", position := Nothing, grounded := GROUND, visible := True, appearance := asgreen) doc= Component.InventorComponent(PLATE_PRE & i).Definition.Document sPath = Component.InventorComponent(PLATE_PRE & i).ReferencedFileDescriptor.FullFileName File_new_name = PLATE_PRE & i & ".ipt" Logger.Debug(File_new_name) Logger.Debug(sPath) sSplit = sPath.Split("\") 'get the Upper Bounds of the array 'knowing that this will be the File name with extention sName = sSplit(UBound(sSplit)) 'remove file name from path sPath = Replace(sPath, sName,"") Logger.Debug(sPath) file_delete = (sPath & File_new_name) 'check to see if file exists. delete if it does If Dir(file_delete) <> "" Then MessageBox.Show("it exists", "Title") Kill(file_delete) Else MessageBox.Show("no file in directory", "Title") End If 'save new part doc.SaveAs(sPath & File_new_name, False) GROUND=False GoTo JUMP_NEXT