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!

How to add loop in to this code got from above thread

Status
Not open for further replies.

vjxzy

Automotive
Jan 31, 2019
13
IN
Language="VBSCRIPT"

Sub CATMain()
Dim DrwDocument As Document
Dim drwsheets As DrawingSheets
Dim drwsheet As DrawingSheet
Dim drwviews As DrawingViews
Dim drwview As DrawingView
Dim DrwTexts As DrawingTexts
Dim DrwText as DrawingText
Set DrwDocument = CATIA.ActiveDocument
Set drwsheets = DrwDocument.Sheets
set drwsheet = drwsheets.item(1)
set drwviews = drwsheets.item(1).views
set drwview = drwviews.item(2)
'msgbox drwviews.item(2).name ////BackgroundView item ID=2 - to find appropriate View
Set DrwTexts = drwview.Texts
Set DrwText = DrwTexts.GetItem("Text.1")
DrwText.text = "ASDF"
End Sub
 
Replies continue below

Recommended for you

requirement
1. there will be multiple sheets in my Drawing I need the macro to move to the next sheet and update the same in all sheets
 
I got the code from this thread
thread560-330652
 
I can't get it right where should I insert the code
 
Put it below this line:

Code:
Set DrwDocument = CATIA.ActiveDocument

and then copy the content below the line into the loop (but you have to update it slightly)

Code:
For Each drwsheet In DrwDocument.Sheets
     Set drwview = drwsheet.Views.Item(2)

     'msgbox drwviews.item(2).name ////BackgroundView item ID=2 - to find appropriate View
     Set DrwTexts = drwview.Texts
     Set DrwText = DrwTexts.GetItem("Text.1") 
     DrwText.text = "ASDF"
Next

Tesak
- Play Tetris in CATIA V5 drawing
 
sorry, tesak I'm new to catia VB at this time I can not get the code right I'm having a problem while understanding the code.thanks for helping ill get back to this in some time.
need to learn basics first do you have any idea where can I start? please share if u have any learning material
 
Learning VBA for Microsoft Excel is a great starting point. Many many resources are available, the type of language is the same, and the concepts are the same. As a bonus, you can start to learn to interact between Catia and Excel for some functions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top