Martin Crawford Posted April 19, 2021 Share Posted April 19, 2021 Is there a way to reset some custom plug-ins, and when done return to the layer that called the refresh? I have two custom plug-in, the first is a "data circuit", the second is a "data note" with info from the data circuit. From a Sheet layer I want to use a menu command to run "Refresh Notes", that will refresh the "data circuit", then refresh the "data note" and when all done I would like to stay on the Sheet Layer. Currently when I do the refresh on the "data circuit" it changes to the Design layer and so far nothing I have done can get it back to the Sheet Layer. I suspect is has to do with the ForEachObject not working like I think it should. Any thoughts on how to move forward? Thanks Martin Quote Link to comment
JBenghiat Posted April 19, 2021 Share Posted April 19, 2021 You can store the name of the active layer and then call vs.Layer( storedLayerName ) at the end of your script — however, your refresh script shouldn't be changing your view. First determine if your reset script is changing the view (it should basically be vs.ForEachObject( vs.ResetObject, "PON='{plug-in_name}'") ) or if your data circuit object is unnecessarily changing the view. Quote Link to comment
Martin Crawford Posted April 19, 2021 Author Share Posted April 19, 2021 My code is super simple. When the routine completes, it always up on the Design Layer. layerName = vs.GetLName(vs.ActLayer()) vs.ForEachObject( vs.ResetObject, "PON='Create Data'" ) vs.ForEachObject( vs.ResetObject, "PON='Create Circuit'" ) vs.ForEachObject( vs.ResetObject, "PON='Create Notes'" ) vs.ForEachObject( vs.ResetObject, "PON='Create Scehdule'" ) vs.Layer(layerName) I do change layers inside of Create Data and Create Circuit and it looks like whichever of those two runs last determines what layer it is on. Create Note and Create Schedule are on Sheet Layers and neither change layers. What does not make sense is why my Vs.Layer at the end does not change back to the sheet layer. Martin Quote Link to comment
JBenghiat Posted April 20, 2021 Share Posted April 20, 2021 Script-based plug-ins run linearly, so the resets actually happen after the script completes. You should look at your Create scripts. There's no reason to switch the active layer — you can send any object to any layer without making it active, and if you do change the view, you should always restore it. 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.