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

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

I will try this instead.


 
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")
 
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.
 
3_oqxsjf.png
2_icnzep.png


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.
 
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.
 
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
 
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
 
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
 
Status
Not open for further replies.
Back
Top