%setlocallist keyword (SDL script)
This keyword sets the content of a local list of Modeler items. A local list is local to the generation template that declares the list (TDK Legacy model and TDK 3G model) or local to the item (TDK Code Generation Transformation Patterns model). You can set the list to the current item by setting the list to 'This'. You can set a list to the content of list unions and intersections, and you can set a list to the items that are linked to the current item through a specific link type.
The current item is derived as follows:
ACS calls the top-level Generate.sdl generation template for each item (Model, Package or Class) that is selected either directly or indirectly for generation. On entering the Generate.sdl generation template, the selected Model, Package or Class is the current item.
The current item remains as the selected Model, Package or Class until a For loop iterates a collection of linked items or items in a list. During a For loop, the current item is the item that is currently being iterated.
After leaving a For loop, the current item reverts to the item that was the current item before entering the For loop.
* 
Before setting a local list, you must declare it in the generation template using the %locallist keyword. You can read the content of a local list through the %getlocallist keyword.
Syntax
To set a local list to the current item:
%setlocallist "<name of list>" = "This"
To set a local list to the content of another list (set to intersection or union of list with itself):
%setlocallist "<name of list>" = %getlist "<name of list>" * %getlist "<name of list>"
To set a local list to the union of two other lists:
%setlocallist "<name of list>" = %getlist "<name of list>" + %getlist "<name of list>"
To set a local list to the intersection of two other lists:
%setlocallist "<name of list>" = %getlist "<name of list>" * %getlist "<name of list>"
To clear a local list:
%setlocallist "<name of list>" = ""
To set a local list to the items linked to the current item:
%setlocallist "<name of list>" = "<link type>"
The <link type> is the automation interface name of the link type that links the current item to other items. For more information about the automation interface names of link types, see Object Attributes and associations under the Automation Interface chapter of the Windchill Modeler Help, and then click the required item type. The link types are listed in the Associations section.
Setting a list to the intersection of two lists
Setting a list to the items linked to the current item
Example 11. Setting a list to the intersection of two lists
This example works in the context of a Class. The For loop processes each Attribute of the Class in turn. For each loop, the CurrentObject local list is set to the current Attribute and then the ChildAttributes global list is appended with the CurrentObject local list. After the For loop, the list2 list is set to the content of the ChildAttributes list.
Notice that the List2 local list is set to the content of the ChildAttributes list by intersecting the ChildAttributes list with itself.
%locallist "ChildAttributes"
%setlist "ChildAttributes" = ""
%for "Attribute"
%setlocallist "CurrentObject" = "This"
%setlist "ChildAttributes" = %getlist "ChildAttributes" + %getlocallist "CurrentAttribute"
%endfor
%setlocallist "List2" = %getlist "ChildAttributes" * %getlist "ChildAttributes"
Example 11. Setting a list to items linked to the current item
In this example, the current item is a Class. The ChildAttributes list is set to the collection of child Attributes, which are linked to the Class through the Attribute link type.
%setlocallist "ChildAttributes" = "Attribute"
Was this helpful?