Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space PRINSAG and version 9.0
Sv translation
languageen

You can edit the code for action parameters that involve arrays of objects.
Many action parameters in Prinergy require lists (or arrays) of objects. For example, the Refine action needs a list of input files to refine, and the Perform Loose Page Output action needs a list of pages. Many event properties are also lists. For example, the Page Approval Changed event provides a list of pages where the approval status has changed.
Working with these arrays in code is considerably more complex than working with simple assignments.


Simple array assignment

When you want to pass all the members of an event property array to an action parameter array, the code looks the same as a simple assignment:

'This takes ALL the input files from the event and gives them to the action
action.InputFiles = triggerEvent.InputFiles


Using ArrayLists

ArrayLists are useful because they are untyped and unsized . They will expand as you add to them and you can put anything in them.

'Create an ArrayList and add items to it
Dim oArray As System.Collections.ArrayList = New
System.Collections.ArrayList
oArray.AddRange(System.IO.Directory.GetFiles("c:\", "*.pdf"))
oArray.Add(someOtherObject)


Converting ArrayLists to other arrays

After you have prepared the ArrayList, you probably need to convert it into other arrays to be used within the rules—arrays that are typed and sized.
ArrayList has a ToArray method that will copy the elements of the ArrayList to an array of a given type.
 

' Converts the ArrayList into an Array of Automation Pages
Dim oAlist As System.Collections.ArrayList ' . . . fill with contents
action.Pages =
oAList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))

 

The ToArray method only works if the contents of the ArrayList can be cast to the type you specify. If not, a runtime error appears. You must manually convert each item in the ArrayList to the array. For example, you cannot cast a String to a FileSystemItem, but you can use the CreateFrom factory method to create a FileSystemItem from a String.

' Converts the ArrayList into an Array of Automation FileSystemItems.
Dim oFSIArray() As Creo.PWS.Automation.PrinergyDataModel.FileSystemItem = _
New Creo.PWS.Automation.PrinergyDataModel.FileSystemItem(oAList.count
- 1) {}
For i As Integer = 0 To oAList.Count - 1
oFSIArray(i) = _
Creo.PWS.Automation.PrinergyDataModel.FileSystemItem.CreateFrom(oAList(i).T
oString)
Next i

 

Flattening nested arrays

Sometimes the data that you want to assign to an action parameter are spread over the members of an array in the event properties. For example, the results of a Refine action are available from an Input Files Refine OK event. When you look into that event, you see that it has the following properties:

Input Files Refined Successfully

The list of input files that refined successfully

Process

Refine process

Event time

Time that the event was processed

Root event

First event in the sequence

Previous Event

Previous event in the sequence

Where are the pages? Each of the refined input files has its own list of pages that were created from it. In other words, each member of the InputFiles array contains an array of pages.
To pass a list of all the refined pages to an action such as Perform Loose Page Output, we need a way to reach into each input file and build a collection of all the pages.

'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New
System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'We reach into the ith Input File and add its Pages array to our
list
newList.AddRange(triggerEvent.InputFiles(i).Pages)
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages =
newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))


Filtering an array

Another common requirement is the ability to filter parts of a list that you are not interested in. For example, you might want a simple way to create imposition proofs of only the front surfaces of every signature in your job. You want to pass to the Imposed Proof action a list of surfaces that has all the back surfaces filtered out.

'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New
System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.Surfaces.Length)
'We look at the ith Surface and add it to our list if it is “Front”
If triggerEvent.Surfaces(i).Side = "Front" Then
newList.AddRange(triggerEvent.Surfaces(i))
End If
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Surfaces and assign it to
the
'Surfaces parameter of the action
action.Surfaces =
newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Surface))


Filtering and flattening arrays

Combining the two patterns for flattening and filtering gives us the most power of all. In this example, we want a list of all the refined pages that are larger than 8.5 x 11. Since we need to look at every page in order to determine its size, this requires us to introduce a second loop. The outer loop goes through all the input files, while the inner (nested) loop goes through all the refined pages for each input file.

'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList

'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0

'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i &lt; triggerEvent.InputFiles.Length)

'Create a second counter and make a second loop to go through all
' the pages for input file i
Dim j As Integer = 0
Do While (j &lt; triggerEvent.InputFiles(i).Pages.Length)

