Martin Crawford Posted March 16, 2018 Share Posted March 16, 2018 Hi I have created a python script to draw LED panels and data lines. The LED panels should be on one layer and the lines on a separate layer. I thought I could use vs.Layer('Screen - Panels') for the LED Panels and vs.Layer('Screen - Data') for the data lines and simply call them before drawing the objects. When the script runs, everything is on the last vs.Layer used, in this case 'Screen - Data' Quote Link to comment
MullinRJ Posted March 16, 2018 Share Posted March 16, 2018 Martin, Try this script: import vs; vs.Layer('Screen - Panels') vs.Rect(0, 0, 1, 1) vs.DSelectAll() vs.Layer('Screen - Data') vs.ArcByCenter(1, 1, 0.5, -90, 270) vs.DSelectAll() It creates a layer and draws a Rectangle on it (and deselect it), then creates another layer and draws an Arc on it (and deselect it). How does this differ from your script? Raymond Quote Link to comment
Martin Crawford Posted March 17, 2018 Author Share Posted March 17, 2018 If I run the above as a script everything shows up on the correct layers, however if I create a plug-in object and run the exact same code, everything is on the Screen - Data layer. I was not doing a deselect all and I thought that would be the problem, however it still is not working. Is there something else that needs to be done because I am doing this within a plug-in? Martin Quote Link to comment
Martin Crawford Posted March 17, 2018 Author Share Posted March 17, 2018 Interestingly, if I create a Marionette node to create two object on two different layers, it works, if I then convert the marionette to an object node, then it no longer works. I suspect because the Marionette changes the parent obj to change a layer, however this fails when working with a plug-in object. Is there a way to have a plug-in with objects on separate layers and classes? This seems like it should be straight forward. Thanks Quote Link to comment
MullinRJ Posted March 17, 2018 Share Posted March 17, 2018 Martin, A basic Plug-In object is a SINGLE object and it must reside on one layer. It can contain multiple parts, like a symbol or a group, but it is treated as ONE object. You can put the pieces in multiple classes, but not on multiple layers. It is possible to "cast off" objects to other layers as your Plugin code runs, but that is definitely not standard practice. You could run your code as a Menu Command and draw on separate layers. That is more akin to running code from a script palette. Write back if you need more direction. Raymond Quote Link to comment
Pat Stanford Posted March 19, 2018 Share Posted March 19, 2018 Another way to think about it. Everything drawing inside of a PIO is considered part of that PIO. Since the PIO can only exist on a single layer, all of the objects inside that PIO must be on that layer. If it is possible to adjust your file to use Classes instead of Layers, then you can keep everything inside the PIO. If you have to use layers, as Raymond says, the objects will have to be "cast off." I think you can do this by using the SetParent command and a handle the the objects that need to be on the other layer. Set the Parent to the layer you want them to be on. Quote Link to comment
Martin Crawford Posted March 19, 2018 Author Share Posted March 19, 2018 Thanks, I think I can make it work with a combination of classes and layer. And I think I understand the layers and PIO 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.