×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Edit an existing Title Block using VBA Macro

Edit an existing Title Block using VBA Macro

Edit an existing Title Block using VBA Macro

(OP)
Hi,

First post!!

I've been tasked to automatically create drawings based on an excel spreadsheet with all the required data.

I've managed to get a script to open a new drawing, add the required text and save it using the correct naming scheme.

The problem I'm up against is that some of the information in the spreadsheet needs to go into a company set title block.

All the scripts I've found so far create the block from scratch, which isn't useful.

I was thinking I could open up a template drawing and then input all the required data like that, but I still need to be able to edit the stock title block!!!

Anybody got any thoughts on either:

A) How to add a title block inputting the required data.
B) Edit an existing title block.

This is the code that opens the drawing:

CODE --> VBA

Set oDocument = CATIA.Documents.Add("Drawing")
Set iDocument = CATIA.ActiveDocument
Set iSheets = iDocument.Sheets
Set iSheet = iSheets.Item(1)
Set iView = iSheet.Views.Item("Background View")
Set iTexts = iView.Texts 

RE: Edit an existing Title Block using VBA Macro

(OP)
Can't work out to edit my post so here is the rest of it:

If anybody has any thoughts that would be great.

Many Thanks,
CR.

RE: Edit an existing Title Block using VBA Macro

(OP)
More on this:

My company has a macro with a toolbar (Supplied by ext company so no access to it) which imports parts of the title block from another .CATdrawing, arranges them and inputs the data given in a User Input form.

Is there any way of running this "Create_Title_Block" toolbar/tool button from my script, inputting the required data into the userform automatically, before clicking 'ok'.

Pain in the backside but there you go!

RE: Edit an existing Title Block using VBA Macro

Few clarifications for us:

The title block is created in macro or ?

If is created in macro then you can modify it or you can input a text at a specific position in a specific view/sheet. I believe there are few codes in this forum as examples.

Yes,, you can run from your script another one, depending on what is it your second one (exe file, CATScript or whatever). If you want to type in a user form something you can use sendkeys method for example (is not so nice but it can be done). Search on Internet, I"m sure you can find something.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208

RE: Edit an existing Title Block using VBA Macro

(OP)
Hi,

I have NO access to the script that generates the title block, nor do I know where it is stored within the CATIA files (even after searching!)

There is a button on the tool bars, but that is all I have to launch this script!!

RE: Edit an existing Title Block using VBA Macro

OK, now is clear. In this case you can write on the drawing sheet a text in a specific point location. Put a point where you want to add text, take the coordinates and do it in a separate macro. Your text still can be added in the title block field, is not neccessary to open and edit the title block (I suppose is not a picture).

Let me know if you manage to do it.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208

RE: Edit an existing Title Block using VBA Macro

dear author:

CODE --> VBA

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)    ////Only one sheet
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("TitleBlock_Text_Design")   ///How to find text box name - just right-click on the desired text and find "... Object" - those dots are Text Item name
'msgbox DrwText.text
DrwText.text = "ASDF"  //change text to ASDF
End Sub 

if You have any questions feel free to ask

With regards
Lukasz

RE: Edit an existing Title Block using VBA Macro

I'm new to creating macros for CATIA. This was very helpful because I have the same issue. The question I have is how do I apply this to a multi sheet drawing. Any assistance is greatly appreciated.

RE: Edit an existing Title Block using VBA Macro

Hi,

Check with tools -> Macros -> and macro libraries.
This should give the details of path of one or more directories from which you can use the edit option to check on macro.

However, as it is an VBA macro and it has been supplied by ext company, i assume there will be security (Password) for the macro without which you can't do any editing in it.

Regards,
Maddy

RE: Edit an existing Title Block using VBA Macro

Quote:

CATIA.ActiveDocument.Sheets.Count
(as Integer) will gave You number of sheets in Your drawing


the next step is to insert loop

If You have any problems feel free to ask

RE: Edit an existing Title Block using VBA Macro

i apologise for resuming an old thread, but i am wondering, what is the benefit of using a macro for the title block versus a catdrawing template that has it drawn (or imported from a dwg)?

also, is it possible to populate the template (from dwg) title block automatically like in solidworks (based on custom properties, part properties - weight... or filename)?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources