CATIA’s data model is structured around two main object types: Physical Products (
Products) that hold information pertaining to structure, and Representations that hold information relating to descriptions– whether 3D geometry as in
Knowledgeware features as in
Knowledge Engineering Specifications, or 2D view drawings as in
Drawings. An overview of CATIA’s data model was described in previous posts. In this post, I’ll focus on the
The Drawing Data Model
CATIA Drawings are Representations whose
V_discipline attribute value is
"Drafting". Here is an overview of relationships found above and below the Drawing
Representationobject. Note that there are two types of Representations.
Aggregated vs Shared
Aggregated type is created by default when a drawing (or a shape) is inserted as new inside a
VPMReference. If a drawing is created by the
c: new content command or the
+ sign, it will be created as a
Shared representation in its own new tab (
One difference is that
Aggregated representations have no PLM state and revision of their own; they follow their parent
Shared representations, however, have their own PLM state and revision, independent of their position in the tree (noticed I didn’t say “parent in the tree”).
Another difference is that
Aggregated representations do not have a notion of
Instance (and no Instance tab in their Properties Window). They can only exist inside one
Shared representations can have multiple instances under any node in an assembly. They do not have a designated
Finally, it is possible to convert an
Aggregated representation to
Shared, but not the opposite; and once converted to
Shared, it can not be changed back to
The graphical notation difference in CATIA’s tree is as follows: Top is
Shared (with an arrow), bottom is
To quickly test our understanding of the above structure, let’s fire up a Drawing and write some VbScript code:
Here is the code in the above video.
Dim root As DrawingRoot set root = CATIA.ActiveEditor.ActiveObject Dim repRef As VPMRepReference Set repRef = root.Parent 'Note that this property, Father, will be always null for Shared Representations/drawings. It will only return a VPMReference is the Drawing is Aggregated.' Dim vpmRef As VPMReference set vpmRef = repRef.Father MsgBox "Root is " & root.Name & "VPMRepRef is " & repRef.Name & "VPMRef is " & vpmRef.Name
Navigating Drawing Inner Collections
Getting the collections inside a drawing is easy. Note that all CATIA API collections are 1 based. That is, the first element is at index 1. That said, VBScript arrays and VBA collections, as well as C-Sharp’s [all] data structures are 0 based– the first element is at index 0.
'In VBscript and VBA, we can declare variables without a type' Dim sheets Set sheets = drwRoot.Sheets MsgBox "DrawingRoot has a Sheets collection, whose type is a <" + TypeName( sheets)+ "> that has " + Cstr(sheets.Count) + " nested sheets" 'or we can declare them as Object' Dim aSheet as object Set aSheet = sheets.Item(1) 'VBScript objects types are resolved at runtime--when the script is executed.' MsgBox "Sheet one's name is <" + aSheet.Name + "> and its type is <" + TypeName(aSheet) +">" Dim views Set views = aSheet.Views MsgBox "aSheet has a Views collection, which at least has " + Cstr(views.Count) + " views. The first is the foreground, and the second is the background" Dim view Set view = views.Item(1) MsgBox "The first view is at index 1, and its type is similar to the second view, which is <" + TypeName(view) + ">"
To get the type name of any object in CATScript, VbScript, or VBA; use the
TypeName( theObject). This is simialr to EKL’s
theObject.PrimaryType.Name and C-Sharp’s
Dim sheets Set sheets = drwRoot.Sheets Dim mySheet As DrawingSheet 'add a new sheet and append the number of currently existing sheets +1. Note the CStr method to cast the integer to a string' sheets.Add( "Sheet " + Cstr(sheets.Count +1)) 'Then we set the mySheet variable to the last added item--which is at the index equal to the sheets count' Set mySheet = sheets.Item( sheets.Count)
The above is a quick overview of the Drawing data model in CATIA. The API for creating and editing drawings is too vast to be covered in a single post. Thus, more posts will be added to focus on specific tasks. Note that I used the dotnet API today since there are very few APIs exposed to EKL at this time.Tags: CATScript, Data Model, Drawing, Representation, VBA, VBScript