Jump to content

Script to Reset all PIOs of Selected Type


Recommended Posts

  • Vectorworks, Inc Employee

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
Link to comment
  • 2 weeks later...

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

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...