Distributive Systems

Accessing Part Connector Data


This use case is intended to show you how to obtain physical part's technological connectors, add and remove a technological part connector to a physical part, and query the connectors information.

This macro opens the document CAAPspEduIn.CATProduct. Using the root node of the document, it then finds a Physical object and then it gets associated parts connector information

CAAPspPart is launched in CATIA [1]. No open document is needed.

CAAPspPart.CATScript is located in the CAAScdPspUseCases module. Execute macro (windows only).

CAAPspPart includes the following steps:

  1. Prolog
  2. Get a Physical Object
  3. Get a List of Part Connectors
  4. Retrieving Part Connector Information
  5. Add a Part Connector
  6. Remove a Part Connector

Prolog

The macro first loads Distributive System document CAAPspEduIn.CATProduct containing Equipment and Piping Design objects.

Note: To open a different document, modify the variable sDocPath to point to the 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\CAAPspEduIn.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 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")
    ...

Next, the macro acquires the PspApplication object corresponding to Piping application and initializes the application data.

    ...
    If ( Not ( objPspWorkbench Is Nothing ) ) Then
      Set objPspApplication = objPspWorkbench.GetApplication(catPspIDLCATPiping)

      If ( objPspApplication Is Nothing  ) Then
        strMessage_g = strMessage_g & "Success in getting objPspApplication" & vbCr
        objPspApplication.Initialization()
    ...

Next, the macro acquires the PspAppFactory object objPspAppFactory on the application object.

    ...
    If ( Not ( objPspWorkbench Is Nothing ) And _
         Not ( objPspApplication Is Nothing ) ) Then
      Dim objLPhysicals     As PspListOfObjects                  
      Set objPspAppFactory = objPspWorkbench.GetInterface("CATIAPspAppFactory", _
                                                objPspApplication )           
    ...

Get a Physical Object

Using the PspAppFactory method ListPhysicals, it obtains a list of physical objects in the Piping domain under the root product. Note that the output of this method is a list of objects. The member of this list can be retrieved using the Item method. The second argument of this method specifies a particular interface to be returned on this object.

It then uses the first physical object and obtains a CATIAPspPhysicalProduct interface handle on the object

    ...
     Set objLPhysicals = objPspAppFactory.ListPhysicals ( objPrdRoot , catPspIDLCATPIP)
      If ( Not ( objLPhysicals Is Nothing ) And _
         ( objLPhysicals.Count > 0 ) ) Then      
        Set objPspPhysicalPrd =  objLPhysicals.Item( 1, "CATIAPspPhysicalProduct" )
    ...

Get a List of Part connectors

Object objPspPhysicalPrd is used to get the list of technological connectors belonging to the physical part. For this it uses the property Connectors to get a list as objLCntrs . It then gets number of technological connectors.

    ...
     Set objLCntrs = objPspPhysicalPrd.Connectors 

      If ( Not ( objLCntrs Is Nothing ) ) Then
        strMessage_g = strMessage_g & _
          "Number of Part Connectors= " &  objLCntrs.Count & vbCr
    ...

It then uses the first connector object in the list objLCntrs and obtains a CATIAPspPartConnector interface handle on the connector and stores under the variable objPspPartCntr .

    ...
        '----------------------------------------
        ' Getting the first PspPartConnector
        Set objPspPartCntr = objLCntrs.Item (1, "CATIAPspPartConnector")        
    ...

Retrieving Part Connector Information

The objPspPartCntr is used to get the following part connector information:

  • Mechanical face connector associated to this technological connector by using GetFaceConnector function
  • Mechanical alignment connector associated to this technological connector by using GetAlignmentConnector function
  • Mechanical orientation connector associated to this technological connector by using GetOrientationConnector function
  • Connector face type by using FaceType
  • Connector alignment type by using AlignType
  • Connector clocking type by using ClockType
  • Connector number in the context of the physical part it belongs to.
  • Connector position by using function GetPosition
  • Connector align direction (outward normal to the face plane position associated with this connector) by using function GetAlignmentDirection
  • Connector up direction (upward normal to the up plane position associated with this connector) by using GetUpDirection
  • Plane containing the connector position, alignment and up directions by using the method GetConnectorMathPlane
  ...
      Set objFaceCntr = objPspPartCntr.GetFaceConnector        
      Set objAlignCntr = objPspPartCntr.GetAlignmentConnector          
      Set objOrientnCntr = objPspPartCntr.GetOrientationConnector

      eFaceType  = objPspPartCntr.FaceType
      eAlignType = objPspPartCntr.AlignType
      eClockType = objPspPartCntr.ClockType

      Set objRelAxisPrd = Nothing
      
      Set objLDbPosition = objPspPartCntr.GetPosition (objRelAxisPrd)
      Set objLDbAlignDir = objPspPartCntr.GetAlignmentDirection( _
                                                    objRelAxisPrd)
      Set objLDbUpDir = objPspPartCntr.GetUpDirection (objRelAxisPrd)    
          
      Set objLDbMathPlane = objPspPartCntr.GetConnectorMathPlane( _
                                                     objRelAxisPrd )   ...
   ...   

Add a Part Connector

This macro then add a part connector (technological connector) on the object objPspPhysicalPrd by calling its AddConnector function. Newly created connector is stored under the variable objNewPspPartCntr

  ...
  objNewPspPartCntr = objPspPhysicalPrd.AddConnector( _
 strCtrType, objFaceCntr,eFaceType, _
 objAlignCntr, eAlignType, _
 objOrientnCntr, eClockType )
  ...
    ' -----------------------------------
    ' Add a new connector
    ' -----------------------------------

    Dim objNewPspPartCntr As PspPartConnector

    If( Not ( objPspPhysicalPrd Is Nothing )) Then

      Dim strCtrType As String
      strCtrType = "CATPspMechPartConnector"

            Set objNewPspPartCntr = objPspPhysicalPrd.AddConnector( _
                             strCtrType, objFaceCntr,eFaceType, _                            
                             objAlignCntr, eAlignType, _
                             objOrientnCntr, eClockType )
   ...   

Remove a Part Connector

This macro then removes the part connector (technological connector) objNewPspPartCntr on the object objPspPhysicalPrd by calling its RemoveConnector method.

  ...   
    ' -----------------------------------
    ' Remove connector
    ' -----------------------------------

    If( Not ( objPspPhysicalPrd Is Nothing )) Then
      objPspPhysicalPrd.RemoveConnector objPspPartCntr
    End if
 ...   

[Top]


In Short

This use case is intended to show you how to obtain physical part's connectors, add and remove a part connector to a physical part, and query the connectors. A message logging the status of the critical steps is displayed at the end of the use case.

[Top]


References

[1] Replaying a macro
[Top]

Copyright © 2004, Dassault Systèmes. All rights reserved.