Jump to content
Sign in to follow this  
Robert Anderson

Script to Reset all PIOs of Selected Type

Recommended Posts

I cobbled out a little useful general purpose script for resetting all instances within a drawing of a selected PIO. (Ain't VectorScript grand?)

Here it is.

PROCEDURE Reset_All_Like_Selected;
CONST
kErrStr_no_select = 'ERROR: Nothing selected.
Select an example of the object type you want to reset and run this script again.';
kConfirm_prefix = 'Are you sure you want to reset all objects of type "';
kConfirm_suffix = '"?';

VAR
PIO_name:STRING;

BEGIN
IF fsactlayer <> NIL THEN
   BEGIN
   PIO_name := GetName(GetRecord(fsactlayer,NumRecords(fsactlayer)));
   IF YNDialog(concat(kConfirm_prefix,PIO_name,kConfirm_suffix)) THEN ForEachObject(ResetObject, R IN [PIO_name]);
   END ELSE Alrtdialog(kErrStr_no_select);
END;

RUN(Reset_All_Like_Selected);

Edited by Robert Anderson

Share this post


Link to post

PIO_name := GetName(GetRecord(fsactlayer,NumRecords(fsactlayer)));

Interesting bit of wisdom here. I was wondering why NumRecords for the GetRecord index so I played with this one a bit. One works fine....as long as there aren't any other records besides the parameter record attached to the PIO.

Sooo...the parameter record, it turns out, is always the last one in the list of records attached to a PIO, so if there's 2 others attached, NumRecords returns 3 and that's the index for the record that returns the PIO name. Obvious to some I guess, but not me.

Thanks Robert,

Charles

Share this post


Link to post

Yes, the PIO parameter record will always be the Nth record attached to a PIO that has N records attached. By the way, this is documented nowhere AFAIK and is the result of trial-and-error testing, whence cometh so much profound programming knowledge :)

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...