Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catia macro to automate drawing sheet numbers

Status
Not open for further replies.

JANE15

Aerospace
Aug 7, 2017
1
SG
I'm trying to write a macro which automates the sheet numbers on my drawings. For example sheet 2 of 3.

I have found a code which works to print this information in the sheet background although I cannot find a way to update these numbers if a sheet is later added or deleted. At the moment if I run the macro again it simply prints the new numbers on top of the previous (so you can see both).

I'm trying to find a way that the existing text box can be either updated or deleted by the macro when an update is needed.

Hope this makes sense! Any help would be greatly appreciated.
 
Replies continue below

Recommended for you

Just an idea: first time when you create the textbox, name it specifically. Thus, when running the script again, you can address it directly from the collection of Texts of your Background View.
 
First, count the number of sheets of your file,
then go to each sheet, and add the number.

try this:

Code:
Dim MyDoc As Document
Dim MyDrawingDoc As DrawingDocument
Set MyDrawingDoc = CATIA.ActiveDocument

Dim DrwDocument   As DrawingDocument
Dim DrwSheets     As drawingSheets
Dim DrwSheet      As drawingSheet
Dim DrwView       As DrawingView
Dim DrwTexts      As DrawingTexts
Dim Text          As DrawingText
Dim Fact          As Factory2D
Dim Point         As Point2D
Dim Line          As Line2D
Dim Cicle         As Circle2D
Dim Selection     As Selection
Dim GeomElems     As GeometricElements

For Each DrwSheet In MyDrawingDoc.Sheets

Dim sheet As Integer
Dim sheet_count As Integer
sheet = sheet + 1
sheet_count = MyDrawingDoc.Sheets.Count

'Insert sheet number

Set MyText1 = MyDrawingViews.ActiveView.Texts.Add(("Sheet " & sheet & " / " & sheet_count), 100, 14.5)
MyText1.WrappingWidth = 23
MyText1.SetFontSize 0, 0, 1.8

next

Tiago Figueiredo
Tooling Engineer

Youtube channel:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top