Ben624 Posted March 30, 2006 Share Posted March 30, 2006 Is there a way to reference the last instance of a PIO from its own script? I'm trying to create a tool that will essentially number itself as I use it repeatedly. So when I use this tool (the 'Channel Indicator'), it will check the value of the channel parameter for the last instance that I created and increase it by one for the currently executing instance. Does that make sense? Ben Quote Link to comment
ccroft Posted April 1, 2006 Share Posted April 1, 2006 How many instances of this PIO are there likely to be in a drawing? One way would be to get a handle to the last created instance. You then use GetRField to get the value. 'Record' is the name of the PIO and 'Field' is the name of the parameter field. Another perhaps simpler approach is to count the number of existing instances of the PIO and increment by one. What will happen to this numbering scheme if you make changes might be something to think about. You might use IsNewCustomObject to stop a PIO from re-numbering if you make other changes and it was created in the middle of the sequence. Depending on how you use this PIO, this may not be a problem. Charles Quote Link to comment
Miguel Barrera Posted April 3, 2006 Share Posted April 3, 2006 One way would be to create a number ID parameter and then use ForEachObject(,) to iterate thru each PIO to get the value of the parameter. You can then test for any gaps in the sequence or find the highest value. Miguel 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.