'Grab the jth Page from the ith Input File
Dim thePage As Page = triggerEvent.InputFiles(i).Pages(j)

'See if the page is larger than 8.5 x 11 (in points) – if so add it to our list
If (thePage.TrimSize.x &gt; 8.5*72 AND thePage.TrimSize.y &gt; 11*72) Then
newList.add(thePage
End If

'Increment the value of j
j = (j + 1)
Loop

'Increment the value of i
i = (i + 1)

Loop

'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))

Sv translation
languagede

Sie können den Code für Aktionsparameter bearbeiten, die Arrays von Objekten umfassen.
Für viele Aktionsparameter in Prinergy sind Listen (oder Arrays) von Objekten erforderlich. Beispielsweise wird für die Aktion Refinen eine Liste von Eingabedateien für das Refining und für die Aktion Einzelseitenausgabe durchführen eine Liste von Seiten benötigt. Zahlreiche Ereigniseigenschaften bilden ebenfalls Listen. Beispielsweise stellt das Ereignis Seitengenehmigung geändert eine Liste von Seiten bereit, deren Abnahmestatus geändert wurde.
Die Arbeit mit solchen Arrays in Code gestaltet sich wesentlich komplexer als die mit einfachen Zuordnungen.

Anchor
Bookmark172_concept_EB754A418D5B4F77A029
Bookmark172_concept_EB754A418D5B4F77A029
Einfache Arrayzuordnung
Wenn Sie alle Elemente eines Ereigniseigenschaften-Arrays an ein Aktionsparameter-Array übergeben möchten, gleicht der Code einer einfachen Zuordnung:
'This takes ALL the input files from the event and gives them to the action
action.InputFiles = triggerEvent.InputFiles
Verwenden von ArrayLists
ArrayLists sind nützlich, da Typ und Größe nicht festgelegt sind. Wenn Sie Elemente hinzufügen, werden sie erweitert, und alle Arten von Elementen können hinzugefügt werden.
'Create an ArrayList and add items to it
Dim oArray As System.Collections.ArrayList = New System.Collections.ArrayList
oArray.AddRange(System.IO.Directory.GetFiles("c:\", "*.pdf"))
oArray.Add(someOtherObject)
Konvertieren von ArrayLists in andere Arrays
Wenn Sie die ArrayList vorbereitet haben, müssen Sie diese wahrscheinlich in andere Arrays konvertieren, die in den Regeln verwendet werden, d. h. in Arrays, deren Typ und Größe festgelegt sind.
ArrayList besitzt eine ToArray-Methode, mit der die Elemente der ArrayList in ein Array eines bestimmten Typs kopiert werden können.
' Converts the ArrayList into an Array of Automation Pages
Dim oAlist As System.Collections.ArrayList ' . . . fill with contents
action.Pages = oAList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))
Die ToArray-Methode funktioniert nur, wenn der Inhalt der ArrayList in den von Ihnen angegebenen Typ umgewandelt werden kann. Andernfalls tritt ein Laufzeitfehler auf. Jedes Element in der ArrayList muss manuell in das Array konvertiert werden. Beispielsweise können Sie keinen String in ein FileSystemItem umwandeln. Sie können jedoch mithilfe der CreateFrom-Factory-Methode ein FileSystemItem aus einem String erstellen.
' Converts the ArrayList into an Array of Automation FileSystemItems.
Dim oFSIArray() As Creo.PWS.Automation.PrinergyDataModel.FileSystemItem = _
New Creo.PWS.Automation.PrinergyDataModel.FileSystemItem(oAList.count - 1) {}
For i As Integer = 0 To oAList.Count - 1
oFSIArray(info) = _
Creo.PWS.Automation.PrinergyDataModel.FileSystemItem.CreateFrom(oAList(info).ToString)
Next i
Vereinfachen verschachtelter Arrays
In manchen Fällen sind die Daten, die Sie einem Aktionsparameter zuordnen möchten, über die Elemente eines Arrays in den Ereigniseigenschaften verteilt. Beispielsweise sind die Ergebnisse einer Aktion Refinen in einem Ereignis Eingabedateien refinen OK verfügbar. Dieses Ereignis enthält die folgenden Eigenschaften:

Erfolgreich einem Refining unterzogene Eingabedateien

Die Liste der Eingabedateien, die erfolgreich einem Refining unterzogen wurden

Verarbeiten

Refining

Ereigniszeit

Der Zeitpunkt, zu dem das Ereignis verarbeitet wurde

Stammereignis

Erstes Ereignis in der Abfolge

Vorheriges Ereignis

Vorheriges Ereignis in der Abfolge

Wo befinden sich die Seiten? Zu jeder Eingabedatei, die das Refining durchlaufen haben, gibt es eine Liste von Seiten, die daraus erstellt wurden. Das heißt, jedes Element des InputFiles-Arrays enthält ein Array von Seiten.
Wenn Sie eine Liste aller einem Refining unterzogenen Seiten an eine Aktion wie Einzelseitenausgabe durchführen übergeben möchten, muss auf jede einzelne Eingabedatei zugegriffen und eine Auflistung aller Seiten erstellt werden.
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'We reach into the ith Input File and add its Pages array to our list
newList.AddRange(triggerEvent.InputFiles(info).Pages)
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))
Filtern eines Arrays
Häufig ist es wichtig, die irrelevanten Teile einer Liste herauszufiltern. Beispielsweise wäre es nützlich, nur die Ausschieß-Proofs für die Vorderseiten-Formen jeder Signatur im Job zu erstellen. Dazu müssten Sie an die Aktion Ausschieß-Proof eine Liste von Formen übergeben, aus der sämtliche Rückseiten-Formen herausgefiltert wurden.
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.Surfaces.Length)
'We look at the ith Surface and add it to our list if it is "Front"
If triggerEvent.Surfaces(info).Side = "Front" Then
newList.AddRange(triggerEvent.Surfaces(info))
End If
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Surfaces and assign it to the
'Surfaces parameter of the action
action.Surfaces =
newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Surface))
Filtern und Vereinfachen von Arrays
Wenn Sie die beiden Muster zum Vereinfachen und Filtern kombinieren, ergeben sich die meisten Optionen. In diesem Beispiel benötigen wir eine Liste aller einem Refining unterzogenen Seiten, die größer als 8,5 x 11 sind. Da jede Seite überprüft werden muss, um die Größe zu ermitteln, wird eine zweite Schleife benötigt. Die äußere Schleife durchläuft alle Eingabedateien, während die innere (geschachtelte) Schleife für jede Eingabedatei alle einem Refining unterzogenen Seiten durchläuft.
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'Create a second counter and make a second loop to go through all
' the pages for input file i
Dim j As Integer = 0
Do While (j < triggerEvent.InputFiles(info).Pages.Length)
'Grab the jth Page from the ith Input File
Dim thePage As Page = triggerEvent.InputFiles(info).Pages(j)
'See if the page is larger than 8.5 x 11 (in points) – if so add it to our list
If (thePage.TrimSize.x > 8.5*72 AND thePage.TrimSize.y > 11*72) Then
newList.add(thePage
End If
'Increment the value of j
j = (j + 1)
Loop
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))

