Pulsonix User Forum

Technical advice from Pulsonix engineers and the wider community.

Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help with using Pulsonix
 Scripting
 Change Variant Description
Author Previous Topic Topic Next Topic  

Heinrich

Germany
9 Posts

Posted - 18 Apr 2018 :  13:38:03  Show Profile  Reply with Quote
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!!

psxforum

United Kingdom
66 Posts

Posted - 18 Apr 2018 :  13:49:25  Show Profile  Reply with Quote
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.

Go to Top of Page

Heinrich

Germany
9 Posts

Posted - 18 Apr 2018 :  17:19:33  Show Profile  Reply with Quote
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 !!
Go to Top of Page

Heinrich

Germany
9 Posts

Posted - 19 Apr 2018 :  06:44:43  Show Profile  Reply with Quote
Sorry,
the first error is a mistake from my side. I have simply forgotten the item()-method. I am not so familar with JScript.
Go to Top of Page

Jochen

Germany
8 Posts

Posted - 09 Jul 2018 :  13:03:48  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
Jump To: