 |
Using Interface Description
Language (IDL), .CATProcesses are available for Automation interfaces to access Manufacturing
Assembly.
The automation interfaces to the Manufacturing Assembly are the following: |
|
- Manufacturing Assembly:
- The Name of the Manufacturing Assembly: MAName (get and put)
- The Part Number of the MA: MAPartNumber (get and put)
- Manufacturing Assembly or Manufacturing Kit: MAType (only get)
- The number of assigned items: Count
- Item (only get); One assigned Part (Product and/or Resource or another
Manufacturing Assembly) of the Manufacturing Assembly
(to be fetched via index):
- AddPart: Adds a part (Product, Resource or another
Manufacturing Assembly) to a Manufacturing
Assembly (Resources can be added only to Manufacturing Kits):
- Remove Part: Removes an allocated Part from the Manufacturing Assembly
- Manufacturing Assembly type
- An Enumeration defining a Manufacturing Assembly or a Manufacturing
Kit
|
|
Subsequent some excerpts of Visual Basic how to access the Manufacturing
Assemblies:
|
|
- Fetch an assigned Manufacturing Assembly from an Activity
Dim myActivity As Activity
myActivity = <get Activity>
Dim myItem As Item
Set myItem = myActivity.Items.Item(1)
Dim obj As MfgAssembly
Set obj = mySel.FindObject("DNBIAMfgAssembly")
- Fetch the Name of the Manufacturing Assembly
Dim myName As String
myName = obj.MAName
- Change the Name of the Manufacturing Assembly
Dim newName As String
newName = "NewMAName"
obj.MAName = newName
- Fetch the PartNumber of the Manufacturing Assembly
Dim myPart As String
myPart = obj.MAPartNumber
- Change the PartNumber of the MA
Dim newPartNumber As String
newPartNumber = "NewPartNumber"
obj.MAPartNumber = newPartNumber
- Fetch the type of the Manufacturing Assembly
Dim MAtype As String
If MA.MAType = manufacturingAssembly Then
MAtype = "Manufacturing Assembly"
Else
MAtype = "Manufacturing Kit"
End If
- Fetch the number of assigned parts of the Manufacturing Assembly
Dim Number As Long
Number = MA.Count
Fetch the assigned parts of the MA
Dim j As Long
For j = 1 To MA.Count
Dim it As Item
Set it = MA.Item(j)
Dim ItemName As String
ItemName = it.Name
Next
- Add a new Part to a Manufacturing Assembly
Dim myProducts As PPRProducts
Set myProducts = DELMIA.ActiveDocument.PPRDocument.Products
Dim Part As Item
Set Part = myProducts.Item(2)
MA.AddPart(Part)
- Remove a new Part from a Manufacturing Assembly
Dim myProducts As PPRProducts
Set myProducts = DELMIA.ActiveDocument.PPRDocument.Products
Dim Part As Item
Set Part = myProducts.Item(2)
MA.RemovePart(Part)
|
 |
Script Example
|
|
Example 1:
|
|
This script is an example how to use all Manufacturing Assembly Automation
Interfaces |
|
Prerequisite
Create following PPR items
- One Activity
- Two Products
- Two Resources
- One Manufacturing Assembly, assign one of the products, assign the
Manufacturing Assembly to the Activity with "Process Processes Product"
- One Manufacturing Kit, assign one of the products and one of the
Resources, assign the Manufacturing Kit to the Activity with "Process
Processes Product"
Create a CATScript: |
|
1. |
Select the Tools > Macro > Macros
and create a new CATScript
 |
