API to reload sheet template
API to reload sheet template
(OP)
From time to time the company sheet formats get updated. I was looking at creating a macro to automate the process up upgrading a drawing to the new version of the format (with the same file name). However, on some drawings (seems random to me), SolidWorks does not allow a reload without convincing it I'm loading a new format (clicking another format and then reselecting the original in the sheet properties window). This issue has been cropping up from time to time across multiple releases of SW.
Anyway, it's been annoying, but ignorable problem. However, now that I'm trying to automatic the process of sheet format updating, this has become a show stopper. Does anyone know a way to force SW to reload a format via API? SetupSheet4 does nothing but mimic the problem that occurs manually and I can't find a API workaround.
Anyway, it's been annoying, but ignorable problem. However, now that I'm trying to automatic the process of sheet format updating, this has become a show stopper. Does anyone know a way to force SW to reload a format via API? SetupSheet4 does nothing but mimic the problem that occurs manually and I can't find a API workaround.
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group






RE: API to reload sheet template
Have you tried using the Reload option in the Sheet Properties dialogue box?
RE: API to reload sheet template
At this time, the only API workaround I can figure out is to tell SW to load a completely different format, then load the correct format from the new location., but that is a bit ridiculous.
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
RE: API to reload sheet template
RE: API to reload sheet template
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group
RE: API to reload sheet template
Ken
RE: API to reload sheet template
However, with a few hacks around that and the first issue, I made a macro that:
1. identifies the sheet currently on the drawing
2. loads a default SW format of the same size
3. loads the new format of the correct size
4. adds the revision block
Issues I ran into:
1. SolidWorks doesn't reload a new sheet format by the same name as the drawing's current sheet format if the current sheet format is physically no longer where SW expects it, but SW still pretends to perform the reload. Solution was to load a fake format first, then load the new desired format.
2. couldn't figure out how getsize works, so had to make a work around using the GetSheetName. I had a surpizing issue with GetSheetName too where SolidWorks was changing the name it reads for the sheet format from normal upper/lower windows names to all lowercase. Worked around that second issue with UCase.
3. found out that API methods for adding revision blocks uses a different "anchor point" than the manual method, making the default API method useless. Workaround was finding out the X,Y location s and listing them in the code directly.
Fun stuff when nothing works the way it is supposed at every step. The resulting code is hella ugly, but it does work.
Matt Lorono
CAD Engineer/ECN Analyst
Silicon Valley, CA
Lorono's SolidWorks Resources
Co-moderator of Solidworks Yahoo! Group
and Mechnical.Engineering Yahoo! Group