Distributive Systems |
Querying Connectivity and Flow Information |
![]() |
This use case is intended to show how to obtain a part's connectors and get connectivity and connector flow data using a macro. This macro opens the document CAAPspEduIn.CATProduct. From the root object of this document, the macro obtains a 3-D physical objects and then gets connected objects to it, and then gets connector and flow information for each connected connector. |
![]() |
CAAPspConnectivity is launched in CATIA [1]. No open document is needed. CAAPspConnectivity.CATScript is located in the CAAScdPspUseCases module. Execute macro (windows only). |
![]() |
CAAPspConnectivity includes the following steps:
PrologThe macro first loads CAAPspEduIn.CATProduct. 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 (objPrdRoot) of the object tree. ... ' 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") End If End If ... Then it uses PspWorkbench get application corresponding to "Piping Design" and initialize it. ... If ( Not ( objPspWorkbench Is Nothing ) ) Then Set objPspApplication = objPspWorkbench.GetApplication(catPspIDLCATPiping) If ( objPspApplication Is Nothing ) Then strMessage_g = strMessage_g & "Unable to get objPspApplication" & vbCr Else strMessage_g = strMessage_g & "Success in getthing objPspApplication" & vbCr objPspApplication.Initialization() End If End If '--- If ( Not ( objPspWorkbench Is Nothing )... ... Get a Physical (3D) Piping ObjectMacro then gets PspAppFactory object (objPspAppFactory) from the objPspApplication object and gets a list of physical (3D) piping objects. It gets the first 3-D physical object from the list and stores in the variable objPspPhysical . ... '----------------------------------------------------------------------- ' Get a PspPhysical object in the Piping domain '----------------------------------------------------------------------- If ( Not ( objPspWorkbench Is Nothing ) And _ Not ( objPspApplication Is Nothing ) ) Then Set objPspAppFactory = objPspWorkbench.GetInterface("CATIAPspAppFactory", _ objPspApplication ) If ( Not ( objPspAppFactory Is Nothing ) ) Then Dim objLPhysicals As PspListOfObjects Set objLPhysicals = objPspAppFactory.ListPhysicals ( objPrdRoot , catPspIDLCATPIP) If ( Not ( objLPhysicals Is Nothing ) And _ ( objLPhysicals.Count > 0 ) ) Then Set objPspPhysical = objLPhysicals.Item( 1, "CATIAPspPhysical" ) ... Get PspConnectable ObjectIt then gets PspConnectable object ( objPspCntbl) corresponding to physical object objPspPhysical . ... '----------------------------------------------------------------------- ' Get objPspCntbl '----------------------------------------------------------------------- If ( Not ( objPspWorkbench Is Nothing ) And _ Not ( objPspPhysical Is Nothing ) ) Then Set objPspPhyID = objPspWorkbench.GetInterface("CATIAPspID", _ objPspPhysical ) Set objPspCntbl = objPspWorkbench.GetInterface("CATIAPspConnectable", _ objPspPhysical ) ... Get Connected ObjectsIt then calls ListConnectables on objPspCntbl to get a list of connected objects (objLCntbles ) to it, and its list of connected connector objects objLCntrsOnThisObj. ... Set objLClassFilter = Nothing objPspCntbl.ListConnectables objLClassFilter, objLCntbles, _ objLCntrsOnThisObj, objLCntrsOnConnected If ( Not ( objLCntbles Is Nothing ) ) Then strMessage_g = strMessage_g & _ "Number of Connected objects= " & objLCntbles.Count & vbCr For intIdx = 1 To objLCntbles.Count Set objAIDCntbl = objLCntbles.Item (intIdx, "CATIAPspID") If ( Not (objAIDCntbl Is Nothing) ) Then strMessage_g = strMessage_g & "Connected object ID =" & objAIDCntbl.GetID & vbCr ... Query Connector InformationThen macro gets PspConnector object objPspCntr in the list objLCntrsOnThisObj and calls local subroutine QueryConnector() to get connector information for each connector. ... For intIdx = 1 To objLCntrsOnThisObj.Count Set objPspCntr = objLCntrsOnThisObj.Item (intIdx, "CATIAPspConnector") ... '----------------------------- ' Query Connector flow information If ( Not (objPspCntrFlow Is Nothing) ) Then QueryCntrFlow objPspCntrFlow ... Private subroutine QueryConnector uses the input parameter objPspCntrArg and gets the following connector information
... Private Sub QueryConnector (objPspCntrArg As PspConnector) ... If ( Not ( objPspCntrArg Is Nothing ) ) Then ' --------------------------- ' Get Associated connectable Set objPspAssocCntbl = objPspCntrArg.GetAssociatedConnectable strCntrName =objPspCntrArg.ConnectorName strMessage_g = strMessage_g & _ "Connector name = " & strCntrName & vbCr Set objLStrAttrNames = objPspCntrArg.AttrNames If ( Not ( objLStrAttrNames Is Nothing ) ) Then strMessage_g = strMessage_g & _ "Number of connector attributes = " & objLStrAttrNames.Count & v ... Query Flow InformationThen macro gets PspCntrFlow object objPspCntrFlow in the list objLCntrsOnThisObj and calls local subroutine QueryCntrFlow() to get flow information or each connector. ... '----------------------------- ' Query Connector flow information If ( Not (objPspCntrFlow Is Nothing) ) Then QueryCntrFlow objPspCntrFlow ... Private subroutine QueryCntrFlow uses the input parameter objPspCntrFlowArg and gets the following flow information
... Private Sub QueryCntrFlow (objPspCntrFlowArg As PspCntrFlow) Dim eFlowCapability As CatPspIDLFlowCapability Dim eFlowReality As CatPspIDLFlowReality If ( Not ( objPspCntrFlowArg Is Nothing ) ) Then ' --------------------------- ' Flow Capability information eFlowCapability = objPspCntrFlowArg.FlowCapability Select Case eFlowCapability Case catPspIDLFlowCapability_Undefined strMessage_g = strMessage_g & "Flow Capability in undefined" & vbCr Case catPspIDLFlowCapability_InDirection strMessage_g = strMessage_g & "Flow Capability is in inward direction" & vbCr Case catPspIDLFlowCapability_OutDirection strMessage_g = strMessage_g & "Flow Capability is in outward direction" & vbCr Case catPspIDLFlowCapability_InOutDirection strMessage_g = strMessage_g & "Flow Capability is in bi-directional" & vbCr End Select ' --------------------------- ' Flow Reality information eFlowReality = objPspCntrFlowArg.FlowReality Select Case eFlowReality Case catPspIDLFlowReality_Undefined strMessage_g = strMessage_g & "Flow in undefined" & vbCr Case catPspIDLFlowReality_InDirection strMessage_g = strMessage_g & "Flow is in inward direction" & vbCr Case catPspIDLFlowReality_OutDirection strMessage_g = strMessage_g & "Flow is in outward direction" & vbCr Case catPspIDLFlowReality_InOutDirection strMessage_g = strMessage_g & "Flow is in bi-directional" & vbCr End Select ' --------------------------- ' Set Flow Reality information If ( eFlowReality = catPspIDLFlowReality_Undefined ) Then eFlowReality = catPspIDLFlowReality_InDirection objPspCntrFlowArg.FlowReality = eFlowReality End If ... Query Valid Connector TypesThen macro calls ValidConnectorTypes function of objPspCntbl to get a list a Valid connector types. ... '----------------------------------------------------------------------- ' Get List of Valid connector types '----------------------------------------------------------------------- If( Not ( objPspCntbl Is Nothing )) Then Dim objLStrValidCntrTypes As PspListOfBSTRs Set objLStrValidCntrTypes = objPspCntbl.ValidConnectorTypes ... |
[Top]
This use case shows how to query connectivity information in a 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.