|
|
|
|
2. |
Execute following script (Tools > Macro > Macros..>select
the new created CATScript>
Run) |
|
|
|
Option Explicit
Language = "VBSCRIPT"
Sub CATMain()
MsgBox "Select an activity"
Dim sFilter(0)
sFilter(0) = "Activity"
Dim This_Sel As Selection
Set This_Sel = DELMIA.ActiveDocument.Selection
Dim sStatus As String
sStatus = This_Sel.SelectElement2(sFilter, "Select an activity", True)
Dim Act As Activity
Set Act = This_Sel.Item(1).Value
display_items Act
change_items Act
display_items Act
End Sub
Sub display_items(myActivity As Activity)
Dim i As Long
Dim mymessg As String
mymessg = mymessg & "List of Manufacturing Assemblies" & vbCrLf & vbCrLf
For i = 1 To myActivity.Items.Count
Dim myItem As Item
Set myItem = myActivity.Items.Item(i)
Dim mySel As Selection
Set mySel = DELMIA.ActiveDocument.Selection
mySel.Add myItem
On Error Resume Next
' Filter out Products
Dim prod As Product
Set prod = mySel.FindObject("CATIAProduct")
If Err.Number <> 0 Then
On Error GoTo 0
Dim MA As MfgAssembly
Set MA = mySel.FindObject("DNBIAMfgAssembly")
Dim MAName As String
MAName = MA.MAName
Dim MAPartNbr As String
MAPartNbr = MA.MAPartNumber
Dim MAtype As String
If MA.MAtype = manufacturingAssembly Then
MAtype = "Manufacturing Assembly"
Else
MAtype = "Manufacturing Kit"
End If
Dim Number As Long
Number = MA.Count
mymessg = mymessg & MAName & vbCrLf
mymessg = mymessg & " Part Number: " & MAPartNbr & vbCrLf
mymessg = mymessg & " Type: " & MAtype & vbCrLf
mymessg = mymessg & " Number of Parts: " & Number & vbCrLf
Dim j As Long
For j = 1 To Number
Dim it As Item
Set it = MA.Item(j)
mymessg = mymessg & " Item: " & it.Name & vbCrLf
Next
mymessg = mymessg & vbCrLf
End If
Next
MsgBox (mymessg)
End Sub
Sub change_items(myActivity As Activity)
Dim i As Long
For i = 1 To myActivity.Items.Count
Dim myItem As Item
Set myItem = myActivity.Items.Item(i)
Dim mySel As Selection
Set mySel = DELMIA.ActiveDocument.Selection
mySel.Add myItem
On Error Resume Next
' Filter out Products
Dim prod As Product
Set prod = mySel.FindObject("CATIAProduct")
If Err.Number <> 0 Then
On Error GoTo 0
Dim MA As MfgAssembly
Set MA = mySel.FindObject("DNBIAMfgAssembly")
Dim myProducts As PPRProducts
Dim myRes As PPRResources
Dim Part As Item
If MA.MAtype = manufacturingAssembly Then
MA.MAName = "NewMA2"
MA.MAPartNumber = "NewMA2Part"
Set myProducts = DELMIA.ActiveDocument.PPRDocument.Products
Set Part = myProducts.Item(1)
MA.RemovePart (Part)
Set Part = myProducts.Item(2)
MA.AddPart (Part)
Else
MA.MAName = "NewMK2"
MA.MAPartNumber = "NewMK2Part"
Set myProducts = DELMIA.ActiveDocument.PPRDocument.Products
Set Part = myProducts.Item(2)
MA.RemovePart (Part)
Set Part = myProducts.Item(1)
MA.AddPart (Part)
Set myRes = DELMIA.ActiveDocument.PPRDocument.Resources
Set Part = myRes.Item(2)
MA.RemovePart (Part)
Set Part = myRes.Item(1)
MA.AddPart (Part)
End If
End If
Next
End Sub
|
|
First a list of the items will be shown before the changes.

Then the changes are applied and a list box is shown.
 |
|
Example 2:
|
|
All assigned Products of an Activity are fetched, independently if they are
direct assigned, or as assigned parts of a Manufacturing Assembly |
|
Prerequisite
|
|
Create following PPR items
- One Activity
- Four Products, assign the fourth Product direct to the Activity
- Three Manufacturing Assemblies, assign the two of the products to the
first MA, assign the third product to the third MA, assign the second MA
to the first MA, assign the third MA to the second MA, assign the first
MA to the Activity with "Process Processes Product"
|
|
Execute following script (Tools > Macro > Macros..>select the
new created CATScript> Run) |
|
Option Explicit
Language = "VBSCRIPT"
Sub CATMain()
MsgBox "Select an activity"
Dim sFilter(0)
sFilter(0) = "Activity"
Dim This_Sel As Selection
Set This_Sel = DELMIA.ActiveDocument.Selection
Dim sStatus As String
sStatus = This_Sel.SelectElement2(sFilter,
"Select an activity", True)
Dim Act As Activity
Set Act = This_Sel.Item(1).Value
display_Act Act
End Sub
Sub display_Act(myActivity As Activity)
Dim i As Long
Dim mymessg As String
mymessg = mymessg & "List of Products of an
Activity" & vbCrLf
For i = 1 To myActivity.Items.Count
Dim myItem As Item
Set myItem = myActivity.Items.Item(i)
display_Item myItem, mymessg
Next
MsgBox (mymessg)
End Sub
Sub display_Item(myItem As Item, mymessg As String)
Dim mySel As Selection
Set mySel = DELMIA.ActiveDocument.Selection
mySel.Add myItem
On Error Resume Next
' Filter out Products
Dim prod As Product
Set prod = mySel.FindObject("CATIAProduct")
If Err.Number = 0 Then
mymessg = mymessg & prod.Name & vbCrLf
Else
On Error GoTo 0
Dim MA As MfgAssembly
Set MA =
mySel.FindObject("DNBIAMfgAssembly")
Dim Number As Long
Number = MA.Count
Dim j As Long
For j = 1 To Number
Dim it As Item
Set it = MA.Item(j)
display_Item it, mymessg
Next
End If
End Sub
|

|
Notes
|
|
- Manufacturing Assemblies cannot be created or deleted; also it is not
possible to get a list of all Manufacturing Assemblies in the document.
|