Sv translation
languagezh

可以编辑涉及对象数组的操作参数的代码。
印能捷中的许多操作参数需要使用由对象组成的列表(或数组)。例如,精炼操作需要输入文件列表来进行精炼,执行单页输出操作需要页面列表。许多事件属性也是列表。例如,页面审核已更改事件提供审核状态已更改的页面的列表。
在代码中使用这些数组比使用简单赋值复杂得多。

Anchor
Bookmark172_concept_EB754A418D5B4F77A029
Bookmark172_concept_EB754A418D5B4F77A029
简单数组赋值
要将事件属性数组的所有成员传递给操作参数数组时,代码看上去与简单赋值相同:
'This takes ALL the input files from the event and gives them to the action
action.InputFiles = triggerEvent.InputFiles
使用 ArrayList
ArrayList 非常有用,因为它们无类型且大小可变。向其中添加内容时,它们会增大,并且您可以向其中放入任何内容。
'Create an ArrayList and add items to it
Dim oArray As System.Collections.ArrayList = New System.Collections.ArrayList
oArray.AddRange(System.IO.Directory.GetFiles("c:\", "*.pdf"))
oArray.Add(someOtherObject)
将 ArrayList 转换为其他数组
在准备 ArrayList 之后,可能需要将它转换为要在规则内使用的其他数组 - 有类型且大小不变的数组。
ArrayList 具有 ToArray 方法,该方法将 ArrayList 的元素复制到给定类型的数组中。
' Converts the ArrayList into an Array of Automation Pages
Dim oAlist As System.Collections.ArrayList ' . . . fill with contents
action.Pages = oAList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))
仅当 ArrayList 的内容可以通过强制类型转换来转换为指定类型时,ToArray 方法才起作用。如果无法转换,则会发生运行时错误。您必须手动将 ArrayList 中的每一项转换为数组。例如,无法将 String 通过强制类型转换转换为 FileSystemItem,但可以使用 CreateFrom 工厂方法来基于 String 创建 FileSystemItem。
' Converts the ArrayList into an Array of Automation FileSystemItems.
Dim oFSIArray() As Creo.PWS.Automation.PrinergyDataModel.FileSystemItem = _
New Creo.PWS.Automation.PrinergyDataModel.FileSystemItem(oAList.count - 1) {}
For i As Integer = 0 To oAList.Count - 1
oFSIArray(info) = _
Creo.PWS.Automation.PrinergyDataModel.FileSystemItem.CreateFrom(oAList(info).ToString)
Next i
合并嵌套数组
有些时候,要为操作参数指定的数据分散在事件属性中某数组的多个成员中。例如,精炼操作的结果可从输入文件精炼成功事件获取。查看该事件时,可以看到它具有以下属性:

