David L Posted January 29, 2008 Share Posted January 29, 2008 Why doesn't the RecalculateWS procedure work? The following simple script should go through a drawing and recalculate all Worksheets but nothing happens. I added the SetSelect procedure to see that something was happening and it does select all worksheets. I tried adding ResetObject procedure per another thread and a couple of other things but nothing makes the recalculate happen. I would appreciate any suggestions. PROCEDURE RecalcAllWorksheets; PROCEDURE RecalcWS(h:HANDLE); BEGIN RecalculateWS(h); SetSelect(h); END; BEGIN ForEachObject(RecalcWS, (T=WORKSHEET)); END; RUN(RecalcAllWorksheets); Quote Link to comment
Pat Stanford Posted January 29, 2008 Share Posted January 29, 2008 David, This was discussed back on the Vectorscript list in 2001. weren't you listening ;-) Apparently ForEachObject works on the list of visible objects in the drawing. If each Worksheet was visible on the drawing your code should work. Julian Carr (with some help from Robert Anderson and Victor Long of NNA) came up with the following that should recalc all worksheets in the drawing. Pat Procedure RecalcWS; VAR i : INTEGER; ObjectName : STRING; h1 : HANDLE; BEGIN FOR i := 1 TO NameNum DO BEGIN ObjectName := NameList(i); IF ObjectName <> '' THEN BEGIN h1 := GetObject(ObjectName); IF GetType(h1) = 18 THEN RecalculateWS(h1); END; END; END; Run(RecalcWS); 1 Quote Link to comment
David L Posted January 30, 2008 Author Share Posted January 30, 2008 Pat, Thanks, that script does the job. I added a count statement after the RecalculateWS statement and a dialog that comfirms the recalc and reports the number of worksheets recalculated, but it reports 434 while there are only 7 in the drawing. With the count incrementor in the GetType IF statement, it should only count the worksheets. I don't know what it is counting. Guess I'll use a dialog that confirms but doesn't count. BTW: With my original script all worksheets where visible on drawing, but it still didn't recalculate. Love the PodCad Podcast - never miss an episode. Quote Link to comment
Pat Stanford Posted January 30, 2008 Share Posted January 30, 2008 Send me a copy of your script and I will be happy to take a look. Pat Quote Link to comment
Vectorworks, Inc Employee Hugues Posted February 1, 2008 Vectorworks, Inc Employee Share Posted February 1, 2008 Hi David, RecalculateWS operates on the worksheet object itself not the worksheet image on the drawing. You need to get the worksheet object handle from its image. You do this by calling GetWSFromImage Your script should work if you modify your procedure like this: PROCEDURE RecalcWS(h:HANDLE); VAR h2 : HANDLE; BEGIN wsH := GetWSFromImage(h); RecalculateWS(h2); SetSelect(h); END; Hugues NNA Quote Link to comment
David L Posted February 3, 2008 Author Share Posted February 3, 2008 Hugues, That works like a charm in my original script, using the ForEachObject procedure. Please try and get NNA to add info like that in the VectorScript Function Reference. It would have helped me if that info was listed in the description of the RecalcWS procedure. I will post some of these scripts in the Resource Sharing section. All of my VectorScript knowledge came from analyzing other peoples scripts, so I think it would help others to have more scripts available to learn from, especially for people like me with no programming background. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.