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:
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
If anybody has any thoughts that would be great.
Many Thanks,
CR.
RE: Edit an existing Title Block using VBA Macro
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
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
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
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
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 Subif You have any questions feel free to ask
With regards
Lukasz
RE: Edit an existing Title Block using VBA Macro
RE: Edit an existing Title Block using VBA Macro
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
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
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)?