成功精炼的输入文件

已精炼成功的输入文件列表

处理

精炼处理

事件时间

事件的处理时间

根事件

序列中的第一事件

先前事件

序列中的前一个事件

页面位于何处?每个已精炼输入文件都具有自己的基于输入文件创建的页面列表。也就是说,InputFiles 数组的每个成员都包含一个页面数组。
要将所有已精炼页面的列表传递给操作(例如执行单页输出),需要一种方式来遍历每个输入文件,并构造所有页面的集合。
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'We reach into the ith Input File and add its Pages array to our list
newList.AddRange(triggerEvent.InputFiles(info).Pages)
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))
过滤数组
另一种常见需求是过滤列表中不感兴趣部分的能力。例如,您可能希望使用一种简单方法来创建仅由作业中的每个帖的正面组成的拼版打样。您希望向拼版打样操作传递过滤掉所有背面的印面列表。
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.Surfaces.Length)
'We look at the ith Surface and add it to our list if it is "Front"
If triggerEvent.Surfaces(info).Side = "Front" Then
newList.AddRange(triggerEvent.Surfaces(info))
End If
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Surfaces and assign it to the
'Surfaces parameter of the action
action.Surfaces =
newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Surface))
过滤和合并数组
结合过滤和合并两种模式可以实现最大的功能。在此示例中,我们希望得到尺寸大于 8.5 x 11 的所有已精炼页面的列表。因为需要检查每个页面来确定其尺寸,所以这需要引入第二个循环。外部循环遍历所有输入文件,而内部(嵌套)循环遍历每个输入文件的所有已精炼页面。
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'Create a second counter and make a second loop to go through all
' the pages for input file i
Dim j As Integer = 0
Do While (j < triggerEvent.InputFiles(info).Pages.Length)
'Grab the jth Page from the ith Input File
Dim thePage As Page = triggerEvent.InputFiles(info).Pages(j)
'See if the page is larger than 8.5 x 11 (in points) – if so add it to our list
If (thePage.TrimSize.x > 8.5*72 AND thePage.TrimSize.y > 11*72) Then
newList.add(thePage
End If
'Increment the value of j
j = (j + 1)
Loop
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))

Sv translation
languagees

Es posible editar el código de los parámetros de acciones que impliquen matrices de objetos.
Muchos parámetros de acción en Prinergy requieren listas (o matrices) de objetos. Por ejemplo, la acción Afinar necesita una lista de archivos de entrada para afinarlos y la acción Efectuar salida de página suelta requiere una lista de páginas. Muchas propiedades de eventos son también listas. Por ejemplo, el evento Aprobación de página cambiada proporciona una lista de páginas cuyo estado de aprobación ha cambiado.
Trabajar con estas matrices en código es considerablemente más complejo que trabajar con asignaciones sencillas.

