×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*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.

Automated Title Block and more

Automated Title Block and more

(OP)
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é

RE: Automated Title Block and more

(OP)
Thank you ferdo and Lwolf for the quick responses

I used their custom title block as a background view in Page Setup. Is it possible to get this into the code ?
I'm having problems also in filling the gaps

RE: Automated Title Block and more

Starting from a model, yes, it can be put in the code. You can find an example in CATIA installation folder, do a search for CATScript there (or title block, can't remember exactly)

RE: Automated Title Block and more

C:\Program Files\Dassault Systemes\B28\win_b64\VBScript\FrameTitleBlock

regards,
LWolf

RE: Automated Title Block and more

(OP)
Sorry, I wasn't clear. I mean my company's title block is what I'd like to convert to code not the default samples of Catia.
Is there an automatic way to do this ? or it has to be written ?

RE: Automated Title Block and more

To be written, no doubts.

RE: Automated Title Block and more

(OP)
I saw on another thread, ferdo you wrote:
"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)."

RE: Automated Title Block and more

True, but first see if you don't have already some text boxes in those places. You can modify their value in a macro.

RE: Automated Title Block and more

(OP)
I do have text boxes and I figured I can get to them using the "Insert Object Resolution" tool. Now changing their value I'm still looking for that. Can you point me in the right direction?

Set drawingDocument1 = CATIA.ActiveDocument

Set drawingSheets1 = drawingDocument1.Sheets

Set drawingSheet1 = drawingSheets1.Item("Sheet.1")

Set drawingViews1 = drawingSheet1.Views

Set drawingView1 = drawingViews1.Item("Background View")

Set drawingTexts1 = drawingView1.Texts

Set drawingText1 = drawingTexts1.Item("Text.82")

RE: Automated Title Block and more

Quote:

Now changing their value I'm still looking for that.

CODE

Set drawingText1 = drawingTexts1.Item("Text.82")
drawingText1.Text = "My new text" 

I'd say that you're going to have really hard time exploring those texts since they have auto-generated names. It means each time a text get pasted in a list it gets unique number as a suffix. So the same piece of a frame titleblock is going to have different names on different sheets.

RE: Automated Title Block and more

(OP)

Here's the titleblock.

Little Cthulhu I've tried your code and it ran but didnt change anything whatsoever.
I pretend to use this titleblock as a background view everytime we need it for a new product. Using page setup to get it. I've tested doing this and using the "Insert Object Resolution" tool and it gives the same output for each one of the text boxes as in the original. For exameple the text box with the 1 inside puts out object Text.79.

Can i change the names of the text boxes ?

[EDIT]- I now know I can change the name of the text boxes, would that facilitate the job ? still can't change the text inside it though.

RE: Automated Title Block and more

(OP)
i've got this :

CODE -->

Language="VBSCRIPT"
Sub CATMain()
CATIA.ActiveDocument.Selection.clear
Set drawingDocument1 = CATIA.ActiveDocument
Set selection1 = drawingDocument1.Selection
selection1.Search "CATDrwSearch.DrwText.TextString=*fillmaterial*,all"
Text1 = selection1.Count
'CATIA.ActiveDocument.Selection.clear
Text2 = "aluminium"
If  selection1.Count > 0 Then
selection1.Item(1).Value.Text = Text2
End If
CATIA.ActiveDocument.Selection.clear
End Sub 

And it works but it goes by the content not the box. I dont manage to get the box selection working.

RE: Automated Title Block and more

see Little Cthulhu last post

regards,
LWolf

RE: Automated Title Block and more

(OP)
I've tried this and it doesnt work. I'm sure there's something really obvious wrong with it.

CODE -->

Language="VBSCRIPT"

Sub CATMain()
CATIA.ActiveDocument.Selection.clear

Set drawingDocument1 = CATIA.ActiveDocument

Set drawingSheets1 = drawingDocument1.Sheets

Set drawingText1 = drawingTexts1.Item("Text_01")
drawingText1.Text = "My new text"

End Sub 

RE: Automated Title Block and more

Always put Option Explicit in the first line of your every script. This way you're going to discover errors easier.

CODE

Option Explicit
Sub CATMain()
Dim doc as DrawingDocument
set doc = CATIA.ActiveDocument
Dim view as DrawingView
set view = doc.Sheets.ActiveSheet.Views.Item(1) ' 1 - background view, 2 - main view
Dim txt as DrawingText
Set txt = view.Texts.Item("Text_01")

txt.Text = "My new text"
End Sub 

RE: Automated Title Block and more

Always put Option Explicit in the first line of your every script. This way you're going to discover errors easier.

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 - main view, 2 - background view
Dim txt as DrawingText
Set txt = view.Texts.Item("Text_01")

txt.Text = "My new text"
End Sub 

RE: Automated Title Block and more

(OP)
Didn't work, gave an error right in the:
Dim doc as DrawingDocument

RE: Automated Title Block and more

actually, background view is View.Item(2)

regards,
LWolf

RE: Automated Title Block and more

... but I cannot seem to identify a text-item by its' name reference "xxx", only by item number?...

regards,
LWolf

RE: Automated Title Block and more

(OP)
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 ...

RE: Automated Title Block and more

Quote:

actually, background view is View.Item(2)

Thanks for correcting.

Quote:

Didn't work, gave an error right in the:
Dim doc as DrawingDocument

What error? Post a screenshot.

RE: Automated Title Block and more

(OP)

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 - main view, 2 - background view
Dim txt as DrawingText
Set txt = view.Texts.Item("Text_01")
txt.Text = "My new text"
End Sub


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

RE: Automated Title Block and more

You are using catvbs, you need to replace all As with 'As - check the documentation why, this code is working in CATScript

RE: Automated Title Block and more

(OP)

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 :

It says Incorrect type : 'view.Texts.Item'

RE: Automated Title Block and more

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.

CODE --> CATVBA

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")

'.... code for other unrelated functions

If WeightApplyAll.Value = False Then 'disregard the If...Then I have an "apply to all sheets" toggle button on my userform
Set Weight = TitleBlockTexts.GetItem("TitleBlock_Text_Estimated_Weight")
Weight.Text = UCase(Title_Block.Weight_TB.Value) & " " & LCase(Weight_Unit_LBL)  '"Weight_Unit_LBL" is for a kg/g option on my userform
End If 

RE: Automated Title Block and more

See LucasC post, replace Item("") with GetIten("")

RE: Automated Title Block and more

yupp, GetItem does the trick! thx

regards,
LWolf

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.

Resources

eBook - Functional Prototyping Using Metal 3D Printing
Functional prototypes are a key step in product development â€“ they give engineers a chance to test new ideas and designs while also revealing how the product will stand up to real-world use. And when it comes to functional prototypes, 3D printing is rewriting the rules of whatâ€™s possible. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!