Jump to content

Create New Class Using NAMECLASS


Recommended Posts

import vs;

List = ['Astera AX5','Astera AX3','ChromaQ ColorForce II 12']

for i in List:
	vs.AlrtDialog(i)
	vs.NameClass(i)

  Running code on VWX 2023, it suppose to create three classes as ' Astera AX5' , 'Astera AX3' , 'ChromaQ ColorForce II 12', but it creates ' Astera AX6' , 'Astera AX4' , 'ChromaQ ColorForce II 13'. Basically, numbers in the end get +1 increment for some reason.

 

I am not sure how to fix that. any leads are appreciated

Broken File.vwx

Edited by Jiajing
Link to comment
5 minutes ago, Jiajing said:
import vs;

List = ['Astera AX5','Astera AX3','ChromaQ ColorForce II 12']

for i in List:
	vs.AlrtDialog(i)
	vs.NameClass(i)

  Running code on VWX 2023, it suppose to create three classes as ' Astera AX5' , 'Astera AX3' , 'ChromaQ ColorForce II 12', but it creates ' Astera AX6' , 'Astera AX4' , 'ChromaQ ColorForce II 13'. Basically, numbers in the end get +1 increment for some reason.

 

I am not sure how to fix that. any leads are appreciated

 

Interestingly, I tried the same code on a brand new file, it works. lol

Edited by Jiajing
Link to comment

Unique names affect more than just the class list.

 

The name list includes resources, classes, and names assigned to objects. For example, if you have a symbol named "Astera AX5," you can't also have a class with the same name. I believe layers is the only object type that doesn't share the name list, but there may be a few others.

 

Generally, any time you create a named object, you should check to see if the name already exists. Checking if vs.Name2Index() > 0 is a good way to confirm the existing name.

  • Like 2
Link to comment
7 minutes ago, JBenghiat said:

Unique names affect more than just the class list.

 

The name list includes resources, classes, and names assigned to objects. For example, if you have a symbol named "Astera AX5," you can't also have a class with the same name. I believe layers is the only object type that doesn't share the name list, but there may be a few others.

 

Generally, any time you create a named object, you should check to see if the name already exists. Checking if vs.Name2Index() > 0 is a good way to confirm the existing name.

Thank you, Josh. That explained, after I delete symbol, the code works just fine. good to know.

 

I can not have class named 'Astera AX5', but I can add prefix and have class named as 'LX-Asteria AX5'. That might be a work around.

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