Anchor
Bookmark172_concept_EB754A418D5B4F77A029
Bookmark172_concept_EB754A418D5B4F77A029
Asignación de matrices sencillas
Si desea pasar todos los miembros de una matriz de propiedades de eventos a una matriz de parámetros de acción, el código tiene el mismo aspecto que una asignación sencilla:
'This takes ALL the input files from the event and gives them to the action
action.InputFiles = triggerEvent.InputFiles
Uso de listas de matrices (ArrayLists)
Las listas de matrices (ArrayLists) son útiles porque no tienen asignado ningún tipo ni ningún tamaño. Su tamaño aumenta a medida que se le agregan elementos y se puede colocar cualquier cosa en ellas.
'Create an ArrayList and add items to it
Dim oArray As System.Collections.ArrayList = New System.Collections.ArrayList
oArray.AddRange(System.IO.Directory.GetFiles("c:\", "*.pdf"))
oArray.Add(someOtherObject)
Conversión de listas de matrices (ArrayLists) en otras matrices
Después de preparar la lista de matrices (ArrayList), es probable que necesite convertirla en otras matrices que se puedan usar en las reglas: matrices con un tipo y un tamaño especificados.
Las listas de matrices (ArrayList) tienen un método "a matriz" (ToArray) que permite copiar los elementos de las listas en una matriz del tipo ArrayList.
' Converts the ArrayList into an Array of Automation Pages
Dim oAlist As System.Collections.ArrayList ' . . . fill with contents
action.Pages = oAList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))
El método ToArray sólo funciona si el contenido de ArrayList se puede asignar al tipo especificado. En caso contrario, se mostrará un error de tiempo de ejecución. Es necesario convertir manualmente cada elemento incluido en ArrayList a la matriz. Por ejemplo, no se puede asignar un elemento String a un FileSystemItem, pero se puede usar el método de fábrica CreateFrom para crear un FileSystemItem a partir de un elemento String.
' Converts the ArrayList into an Array of Automation FileSystemItems.
Dim oFSIArray() As Creo.PWS.Automation.PrinergyDataModel.FileSystemItem = _
New Creo.PWS.Automation.PrinergyDataModel.FileSystemItem(oAList.count - 1) {}
For i As Integer = 0 To oAList.Count - 1
oFSIArray(info) = _
Creo.PWS.Automation.PrinergyDataModel.FileSystemItem.CreateFrom(oAList(info).ToString)
Next i
Desanidamiento de matrices
En ocasiones, los datos que se deben asignar a un parámetro de acción están dispersos por los miembros de una matriz en las propiedades de evento. Por ejemplo, los resultados de una acción Afinar están disponibles a partir de un evento Afinado de archivos de entrada correcto. Cuando se consulta el evento, se aprecia que incluye las siguientes propiedades:

Archivos de entrada afinados correctamente

Lista de archivos de entrada que se han afinado correctamente

Proceso

Proceso de afinado

Hora del evento

La hora a la que se ha procesado el evento.

Evento raíz

Primer evento de la secuencia

Evento anterior

Evento anterior en la secuencia

¿Dónde están las páginas? Cada uno de los archivos de entrada afinados tiene su propia lista de páginas creadas a partir de ellos. Es decir, cada miembro de la matriz InputFiles incluye una matriz de páginas.
Para pasar una lista con todas las páginas afinadas a una acción como Efectuar salida de página suelta, se necesita una forma de acceder a cada archivo de entrada y crear una colección con todas las páginas.
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'We reach into the ith Input File and add its Pages array to our list
newList.AddRange(triggerEvent.InputFiles(info).Pages)
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))
Filtrado de una matriz
Otro requisito frecuente es la necesidad de filtrar partes de una lista que carecen de interés. Por ejemplo, puede que desee utilizar una forma sencilla de crear pruebas de imposición sólo de los anversos de los pliegos de un trabajo. Desea pasar a la acción Prueba de imposición una lista de superficies que excluya todas las superficies de los reversos.
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.Surfaces.Length)
'We look at the ith Surface and add it to our list if it is "Front"
If triggerEvent.Surfaces(info).Side = "Front" Then
newList.AddRange(triggerEvent.Surfaces(info))
End If
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Surfaces and assign it to the
'Surfaces parameter of the action
action.Surfaces =
newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Surface))
Filtrado y desanidamiento de matrices
El hecho de combinar los dos patrones para desanidar y filtrar las matrices aporta la mayor capacidad de control. En este ejemplo, queremos obtener una lista con todas las páginas afinadas cuyo tamaño sea superior a 8,5 x 11. Dado que es necesario mirar todas las páginas para determinar su tamaño, resulta necesario introducir un segundo bucle. El bucle externo pasa por todos los archivos de entrada, mientras que el interno (anidado) pasa por todas las páginas afinadas de cada archivo de entrada.
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'Create a second counter and make a second loop to go through all
' the pages for input file i
Dim j As Integer = 0
Do While (j < triggerEvent.InputFiles(info).Pages.Length)
'Grab the jth Page from the ith Input File
Dim thePage As Page = triggerEvent.InputFiles(info).Pages(j)
'See if the page is larger than 8.5 x 11 (in points) – if so add it to our list
If (thePage.TrimSize.x > 8.5*72 AND thePage.TrimSize.y > 11*72) Then
newList.add(thePage
End If
'Increment the value of j
j = (j + 1)
Loop
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))

