Pulsonix User Forum

Technical advice from Pulsonix engineers and the wider community.

Save Password
Forgot your Password?

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


9 Posts

Posted - 18 Apr 2018 :  13:38:03  Show Profile  Reply with Quote
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
In the help I see that I can set this data, but how can I do that?

Hope somebody can help me! Thanks!!


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:

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"

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.


Go to Top of Page


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


9 Posts

Posted - 19 Apr 2018 :  06:44:43  Show Profile  Reply with Quote
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


8 Posts

Posted - 09 Jul 2018 :  13:03:48  Show Profile  Reply with Quote

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

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

Go to Top of Page
  Previous Topic Topic Next Topic  
Jump To: