I often re-use designs with slight modifications. Unfortunately, I don't bring the drawing with the model when doing a save-as. Instead, I typically open the old drawing at a later date, do a save-as to the new file name, then is the tricky re-referencing: close the drawing, go to open the drawing with the open dialog box, re-reference the part within the file, THEN open the drawing file with the proper model referenced.
I want to make a simple macro that will open the drawing of the same name as the model I am in, but re-reference the drawing automatically to the file that I am in. Seems simple, but I can't find any history of a macro for doing this.
I am using SolidWorks 2012 currently.
SolidworksApi macros
Is it possible for you to use "pack and go" command in SW? I think it will do what you are describing.
Well, Pack and Go would be good if I were doing it all at once, but I'm basically doing my design, then coming back weeks or possibly months later to re-reference a new part to a newly-made copy of an old drawing.
I think basically what I need is a macro to:
1 - Look for drawing file of same file name as part that is open.
2 - Get referenced model path from within drawing file.
3 - Open drawing file with command to re-reference from old part file to new part file.
4 - Profit.
If I understand your steps correctly, all you need to do is open the drawing. Two different part files with the same filename (even different path) cannot be open at the same time. If the filename of the old part and new part are the same, then when you open the drawing SolidWorks will automatically reference the file you have open. Then when you save the drawing (using save-as, of course, or you will overwrite the original drawing) it will reference the new path.
You are correct in your process, but unfortunately my file names (and locations) both change throughout the process.
C:\folder1\A.SLDPRT
C:\folder1\A.SLDDRW
become:
C:\folder2\B.SLDPRT
C:\folder2\B.SLDDRW
I save-as A.SLDPRT to B.SLDPRT during initial design stages, then later do a save-as for A.SLDDRW to B.SLDDRW. The problem is the B.SLDDRW still references A.SLDPRT, even when I 'Open Drawing' from B.SLDPRT.
I understand that the SW "pack and go" function not work for you at this moment but I saw a past thread;
https://forum.solidworks.com/message/241407#241407
And it lead me to this VBA code
http://help.solidworks.com/2011/English/api/sldworksapi/pack_and_go_an_assembly_example_vb.htm
when I ran the code it renamed the parts and not with a suffix or prefix but the entire file name was changed. Perhaps these two links will be a good jump off for you to modify the code per your specific needs per file name and file type.