Creating Activity-to-Product/Weld/Resource Relationships

Using Interface Description Language (IDL), the PPR Document is available for Automation clients to access the Process Document. Using this functionality, clients can:
 
  • Add a process library to use.
  • Insert products and resources in their respective contexts.
  • Retrieve the handle of a specific product or resource in the tree. (This is used to assign to an activity.)
  • Retrieve the list of processes, products and resources in the process document.

This feature helps users build the process document from external applications (such as Microsoft Excel), as well as from running VBScript macros from the Tools>Macro command.
 

Language="VBSCRIPT"
Sub CATMain()
'Create a New PPRDocument and Set it as an ActiveDocument
Dim processDoc As PPRDocument
Set processDoc = CATIA.Documents.Add("Process")
Set processDoc = CATIA.ActiveDocument

'Adding a Process Library to Use
processDoc.addProcessLibraryToUse  "d:/myProcess.act"

'Inserting Products and Resources in their Respective Contexts
processDoc.addProduct   "d:/Product1.CATProduct" 
processDoc.addProduct   "d:/Product2.CATProduct" 

processDoc.addResource  "d:/Resource1.CATProduct"
processDoc.addResource  "d:/Resource2.CATProduct" 

'Get the Handle to the Root Process
Dim Process as Activity
Set Process = ProcessDoc.Processes.Item( 1 )
 
 'Create an Activitiy of Type Load1
Dim LoadActivity as Activity
set LoadActivity = Process.CreateChild("Load1")
LoadActivity.Name = "LoadActivity"

'Create an Activitiy of Type Load33
Dim WeldActivity as Activity
set WeldActivity = Process.CreateChild("Load33")
WeldActivity.Name = "WeldActivity"

'Get the Handle to Product in the ProductList  as an Item
Dim Product1 As CATIAProduct
Set Product1 = processDoc.Products.Item(1)

'Get the Handle to a Resource in the ResourceList 
Dim Resource1 As CATIAProduct
Set Resource1 = processDoc.Resources.Item( 1 )

'Get the Handle to Manage the Collection of Items on the Activity and 
'assign the item handle to this collection
Dim itms as items
Set itms = LoadActivity.items
itms.AssignItem( Product1 )

'Get the Handle to Manage the Collection of Resources on the Activity 
'and assign the Resource handle to this collection
Dim resrcs as Resources
Set rsrcs = LoadActivity.Resources
rsrcs.AssignResource( Resource1 )

'Create the Link between Load and Weld Activities and Save the Document. 
LoadActivity.CreateLink(WeldActivity)
processDoc.SaveAs "d:\CreatedFromVBScript.CATProcess"
End Sub