Distributive Systems |
Disconnecting Parts |
![]() |
This use case is intended to shows how to check connection of two parts using a macro. This macro opens the document CAAPspEduIn.CATProduct. From the root object of this document, the macro obtains a handle to two objects and checks if they are connected . Furthermore, if the parts are connected they are disconnected. |
![]() |
CAAPspDisconnectParts is launched in CATIA [1]. No open document is needed. CAAPspDisconnectParts.CATScript is located in the CAAScdPspUseCases module. Execute macro (windows only). |
![]() |
CAAPspDisconnectParts 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 Set objPrdRoot = CATIA.ActiveDocument.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 ( Not( objPspApplication Is Nothing ) ) Then strMessage_g = strMessage_g & "Success in getthing objPspApplication" & vbCr objPspApplication.Initialization() End If End If '--- If ( Not ( objPspWorkbench Is Nothing )... ... Get a List of Physical (3D) Piping ObjectsMacro then gets Get PspAppFactory object handler from the objPspApplication object and get a list of physical (3D) piping objects in the root product. ... '----------------------------------------------------------------------- ' Get list of physical (3D) objects in the Piping domain '----------------------------------------------------------------------- Dim objLPhysicals As PspListOfObjects If ( Not ( objPspWorkbench Is Nothing ) And _ Not ( objPspApplication Is Nothing ) ) Then Set objPspAppFactory = objPspWorkbench.GetInterface("CATIAPspAppFactory", _ objPspApplication ) If ( Not ( objPspAppFactory Is Nothing ) ) Then Set objLPhysicals = objPspAppFactory.ListPhysicals( objPrdRoot, catPspIDLCATPIP) End If ... Get PspConnectable Objects Corresponding to Two PartsIt then gets PspConnectable objects corresponding to Valve whose ID is "V-117" and a gasket object whose ID is "Gasket-012" using the private Function FindPipingPartByID by passing input list of Physical objects (objLPhysicals). ... ' -------------------------------------------------------------- ' Get PspConnectable object corresponding to Valve with ID=V-117 ' and Gasket whose ID = Gasket-012 ' --------------------------------------------------------------- Dim objValveCtbl As PspConnectable Dim objGasketCtbl As PspConnectable If ( Not ( objLPhysicals Is Nothing ) And _ ( objLPhysicals.Count > 0 ) ) Then Set objValveCtbl = FindPipingPartByID (objLPhysicals, "V-117") Set objGasketCtbl = FindPipingPartByID (objLPhysicals,"Gasket-012") End If ... Check if Two Parts Are ConnectedIt then calls ListConnectables on objValveCtbl ( corresponding to V-117) to get a list of connected objects (objLCntbles) to it. Then it checks ID of all the connected objects to see if any of them match with "Gasket-012". ... Set objLClassFilter = Nothing objValveCtbl.ListConnectables objLClassFilter, objLCntbles, _ objLCntrsOnThisObj, objLCntrsOnConnected If ( Not ( objLCntbles Is Nothing ) ) Then Dim objAIDCntbl As PspID strMessage_g = strMessage_g & _ "Number of Connected objects= " & objLCntbles.Count & vbCr For iIdx = 1 To objLCntbles.Count Set objAIDCntbl = objLCntbles.Item (iIdx, "CATIAPspID") Dim strCntdID As String If ( Not (objAIDCntbl Is Nothing) ) Then strCntdID = objAIDCntbl.GetID If ( strCntdID = "Gasket-012" ) Then iIdxOfGasket = iIdx Exit For ' Exit out of the for loop End If End If ... Disconnect Two PartsTo get corresponding connectors on the two objects, use the index of the Gasket-012 object in the list objLCntbles and obtain the corresponding PspConnector objects from List of connectors objLCntrsOnThisObj and objLCntrsOnConnected. Connector on the Valve is obtained as objPspCntrValve while on the gasket it is objPspCntrGasket. ... Set objPspCntrValve = objLCntrsOnThisObj.Item (iIdxOfGasket, "CATIAPspConnector") Set objPspCntrGasket = objLCntrsOnConnected.Item (iIdxOfGasket, "CATIAPspConnector") ... To disconnect the Valve and gasket the macros calls Disconnect on objPspCntrValve by passing in the argument objPspCntrGasket. ... objPspCntrValve.Disconnect objPspCntrGasket ... |
[Top]
This use case shows how to check connection of two parts 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.