Jump to content

Creating Sheet Layers


Recommended Posts

Hi

 

I am having a strange issue when I try to use Python to create sheet layers. The following code:

            layerName = 'Module Layout - ' + screenName
            vs.CreateLayer(layerName, 2)


Creates the follwoing:

 

image.thumb.png.e94819cbb037d1419bdf628aae5eb36a.png

 

How would I set the Sheet Number and set the Sheet Title of the text in the Sheet Number?

 

Thanks

 

Martin

 

Link to comment
screenName = "Screen 1"
SheetNumber = "01"
layerType = 2
layerName = "Module Layout - " + screenName

newLayerHandle = vs.CreateLayer(SheetNumber, layerType) # <-- Sheet Number in the Sheet Layer context, confusing I know
vs.SetObjectVariableString(newLayerHandle, 159,layerName) # <-- Found on the DevWiki Appendix page. Documentation states Layer Description, which is also misleading, as it is actually the Sheet Layer 'name'

 

Link to comment

In the Sheet Layer context, the Sheet Number component, is basically the Layer name.

so you'd use:

 

"""
Disclaimer: no warranties of any kind, expressed or inclined. Code provided for self-help use only. Save work, save often.
Tui W K 2018
"""
def list_layers():
  # sub_function to retrieve list of layer names in document
  layer_names = []
  hLayer = vs.FLayer()
  while hLayer != None:
    layer_names.append(vs.GetLName(hLayer))
    hLayer = vs.NextLayer(hLayer)
  return layer_names

# SAFE CHECK:
# check if name is in the layer list,
# then create new layer if it's not in the list. 
cur_layer_to_change_name = "SomeCurrentLayerName" #Replace Name of an existing Sheet Number
cur_layer_handle = vs.GetLayerByName(cur_layer_to_change_name)

newLayerName = "SomeNewName"
if newLayerName not in list_layers():
  vs.SetName(cur_layer_handle, newLayerName)

 

HTH,

Tui

 

Link to comment
  • 3 years later...

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