|
|
A CATScript file named DocumentNewGeneratorHTML.CATScript is located in
the code/command directory of the DELMIA installation. This script can be executed using the command
"Generate Documentation" in the DPM Tools toolbar in the DPM Planner Workbench. An analysis of this script is provided below for educational purposes. The interfaces that are used and their purpose are described. In the following script, interfaces of interest are highlighted in bold green text, and additional
descriptive remarks (which are not part of the program) are highlighted in
red text with a gray background. |
'******************************************************************** '******************************************************************** '**** VBSCRIPT MACRO FOR THE GENERATION OF HTML DOCUMENTATION **** '**** Steve Morissette 11/01/99 **** '******************************************************************** '******************************************************************** ' 11/01/99 : Modified to make URL references to attributes named URL The lines above represent a series of comment lines. All comment
lines must begin with the single-quote (') character.
Language="VBSCRIPT" This is mandatory.
Dim OutRef, OutPath, OutIndex This declares global variables to be
used later.
Sub CATMain() This is the script that is going to be called by the documentation function. CATDocument "Process", "Test", "c:\temp\" The Subroutine CATDocument will be called with these default values if no other values are given. End Sub '-------------------------------------------------------------------- ' Main Procedure This procedure will set up starting variables for this particular documentation method (this is related to the way the documentation method is called, and is not pertinent in knowing how to use Process Data interfaces). '-------------------------------------------------------------------- Sub CATDocument( RootActivityName, HtmlFilesName, HtmlFilesPath) CATIA.SystemService.Print "RootActivityName : " & RootActivityName CATIA.SystemService.Print "HtmlFilesName : " & HtmlFilesName CATIA.SystemService.Print "HtmlFilesPath : " & HtmlFilesPath Dim RootActivity Dim RootActName RootActName = RootActivityName OutPath = HtmlFilesPath OutRef = HtmlFilesName OutIndex = OutRef & "_index.html" Set RootActivity = Catia.ActiveDocument.GetItem(RootActName) CATIA will find the object called RootActName in the current ActiveDocument and set RootActivity at this value. CreateIndex RootActivity, OutPath, OutRef, OutIndex Calling the CreateIndex method. End Sub '--------------------------------------------------------------- ' Create the index file '---------------------------------------------------------------' Sub CreateIndex(RootActivity, OutPath, OutRef, OutIndex) Dim indexfs Dim indexf Set indexfs = CreateObject("Scripting.FileSystemObject")
Set indexf = Indexfs.OpenTextFile(OutPath & OutIndex, 2, True)
This created an output file for the data to be written, and
opened the file to receive the data All the data will be
written using the indexf.WriteLine statement.
The few next statements are related to the html header, since in
this example, we are trying to create a set of html pages.
'Write index file header
indexf.WriteLine "<!doctype html public ""-//w3c//dtd html 4.0 transitional//en"">"
indexf.WriteLine "<html>"
indexf.WriteLine "<head>"
indexf.WriteLine " <meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">"
indexf.WriteLine " <meta name=""GENERATOR"" content=""IPD v2"">"
indexf.WriteLine " <meta name=""Author"" content=""IPD v2"">"
indexf.WriteLine " <title>Activities Index for Process : " & RootActivity.Name & "</title>"
RootActivity is an object of type Activity, for which the Name attribute will return a label.
indexf.WriteLine "</head>" indexf.WriteLine "<body background=""back.gif"" bgcolor=#EEEEFF>" indexf.WriteLine "<CENTER>" indexf.WriteLine "<P><h2>Activities Index for Process : <I>" & RootActivity.Name & "</I></h2>" indexf.WriteLine "<I>Generation Date : " & Date & " at " & Time & "</I></P>" indexf.WriteLine "</CENTER>" indexf.WriteLine "<P><TABLE BORDER COLS=1 WIDTH=""100%"" >" indexf.WriteLine "<TR ALIGN=CENTER BGCOLOR=#CCCCCC><TD><B>Activities Hierarchy</B></TD></TR></TABLE>" indexf.WriteLine "<TABLE BORDER COLS=5 WIDTH=""100%"" >" indexf.WriteLine "<TR ALIGN=CENTER BGCOLOR=#EEEEEE>" indexf.WriteLine "<TD WIDTH=""30%""><B>Name</B></TD>" indexf.WriteLine "<TD WIDTH=""40%""><B>Description</B></TD>" indexf.WriteLine "<TD WIDTH=""10%""><B>Cycle Time</B></TD>" indexf.WriteLine "<TD WIDTH=""10%""><B>Begin Date</B></TD>" indexf.WriteLine "<TD WIDTH=""10%""><B>End Date</B></TD>" indexf.WriteLine "</TR>" 'Write reference WriteIndexRef RootActivity, indexf, OutPath, OutRef, 0 indexf.WriteLine "</TD></TR></TABLE></P>" The main page of the documentation has now been written and another subroutine,
WriteIndexRef, is now being called to extract all the details of the operations.
End Sub '--------------------------------------------------------------- ' Write the index reference for an activity '--------------------------------------------------------------- Function WriteIndexRef(Activity, File, OutPath, OutRef, Level) Dim childs Dim child Dim quantity Dim I If (Activity.IsSubTypeOf("PhysicalActivity")) Then
This method of the Activity Object allows to test for the type of
an Activity object.
'Write reference for the activity itself
File.WriteLine "<TR VALIGN=TOP BGCOLOR=#FFFFFF><TD><A HREF = " & OutRef & "_"
& Activity.Name & ".html>"
'Indent the name according to the level of the activity
Dim J
For J = 0 To Level
File.Write "--"
Next
File.WriteLine Activity.Name & "</A></TD>"
File.WriteLine "<TD>" & Activity.Description & "</TD>"
File.WriteLine "<TD>" & Activity.CycleTime & "</TD>"
File.WriteLine "<TD>" & Activity.BeginningDate & "</TD>"
File.WriteLine "<TD>" & Activity.EndDate & "</TD></TR>"
All of the above methods are also available using the Activity Object.
They will return the values of the Description, the CycleTime, and the
Beginning and End Dates. Please note that Time and Dates are updated
once the Gantt Chart is opened in DPM.
'Write the activity detail file
WriteActivityFile Activity, OutPath, OutRef
'Write the list
Set childs = Activity.ChildrenActivities
This will get a list of children activities of the selected Activity.
quantity = childs.Count This will give the number of elements in
that returned list.
if quantity <= 0 then
Exit Function
End if
'Recursively write sons
For I=1 To quantity
Set child = childs.Item(I) This will extract all elements
of the child's list. Each extracted element is also an Activity,
and therefore, we can recursively call the method to extract the
Activity data for this son element.
WriteIndexRef child,File,OutPath,OutRef,Level+1
Next
End if
End Function These are other subroutines that may be called with an Activity and an output File. '--------------------------------------------------------------- ' Write an activity item list This will return the list of items attached to an activity (that is the list of items products that an Activity will be working on). '--------------------------------------------------------------- Sub WriteItems(Activity, File) Dim items,item,quantity Set items = Activity.Items quantity = items.Count if quantity <= 0 then File.WriteLine "None" exit sub end if File.WriteLine "<UL>" For I=1 To quantity Set item = items.Item(I) File.WriteLine "<LI>" & item.Name & "</LI>" Each of the items, as any Object, has a name that can be extracted. Next File.WriteLine "</UL>" End Sub '---------------------------------------------------------------
' Write an activity resource list This will return the list
of resources attached to the Activity so that it may be properly
performed.
'---------------------------------------------------------------
Sub WriteResources(Activity, File)
Dim resources,item,quantity
Set resources = Activity.Resources
quantity = resources.Count
if quantity <= 0 then
File.WriteLine "None"
exit sub
end if
File.WriteLine "<UL>"
For I=1 To quantity
Set resource = resources.Item(I)
File.WriteLine "<LI>" & resource.Name & "</LI>"
Next
File.WriteLine "</UL>"
End Sub
'---------------------------------------------------------------
' Write the previous list This method will allow you to extract
the list of previous Activities (in Sequence) for an Activity,
inside an output File
'---------------------------------------------------------------
Sub WritePrevious(Activity, File)
Dim activities
Dim one
Dim quantity
Dim I
Set activities = Activity.PreviousCFActivities
quantity = activities.Count
if quantity <= 0 then
exit sub
end if
File.WriteLine "<UL>"
for I = 1 to quantity
Set one = activities.Item(I)
If (one.IsSubTypeOf("PhysicalActivity")) Then
File.WriteLine "<LI><A HREF = """ & OutRef & "_" & one.Name & ".html" & """>"
& one.Name & "</A></LI>"
End If
next
File.WriteLine "</UL>"
End Sub
'---------------------------------------------------------------
' Write the next list This method will allow you to extract the
list of next Activities (in Sequence) for an Activity, inside
an output File
'---------------------------------------------------------------
Sub WriteNext(Activity, File)
Dim activities
Dim one
Dim quantity
Dim I
Set activities = Activity.NextCFActivities
quantity = activities.Count
if quantity <= 0 then
exit sub
end if
File.WriteLine "<UL>"
for I = 1 to quantity
Set one = activities.Item(I)
If (one.IsSubTypeOf("PhysicalActivity")) Then
File.WriteLine "<LI><A HREF = """ & OutRef & "_" & one.Name & ".html" & """>"
& one.Name & "</A></LI>"
next File.WriteLine "</UL>" End Sub '--------------------------------------------------------------- ' Write an activity file specific data block This method will allow you to extract the list of specific attributes attached to an Activity, inside an output File '--------------------------------------------------------------- Sub WriteSpecific(Activity, File) If (Activity.IsSubTypeOf("PhysicalActivity")) Then This If statement is necessary since only the Physical Activity have the capability to have additional specific user attributes. Nbr=Activity.AttrCount This will give the number of extra attributes on the Activity If (Nbr > 0) Then For I=1 To Nbr name = Activity.AttrName(I) This will give the name of the attribute of rank I in the list of extra attributes. If (name = "URL") Then File.WriteLine "<B>" & name & " : </B>" AttrVal = Activity.AttrValue(I) This will give the value of the attribute of rank I in the list of extra attributes. File.WriteLine "<A HREF=file:/" & AttrVal & ">" & AttrVal & "</A><BR>" Else File.WriteLine "<B>" & name & " : </B>" AttrVal = Activity.AttrValue(I) File.WriteLine AttrVal & "<BR>" End If Next Else File.WriteLine "None" End If End If End Sub |
|
|
|
Notes |
|
![]()