Jump to content

Layers with Python


Recommended Posts

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'

 

 

Link to comment

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

 

 

 

 

Link to comment

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

Link to comment

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

 

Link to comment

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

Link to comment

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.

 

 

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