Sv translation
languagefr

Vous pouvez modifier le code des paramètres d'action qui impliquent des matrices d'objets.
De nombreux paramètres d'action dans Prinergy requièrent des listes (ou matrices) d'objets. Par exemple, l'action Raffiner nécessite une liste de fichiers d'entrée à raffiner et l'action Réaliser une sortie de pages non-imposées requiert une liste de pages. De nombreuses propriétés d'événement sont également des listes. Par exemple, l'événement Approbation de la page modifiée fournit une liste des pages dans lesquelles l'état d'approbation a changé.
Travailler avec ces matrices codées est bien plus complexe que de travailler avec de simples affectations.

Anchor
Bookmark172_concept_EB754A418D5B4F77A029
Bookmark172_concept_EB754A418D5B4F77A029
Simple attribution de matrices
Lorsque vous souhaitez transférer tous les membres d'une matrice de propriété d'événement vers une matrice de paramètre d'action, le code est semblable à celui d'une simple attribution :
'This takes ALL the input files from the event and gives them to the action
action.InputFiles = triggerEvent.InputFiles
Utilisation des ArrayLists
Les ArrayLists sont utiles car elles ne sont pas saisies ni dimensionnées. Elles s'allongent au fur et à mesure que vous les complétez et vous pouvez y ajouter ce que vous voulez.
'Create an ArrayList and add items to it
Dim oArray As System.Collections.ArrayList = New System.Collections.ArrayList
oArray.AddRange(System.IO.Directory.GetFiles("c:\", "*.pdf"))
oArray.Add(someOtherObject)
Conversion des ArrayLists en d'autres matrices
Après avoir préparé ArrayList, vous devrez probablement la convertir en d'autres matrices à utiliser dans les règles ; il s'agit de matrices saisies et dimensionnées.
L'ArrayList dispose d'une méthode ToArray qui copiera les éléments de l'ArrayList sur une matrice d'un type donné.
' Converts the ArrayList into an Array of Automation Pages
Dim oAlist As System.Collections.ArrayList ' . . . fill with contents
action.Pages = oAList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))
La méthode ToArray fonctionne seulement si le contenu de l'ArrayList peut être converti au type spécifié. Dans le cas contraire, une erreur d'exécution apparaît. Vous devez convertir manuellement chaque élément de l'ArrayList en matrice. Par exemple, vous ne pouvez pas convertir un String en FileSystemItem, mais vous pouvez utiliser la méthode d'usine CreateFrom pour créer un FileSystemItem à partir d'un String.
' Converts the ArrayList into an Array of Automation FileSystemItems.
Dim oFSIArray() As Creo.PWS.Automation.PrinergyDataModel.FileSystemItem = _
New Creo.PWS.Automation.PrinergyDataModel.FileSystemItem(oAList.count - 1) {}
For i As Integer = 0 To oAList.Count - 1
oFSIArray(info) = _
Creo.PWS.Automation.PrinergyDataModel.FileSystemItem.CreateFrom(oAList(info).ToString)
Next i
Aplatissement des matrices imbriquées
Les données à affecter à un paramètre d'action sont parfois réparties sur les membres d'une matrice dans les propriétés de l'événement. Par exemple, les résultats d'une action Raffiner sont disponibles à partir d'un événement Raffiner fichiers d'entrée OK. Quand vous examinez cet événement, vous voyez qu'il possède les propriétés suivantes :

Fichiers d'entrée raffinés avec succès

La liste des fichiers d'entrée correctement raffinés.

Processus

Processus de raffinage

Heure de l'événement

