Interactive Drafting |
Dimensions Checking |
|
This macro shows you how to find dimensions pointed by text leader in Drawing document. This macro works on current drawing document. |
||||||||||
|
CAADriDimension has to be launch in CATIA [1]. Open CAADriDimension.CATDrawing document below sample directory. CAADriDimension.CATScript is located in the CAADriUseCases module. Execute macro (Windows only).
|
||||||||||
|
CAADriDimension includes nine steps:
Prolog
The CATIA prompts are disabled thanks to the Reading current Drawing Document of the CATIA Session
|
...
' Retrieve the drawing document's sheets collection
Set DrwSheet = DrwDoc.Sheets
' Retrieve the active sheet to restore it at the end of the macro
Set SheetToRestore = oDrwSheets.ActiveSheet
' Scan all the sheet of the Drawing document
For numsheet = 1 To DrwSheets.Count
Set CurrentSheet = DrwSheets.Item(numsheet)
' Active Currentsheet
CurrentSheet.Activate
...
|
The Sheets collection is retrieved from the DrwDoc object
using the Sheets method.
... 'get the Views' collection Set DrwViews = CurrentSheet.Views 'Read the current view to restore it at the end of the macro Set ViewToRestore = DrwViews.ActiveView 'Scan all the view of the current Sheet
For numview = 1 To DrwViews.Count
Set CurrentView = DrwViews.Item(numview)
'Active the current view
CurrentView.Activate
...
|
The Views collection is retrieved from Sheet object using the Views method.
... 'Get the Texts' collection Set DrwTexts = CurrentView.Texts
'Scan all the Texts of the current View
For numtxt = 1 To DrwTexts.Count
Set CurrentText = DrwTexts.Item(numtxt)
...
|
the Texts collection is retrieved from View object using the Texts method.
...
'Get the Leaders' collection
Set DrwLeaders = CurrentText.Leaders
'Scan all the Leader of the current Text
For numlead = 1 To DrwLeaders.Count
Set CurrentLeader = DrwLeaders.Item(numlead)
' Manage error on HeadTarget method when
' no element is pointed by the text leader.
On Error Resume Next
' Get object pointed on the leader
Set ElemDispatch = Nothing
Set ElemDispatch = CurrentLeader.HeadTarget
NomObj = TypeName(ElemDispatch)
...
|
If no element is pointed by the leader the method returns fail.
...
' A dimension is pointed by text leader
If NomObj = "DrawingDimension" Then
' Get the dimension object
Dim PointedDim As DrawingDimension
Set PointedDim = ElemDispatch
' Read dimension tolerances
PointedDim.GetTolerances oTolType, oTolName, oUpTolS, oLowTolS, oUpTolD, oLowTolD, oDisplayMode
' Read dimension frame type
TypeFrame = PointedDim.ValueFrame
...
|
TypeName method returns the name of the pointed element.
.
...
' If dimension does not respect the criteria text leader object is highlighted
If oTolType <> 0 Or TypeFrame <> catFraRectangle Then
DrwSelect.Add CurrentText
DrwSelect.VisProperties.SetRealColor 255, 0, 0, 0
DrwSelect.VisProperties.SetRealWidth 6, 1
End If
...
|
Text appearance is changed by using VisProperties capabilities of Select object.

...
'Restore the view
ViewToRestore.Activate
Next
Next
'Restore the Drawing Document sheet
SheetToRestore.Activate
...
|
By this way the Drawing document keep his state before macro processing.
End of the macro.
![]()
[Top]
This use case has shown how to get dimension pointed by a Text leader.
[Top]
| [1] | Replaying a Macro |
| [2] | Drawing Document, DrawingSheet, DrawingSheets, DrawingView, |
| [Top] | |
Copyright © 2002, Dassault Systèmes. All rights reserved.