Jump to content

Why doesn't RecalculateWS procedure work?


David L

Recommended Posts

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);

Link to comment

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);

  • Like 1
Link to comment

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.

Link to comment
  • Vectorworks, Inc Employee

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

Link to comment

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.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...