How to create layer by python code?

edited October 22 in Python scripting

Hello,

I am trying to create a layer to play the interesting code that discussed as posted directly, instead of using " New layer " function manually. but seems not easy for me, please refer to below code, and your suggestion will be appreciated. This code is not worked, but after running this, the create layer function " New layer " will be failed also, and alarm occurred

layout = pya.Application.instance().main_window().current_view().active_cellview().layout() 
top = pya.Application.instance().main_window().current_view().active_cellview().cell
cell_index = top.cell_index()
metal = layout.layer(9, 0)
metal_layerinfo = pya.LayerInfo(9, 0)
layout.insert_layer_at(9, metal_layerinfo)

Comments

Sign In or Register to comment.