Sets the value of the specified attribute.

syntaxSyntax:
DlxObject.SetAttribute(name, category, value, info = "", orderId = "", flags = 0)

Parameters

Parameter Description
name Specify the name of the attribute.
category For each attribute, the category to which it belongs must be indicated. The following categories are predefined: OBJECT, SHAPE, SPICE, DEVICE, PACKAGE.
value Specify the value.
info Enter a brief description of what the attribute represents and, if applicable, the range of valid values.
orderId You can specify a number to reorder attributes when they are listed. Attributes are sorted by the increasing value of the Order Id. This parameter can also be used to filter attributes so that only those attributes related to the selected option are shown in a ListBox.
flags Specifies the horizontal and vertical alignment of the text with respect to the insertion point. Enter a combination of the following values:
DlxApp.ATTRIBUTEFLAGS_ADVANCED For attributes that do not normally require a change to their value
DlxApp.ATTRIBUTEFLAGS_HIDDEN For attributes set in the library that do not need to be changed.
DlxApp.ATTRIBUTEFLAGS_REQUIRED For attributes that must necessarily have a value. If the value of the attribute is empty, a message is displayed when closing the object properties dialog box.
DlxApp.ATTRIBUTEFLAGS_SEPARATOR It only has the function of displaying a separation line when attributes are listed in the object properties dialog box.
DlxApp.ATTRIBUTEFLAGS_LISTBOX

To create a multiple-choice attribute. This attribute type must be defined when creating library files by specifying the list of all valid values in the Value parameter. When the object is inserted into a drawing, you can select the appropriate value from a list box. The values must be listed according to the following scheme:

  1. The first line must contain an integer numeric value that specifies the line number (beginning from zero) that contains the currently selected value.

  2. The list of values starts from the second line. A single value per line must be specified.

The lines containing the values have the following format:

<title> [§<value> [§<orderId>[,<orderId>]*]]

title specifies the name to be reported in the list box, while value specifies the actual value of the attribute. If the title and value match, only the title can be specified. orderId is the Order Id property of the attributes to be displayed exclusively when the line is selected. In this way, the attributes can be filtered to show only those relevant to the selected option. Only attributes belonging to the same category of the ListBox are filtered.

Examples:

If the possible values of an attribute are: ON, OFF. Considering ON as the default value, the list of values is as follows:

0
ON
OFF

In the following example, the two numeric values are listed in the list box with a more descriptive name:

0
Minimum§1e3
Maximum§1e9

In the following example, each option is associated with a list of attributes (indicated through its Order Id). When an option is selected, only the attributes included in the list are shown:

0
Option1§value1§10,20,30
Option2§value2§40,50,60

Include external lists

If the same list of options is to be inserted as a ListBox attribute in many components, it is convenient to define the list of options in a SPICE document using the .DATA directive and then include it in a ListBox by simply specifying its name preceded by the @@ string. For example, in a SPICE document you can define the following list:

.DATA @@LIST1
Option1§value1
Option1§value2
Option3§value3
.ENDD

in the ListBox attributes is sufficient to insert the following line:

0
@@LIST1

The lists of options listed in the table below are predefined:

Name Description
@@IOMODELS Lists I/O models.
@@NETS Lists all nets from the current design document.

Return Value

If the attribute is set correctly it returns true otherwise it returns false.

Example

  Copy codeCopy code
var prj = DlxApp.GetJob().GetProject("Example Sch");
if (!prj.IsValid())
  prj = DlxApp.GetJob().NewProject("Example Sch");
var doc = prj.GetDocument("Examples Sch", DlxApp.DOCTYPE_SCHEMATIC);
if (!doc.IsValid())
{
  doc = prj.NewDocument("Examples Sch", DlxApp.DOCTYPE_SCHEMATIC);
  doc.SetPageFormat("A4", false);
}
if (doc.IsValid() && doc.Activate())
{
  var page = doc.GetActivePage();
  if (page.IsValid())
  {
    var layer = page.GetLayerFromType(DlxApp.LAYERTYPE_DRAWING);
    if (layer.IsValid())
    {
      var obj = layer.DrawEllipse(new DlxPoint(50,50), 10);
      obj.SetAttribute("My Attr", "My Category", "0\nValue1\nValue2\nValue3", 
         "Example of ListBox attribute", "1", DlxApp.ATTRIBUTEFLAGS_LISTBOX);
    }
  }
}

See also