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