Distributive Systems |
Accessing Logical Line and Group Membership |
|
This use case is intended to show you how to obtain a Logical line instance and access its group members. This macro opens the document CAAPsp3DEduIn.CATProduct. Using the root node of the document, it then finds a Logical line object with a given instance name. It then accesses group members, adds and removes a member. |
|
|
CAAPspLogicalLine is launched in CATIA [1]. No open document is needed. CAAPspLogicalLine.CATScript is located in the CAAScdPspUseCases module. Execute macro (windows only). |
|
|
CAAPspLogicalLine includes the following steps:
PrologThe macro first loads Distributive System document CAAPsp3DEduIn.CATProduct containing Equipment and Piping Design objects. Note: To open a different document, modify the variable sDocPath to point to the document directory and sDocFullPath to point to full path name of the document. ...
' ----------------------------------------------------------------
' Open the Distributive system document
Dim objPspDoc As Document
sDocFullPath = CATIA.FileSystem.ConcatenatePaths(sDocPath, _
"\online\CAAScdPspUseCases\samples\CAAPsp3DEduIn.CATProduct" )
Set objPspDoc = CATIA.Documents.Open(sDocFullPath)
...
Next, the macro acquires the PspWorkbench object from the document using the top node of the object tree in a Distributive System document. ...
'---------------------------------------------------------
' Find the top node (PspWorkbench) of the Distributive System object tree - .
If ( Not ( objPspDoc Is Nothing ) ) Then
Set objPrdRoot = objPspDoc.Product
If ( Not ( objPrdRoot Is Nothing ) ) Then
Set objPspWorkbench = objPrdRoot.GetTechnologicalObject ("PspWorkbench")
End If
End If
...
Get a Logical Line ObjectFrom the objPspWorkbench object following objects can be obtained.
...
If ( Not ( objPspWorkbench Is Nothing ) ) Then
Set objPspApplication = objPspWorkbench.GetApplication(catPspIDLCATPiping)
...
Application factory object is then used to get a list of the logical line instances in the document. ...
If ( Not ( objPspWorkbench Is Nothing ) And _
Not ( objPspApplication Is Nothing ) ) Then
Set objPspAppFactory = objPspWorkbench.GetInterface("CATIAPspAppFactory", _
objPspApplication )
If ( Not ( objPspAppFactory Is Nothing ) ) Then
Set objLLogLines = objPspAppFactory.ListLogicalLines (objPrdRoot)
...
Then the macro gets CATIAPspGroup, CATIAPspLogicalLine and CATIAPspID handle on the first object in the list of logical lines. ...
Set objPspGroup = objLLogLines.Item(1,"CATIAPspGroup")
Set objPspLogLine = objLLogLines.Item(1,"CATIAPspLogicalLine")
Set objPspID = objLLogLines.Item(1,"CATIAPspID")
If ( Not (objPspID Is Nothing) ) Then
strMessage_g = strMessage_g & "Logical line object ID =" & objPspID.GetID & vbCr
End If
...
List MembersLogical line is a logical grouping of components (parts and strings) that share common attributes. This macros obtains a a list of members by use of Property Members on the PspGroup object on the logical line. Then for each member of the logical it gets a PspGroupable object. ...
Set objLMembers = objPspGroup.Members
If ( Not ( objLMembers Is Nothing ) ) Then
strMessage_g = strMessage_g & _
"Number of Members= " & objLMembers.Count & vbCr
For intIdx = 1 To objLMembers.Count
Set objPspGroupable = objLMembers.Item (intIdx, "CATIAPspGroupable")
Set objPspIDMember = objLMembers.Item (intIdx, "CATIAPspID")
...
Groupable DataMacro obtains a PspGroupable object obtained for the last member in the List of members. It then calls local Subroutine QueryGroupable by passing objPspGroupable as an argument. ...
'-----------------------------------------
' Query PspGroupable methods
'-----------------------------------------
If ( Not ( objPspGroupable Is Nothing ) ) Then
QueryGroupable objPspGroupable
...
Subroutine QueryGroupable then calls property Groups on the PspGroupable object to obtain information on the Groups of which the PspGroupable object is a member. ...
Private Sub QueryGroupable (objPspGroupableArg As PspGroupable)
Dim objPspGroups As PspGroup
If ( Not ( objPspGroupableArg Is Nothing ) ) Then
' ---------------------------
' Get Groups
' ---------------------------
Set objPspGroups = objPspGroupableArg.Groups
If ( Not ( objPspGroups Is Nothing ) ) Then
strMessage_g = strMessage_g & _
"Number of Groups =" & objPspGroups.Count & vbCr
...
Add and Remove a MemberIt then calls RemoveMember on PspGroup object to remove a PspGroupable object. ...
'-------------------------------------
' Remove member
'-------------------------------------
If ( Not ( objPspGroupable Is Nothing ) ) Then
strMessage_g = strMessage_g & "Removing member= " & _
objPspIDMember.GetID & vbCr
objPspGroup.RemoveMember objPspGroupable
...
It then calls AddMember on PspGroup object to restore the member back to the PspGroup object. ...
'-------------------------------------
' Add member
'-------------------------------------
strMessage_g = strMessage_g & _
"Adding member= " & objPspIDMember.GetID & vbCr
objPspGroup.AddMember objPspGroupable
...
Get From-to Object InformationThe macros uses PspLogicalLine object handle to call method GetFromTo to obtain From-To objects list. ...
'-----------------------------------------------------------------------
' GetFromTo information (CATIAPspLogicalLine)
'-----------------------------------------------------------------------
Dim objLFromMajorMembers As PspListOfObjects
Dim objLFromMinorMembers As PspListOfObjects
Dim objLToMajorMembers As PspListOfObjects
Dim objLToMinorMembers As PspListOfObjects
If ( Not ( objPspLogLine Is Nothing )) Then
objPspLogLine.GetFromTo objLFromMajorMembers, objLFromMinorMembers, _
objLToMajorMembers, objLToMinorMembers
If ( Not ( objLFromMajorMembers Is Nothing )) Then
strMessage_g = strMessage_g & _
"Number of From-Major Members is: " & objLFromMajorMembers.Count & vbCr
Else
strMessage_g = strMessage_g & _
"Number of From-Major Members is 0" & vbCr
End If
If ( Not ( objLFromMinorMembers Is Nothing )) Then
If ( Not ( objLFromMinorMembers Is Nothing )) Then
...
|
[Top]
This use case shows how to access a Logical line instance of an existing document. A message logging the status of the critical steps is displayed at the end of the use case.

[Top]
| [1] | Replaying a macro |
| [Top] | |
Copyright © 2004, Dassault Systèmes. All rights reserved.