This script is to add a new user layer to be prepared to add drawing or text to the layer.
Before using Document.PutUserLayerGfx or Document.PutUserLayerText to add drawong or text, this code can be used to make sure if the user layer is prepared.
The script will begin with a prompt dialog to enter the layer name to add, and add the user layer or (if the layer already exists,) remove all drawings/texts on the layer.
Automation method to add a user layer requires saving PCB database, so I added the Document.Save statement after adding a user layer.
This script is not officially supported, so please use at your own risk.
' DISCLAIMER OF WARRANTY: Unless otherwise agreed in writing,
' Mentor Graphics software and associated files are provided "as is"
' and without warranty. Mentor Graphics has no obligation to support
' or otherwise maintain software. Mentor Graphics makes no warranties,
' express or implied with respect to software including any warranty
' of merchantability or fitness for a particular purpose.
' LIMITATION OF LIABILITY: Mentor Graphics is not liable for any property
' damage, personal injury, loss of profits, interruption of business, or for
' any other special, consequential or incidental damages, however caused,
' whether for breach of warranty, contract, tort (including negligence),
' strict liability or otherwise. In no event shall Mentor Graphics'
' liability exceed the amount paid for the product giving rise to the claim.