Distributive Systems |
Accessing Light Part Data |
|
This use case is intended to show you how to obtain and set Light part data on a light part object using a macro.. This macro opens the document CAAPsp3DEduIn.CATProduct. Using the root node of the document, it then finds a Light Part object with a given instance name. It then sets and gets the definition points of the light part. |
|
|
CAAPspLightPart is launched in CATIA [1]. No open document is needed. CAAPspLightPart.CATScript is located in the CAAScdPspUseCases module. Execute macro (windows only). |
|
|
CAAPspLightPart 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 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 Light Part ObjectUsing the objPrdRoot as the node, the macros processes the Products collection to get a product whose instance name is "Weld-011". It uses GetInterface method of objPspWorkbench to get CATIAPspLightPart interface handle on the light part object. ...
' ----------------------------------------------------
' Get a Product whose instance name is Weld-011
' and then get handler to PspLightPart
' ----------------------------------------------------
Dim objWeld As Product
Dim objPspLightPart As PspLightPart
If ( Not ( objPspWorkbench Is Nothing ) And _
Not ( objPrdRoot Is Nothing ) ) Then
Set objWeld = objPrdRoot.Products.Item("Weld-011")
If ( Not ( objPrdRoot Is Nothing ) ) Then
Set objPspLightPart = objPspWorkbench.GetInterface("CATIAPspLightPart", _
objWeld )
End If
...
Set Definition PointsIt then calls SetDefinition method of objPspLightPart object to set definition points of the light part by passing an array of six values as coordinates of two points. ...
' ----------------------------------------
' Setting up array of definition of points
' -----------------------------------------
db6Array(0)=0.5
db6Array(1)=0.0
db6Array(2)=0.0
db6Array(3)=4.0
db6Array(4)=0.0
db6Array(5)=0.0
objPspLightPart.SetDefinition objRelAxisPrd, db6Array
...
Get Definition Points InformationIt then GetDefinition method of objPspLightPart object to obtain definition point information. ...
' ----------------------------------------
' Get definition points of the light part
' ----------------------------------------
Set objLDefPoints = objPspLightPart.GetDefinition ( _
objRelAxisPrd )
'-----------------------------------------
' Display information on Definition points
'-----------------------------------------
If ( Not ( objLDefPoints Is Nothing ) ) Then
iNbPts = objLDefPoints.Count / 3
strMessage_g = strMessage_g & _
"Number of definition points =" & iNbPts & vbCr
For iIdx = 1 To objLDefPoints.Count Step 3
dbX = objLDefPoints.Item( iIdx )
dbY = objLDefPoints.Item( iIdx + 1 )
dbZ = objLDefPoints.Item( iIdx + 2 )
strMessage_g = strMessage_g & "Definition pt " & vbCr
strMessage_g = strMessage_g & " X= " & dbX & vbCr
strMessage_g = strMessage_g & " Y= " & dbY & vbCr
strMessage_g = strMessage_g & " Z= " & dbZ & vbCr
Next
...
|
[Top]
This use case shows how to access a light part 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.