Heure du processus de l'évènement

Événement primordial

Premier événement dans la séquence

Événement précédent

Événement précédent dans la séquence

Où sont les pages ? Chacun des fichiers d'entrée raffinés dispose de sa propre liste de pages créées à partir de celle-ci. En d'autres termes, chaque membre de la matrice InputFiles contient une matrice de pages.
Pour faire passer une liste de toutes les pages raffinées à une action comme Réaliser une sortie de pages non-imposées, il nous faut un moyen pour pénétrer dans chaque fichier d'entrée et générer un ensemble de toutes les pages.
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'We reach into the ith Input File and add its Pages array to our list
newList.AddRange(triggerEvent.InputFiles(info).Pages)
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))
Filtrage d'une matrice
Une autre exigence courante est la possibilité de filtrer des parties d'une liste qui ne vous intéressent pas. Il se pourrait, par exemple, que vous vouliez un moyen simple pour créer des épreuves d'imposition des surfaces recto uniquement de chaque cahier de votre travail. Vous souhaitez transmettre à l'action Épreuve imposée une liste des surfaces dont les surfaces verso sont toutes éliminées par filtrage.
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.Surfaces.Length)
'We look at the ith Surface and add it to our list if it is "Front"
If triggerEvent.Surfaces(info).Side = "Front" Then
newList.AddRange(triggerEvent.Surfaces(info))
End If
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Surfaces and assign it to the
'Surfaces parameter of the action
action.Surfaces =
newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Surface))
Filtrage et aplatissement des matrices
La combinaison des deux motifs d'aplatissement et de filtrage vous donne le maximum de puissance. Dans cet exemple, nous voulons une liste de toutes les pages raffinées dont le format est supérieur à 21 x 28 cm. Comme nous devons examiner chaque page afin de déterminer sa taille, il nous faut introduire une seconde boucle. La boucle externe passe en revue tous les fichiers d'entrée, tandis que la boucle (imbriquée) interne passe en revue toutes les pages raffinées pour chaque fichier d'entrée.
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'Create a second counter and make a second loop to go through all
' the pages for input file i
Dim j As Integer = 0
Do While (j < triggerEvent.InputFiles(info).Pages.Length)
'Grab the jth Page from the ith Input File
Dim thePage As Page = triggerEvent.InputFiles(info).Pages(j)
'See if the page is larger than 8.5 x 11 (in points) – if so add it to our list
If (thePage.TrimSize.x > 8.5*72 AND thePage.TrimSize.y > 11*72) Then
newList.add(thePage
End If
'Increment the value of j
j = (j + 1)
Loop
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))

Sv translation
languageja

オブジェクトの配列を含むアクション パラメータのコードを編集できます。
Prinergy の多数のアクション パラメータでは、オブジェクトのリスト(配列)が必要になります。たとえば、リファインアクションではリファインする入力ファイルのリストが必要となり、単ページ出力の実行アクションではページのリストが必要です。また、イベント プロパティの多くもリストで表されます。たとえば、ページの承認 – 変更済みイベントでは、承認ステータスが変更されたページのリストが提供されます。
コード内でこのような配列を処理する場合、単純な割り当て処理に比べるとかなり複雑なコーディングになります。

