Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Automated Title Block and more

Status
Not open for further replies.

theribeiro

Computer
Aug 19, 2020
12
0
0
PT
Hello everyone ! my name is Andre. Im an IT student internshipping in a metal design factory working for the first time with Catia.
I'm working using Catia v5r26.

So here they have a custom title block someone made, and they use it for all the parts.
The thing is they have it in a CATdrawing, each time they need it they create a copy of the file and delete the previous part views and data. And they fill the gaps with the new information by hand.

I'm trying to find a way to have the custom title block in a macro or by someway that would be more easily acessible. And fill the gaps such as date, number part, material and Designer automatically (getting that information from the part itself).

1 - Would there be a way to "transfer" the custom title block they have into code ? or do i need to draw it all over again ? I don't have much experience creating tables and its not simple, it has different column and row width, an image...

2 - Can I get that automated filling of the gaps using only formulas ? or is macro necessary too ?

I've searched but haven't found a thing like this. However if you can send me links or something I appreciate :D

Thank you in advance, any help is amazing

André
 
Replies continue below

Recommended for you

LWolf with the code I posted above I can get to the value of the text box, by searching it in the drawing and changing it to something else. What I'm not able to do is select the text box itself to change what's inside it. Till now with no success.
The number inside doesn't serve any purpose, merely to enumerate the boxes. The boxes names go like Text_01 ...
 
error_jbdktt.png
Code:
[b]
Option Explicit

Sub CATMain()


 Dim doc as DrawingDocument
 set doc = CATIA.ActiveDocument
 Dim view as DrawingView
 set view = doc.Sheets.ActiveSheet.Views.Item(2) ' 1 - main view, 2 - background view
 Dim txt as DrawingText
 Set txt = view.Texts.Item("Text_01")
 txt.Text = "My new text" 
End Sub
[/b]

Sorry It's in portuguese, but it basically says Error in compilation, End of instruction missing
 
Code:
Option Explicit

Sub CATMain()

Dim doc as DrawingDocument

set doc = CATIA.ActiveDocument

Dim view as DrawingView

set view = doc.Sheets.ActiveSheet.Views.Item(2) ' 1 - background view, 2 - main view

Dim txt as DrawingText

Set txt = view.Texts.Item("Text_01")

txt.Text = "My new text" 

End Sub

I've tested with CATScript too and it puts out another error :

error_uuows8.png


It says Incorrect type : 'view.Texts.Item'
 
Here's a sample of my code for changing titleblock text boxes (in sheet background). This is used on a userform so some strings refer to clickable buttons or text boxes there.

2020-08-20_12_20_03-Properties_vkpsdc.png


Code:
Dim DrawingDoc As DrawingDocument
Set DrawingDoc = CATIA.ActiveDocument

Dim TitleBlockTexts As DrawingTexts
Set TitleBlockTexts = DrawingDoc.sheets.ActiveSheet.views.Item("Background View").Texts

Dim Weight
Set Weight = TitleBlockTexts.GetItem("TitleBlock_Text_Estimated_Weight")

[COLOR=#73D216]'.... code for other unrelated functions[/color]

If WeightApplyAll.Value = False Then [COLOR=#73D216]'disregard the If...Then I have an "apply to all sheets" toggle button on my userform[/color]
Set Weight = TitleBlockTexts.GetItem("TitleBlock_Text_Estimated_Weight")
Weight.Text = UCase(Title_Block.Weight_TB.Value) & " " & LCase(Weight_Unit_LBL)  [COLOR=#73D216]'"Weight_Unit_LBL" is for a kg/g option on my userform[/color]
End If
 
Status
Not open for further replies.
Back
Top