| Building a Console Application in VB for the Alibre Design API - Looping Through Sessions |
|
|
Page 11 of 14 Looping Through SessionsNow let's loop through all the sessions that Alibre Design has loaded into memory. Think of a session (what Alibre Design's API calls "IADSession") as all the things that are in common about an Alibre Design document (part, assembly, etc.). For example, all types of Alibre Design document have a name that's displayed in the Alibre Design's title bar, and they can all be loaded from disk and saved again. In lines 49-50 we create a couple of variables that we can use to count up the total number of sessions and configurations. In line 54 we start looping through all the sessions, and in line 54 we make sure the session is opened up somewhere in an Alibre Design window. If it is opened up in an Alibre Design GUI, then we output the name of the session (Remember that at this point the output might either be going to the screen or to a file. [See lines 34-39.]), increment the session counter by one, and reset the configuration counter back to zero. We need to reset the configuration counter back to zero at this point because we're going to be re-using this variable in the next bit of code to count up the total number of configurations per session. ' Search through all the sessions.
Dim sessionCount As Integer = 0
Dim configCount As Integer = 0
For Each session As IADSession In root.Sessions
' Be sure it's a visible GUI
If session.IsGUIVisible Then
' Write out the name
Call Console.WriteLine("Name: " & session.Name)
sessionCount = sessionCount + 1
configCount = 0
|
|
| Last Updated ( Monday, 28 January 2008 16:22 ) |