Anchor
Bookmark172_concept_EB754A418D5B4F77A029
Bookmark172_concept_EB754A418D5B4F77A029
単純な配列の割り当て
イベント プロパティの配列のすべてのエレメントをアクション パラメータの配列に渡す場合、コードは次のように単純な割り当て処理と同様になります。
'This takes ALL the input files from the event and gives them to the action
action.InputFiles = triggerEvent.InputFiles
ArrayList の使用
ArrayList は、型とサイズを指定しないので便利です。エレメントを追加するたびに拡張され、任意のエレメントを格納できます。
'Create an ArrayList and add items to it
Dim oArray As System.Collections.ArrayList = New System.Collections.ArrayList
oArray.AddRange(System.IO.Directory.GetFiles("c:\", "*.pdf"))
oArray.Add(someOtherObject)
ArrayList を別の配列に変換
ArrayList の準備が完了したら、ルール内で使用できるように、型とサイズを指定する別の配列に変換する必要がある場合があります。
ArrayList には、ArrayList のエレメントを指定した型の配列にコピーする ToArray メソッドがあります。
' Converts the ArrayList into an Array of Automation Pages
Dim oAlist As System.Collections.ArrayList ' . . . fill with contents
action.Pages = oAList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))
ToArray メソッドは、ArrayList のエレメントが指定する型にキャストできる場合にのみ機能します。キャストできない場合は、実行時エラーが表示され、ArrayList 内の各エレメントを指定の配列に手動で変換する必要があります。たとえば、String 型を FileSystemItem にキャストできない場合は、CreateFrom ファクトリ メソッドを使用して String 型から FileSystemItem を作成することができます。
' Converts the ArrayList into an Array of Automation FileSystemItems.
Dim oFSIArray() As Creo.PWS.Automation.PrinergyDataModel.FileSystemItem = _
New Creo.PWS.Automation.PrinergyDataModel.FileSystemItem(oAList.count - 1) {}
For i As Integer = 0 To oAList.Count - 1
oFSIArray(info) = _
Creo.PWS.Automation.PrinergyDataModel.FileSystemItem.CreateFrom(oAList(info).ToString)
Next i
ネストした配列のフラット化
アクション パラメータに割り当てるデータが、イベント プロパティの配列内で分散している場合があります。たとえば、入力ファイルのリファイン - OKイベントからリファインアクションの結果を使用できるとします。このイベントには、以下のプロパティがあります。

入力ファイル - リファイン済み

正常にリファインされた入力ファイルのリスト

プロセス

リファイン プロセス

イベント タイム

イベントが処理された時間

ルート イベント

最初のイベント

前のイベント

直前のイベント

ページの場所については、リファイン済みの各入力ファイルに固有のリストがあり、作成されたページはそこに含まれています。つまり、InputFiles の配列の各エレメントにはページの配列が含まれています。
すべてのリファイン済みページのリストを単ページ出力の実行などのアクションに渡すには、各入力ファイルを調べてすべてのページの集合を作成する必要があります。
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'We reach into the ith Input File and add its Pages array to our list
newList.AddRange(triggerEvent.InputFiles(info).Pages)
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))
配列のフィルタリング
一般的に、リスト内の不要な部分をフィルタリングする機能が必要な場合があります。たとえば、ジョブ内のすべての折丁の表面のみの面付けプルーフを作成するための簡単な方法が必要であるとします。この場合、面付けプルーフアクションに、すべての裏面が除外された面のリストを渡す必要があります。
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.Surfaces.Length)
'We look at the ith Surface and add it to our list if it is "Front"
If triggerEvent.Surfaces(info).Side = "Front" Then
newList.AddRange(triggerEvent.Surfaces(info))
End If
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Surfaces and assign it to the
'Surfaces parameter of the action
action.Surfaces =
newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Surface))
配列のフィルタリングおよびフラット化
フラット化とフィルタリングの 2 つのパターンを組み合わせることにより、機能が最大限強化されます。次の例では、8.5 x 11 よりも大きいすべてのリファイン済みページのリストを作成します。サイズを確認するために各ページを調べる必要があるので、2 つめのループを挿入する必要があります。外側のループではすべての入力ファイルを調べ、内側の(ネストした)ループでは各入力ファイルのすべてのリファイン済みページを調べます。
'First we need to create a holder for the new list we will be building
Dim newList As System.Collections.ArrayList = New System.Collections.ArrayList
'Now we create a counter variable and initialize to the value 0
Dim i As Integer = 0
'Next we create a loop that will go through all the input files (until
'the counter i reaches the end of the list)
Do While (i < triggerEvent.InputFiles.Length)
'Create a second counter and make a second loop to go through all
' the pages for input file i
Dim j As Integer = 0
Do While (j < triggerEvent.InputFiles(info).Pages.Length)
'Grab the jth Page from the ith Input File
Dim thePage As Page = triggerEvent.InputFiles(info).Pages(j)
'See if the page is larger than 8.5 x 11 (in points) – if so add it to our list
If (thePage.TrimSize.x > 8.5*72 AND thePage.TrimSize.y > 11*72) Then
newList.add(thePage
End If
'Increment the value of j
j = (j + 1)
Loop
'Increment the value of i
i = (i + 1)
Loop
'Finally, we convert our list into an Array of Pages and assign it to the
'Pages parameter of the action
action.Pages = newList.ToArray(GetType(Creo.PWS.Automation.PrinergyDataModel.Page))