Pulsonix User Forum

Technical advice from Pulsonix engineers and the wider community.

 All Forums
 Help with using Pulsonix
 Scripting
 Change Variant Description

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON

   Upload a file

Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Heinrich Posted - 18 Apr 2018 : 13:38:03
Hello,
how can I change the Variant.Description with a script.
I can change the Variant with the Design.SelectVariant() command and I can
then get the variant description with
Design.GetAttribute("<Current Variant Description>")

Then I want to change the the description through the DesignItem-Obtject
variant.description
In the help I see that I can set this data, but how can I do that?

Hope somebody can help me! Thanks!!
4   L A T E S T    R E P L I E S    (Newest First)
Jochen Posted - 09 Jul 2018 : 13:03:48
Hi,

Design.Variants is a collection of variant objects that you can not write.

You have to use the SelectVariant() method of the Document.

Jochen
Heinrich Posted - 19 Apr 2018 : 06:44:43
Sorry,
the first error is a mistake from my side. I have simply forgotten the item()-method. I am not so familar with JScript.
Heinrich Posted - 18 Apr 2018 : 17:19:33
I tried to do your suggestion in JScript:

var Design = ActiveDocument();
objVariant = Design.Variants();
var VarName = new Enumerator(objVariant);
for (; !VarName.atEnd(); VarName.moveNext()) {
var Name = VarName.Name;
var Desc = VarName.Description;
Message(Name + " - " + Desc + " - " + VarName.Description);
}
objVariant = VarName;
Design.Variants = objVariant;

I have defined two Variants in my schematics, "001", "002" and two different variant description.

1st error:
in the messagebox all three variables are shown as "undefind"

2nd error:
The last command (Design.Variants = objVariant) result in the error,
that Pulsonix forbid to write Design.Variants.
Is that not the same as in VBScript?

Thank you for your help !!
psxforum Posted - 18 Apr 2018 : 13:49:25
There isn't a way to get the current variant, nor to directly change its name or description.

However, you can iterate through the variants in the design and set their descriptions like this:

'vbs
Option Explicit
Dim psxDoc, psxVariants, psxVar
Set psxDoc = Application.ActiveDocument() 'an active schematic design containing a few variants…
Set psxVariants = psxDoc.Variants
For each psxVar in psxVariants
psxVar.Description = "My new description"
Next


Maybe you could include a test to see if psxDoc.CurrentVariantName = psxVar.Name to ensure that you change the name of only the current variant.

David.