Modify Text in Title Blocks on every CatDrawing that is open.
Modify Text in Title Blocks on every CatDrawing that is open.
(OP)

This is how the Title Blocks looks (every CatDrawing the same.)
Now what i have to do is to modify Text1 , Text2 , Text3 ,Text4 and Text 5 on every page. I am new to catia , and VB too. I have tried to create a macro that asks me ..what new text should be and type them in the text boxes but i have failed.
For example:
New project:
Text1 = a1
Text2 = b1
Text3 = c1
Text4 = d1
Text5 = e1
After few days update is needed and after some changes :
Text1 must become = a2
Text2 must become = b2 and so on.
Sometimes i have to do this for 2 or 3 sheets and i do it..manually on each page. But other times i have to do this for 100 or more..
The Title Blocks are allways in SheetBackground , and it's custom made (it't not one from Catia title blocks library)
If needed , i can send you a CatDrawing sheet, just ask.
Hope i will find here some help.
Best regards , and thank you for your time.





RE: Modify Text in Title Blocks on every CatDrawing that is open.
The screen capture is too small, better upload the drawing because you have to identify also those text strings in order to assign them new values.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Modify Text in Title Blocks on every CatDrawing that is open.
http://files.engineering.com/getfile.aspx?folder=d...
RE: Modify Text in Title Blocks on every CatDrawing that is open.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Modify Text in Title Blocks on every CatDrawing that is open.
It is posible to have the subsequesnt sheet inheret the background from the first sheet.
Tools>Options>Mechanical Design>Drafting>Layout : New Sheet
This must be done when the new sheet is added.
If you already have a drawing with multiple sheets, then I think coding it will be the only way.
Start off by trying some stuff manually with the macro recorder running.
Also,, take a look at the canned macros that come with catia.
There is code in there that shows how to loop through elements on a drawing.
RE: Modify Text in Title Blocks on every CatDrawing that is open.
I dont have to create any new sheet.
I must open all CatDrawings in Catia. (Every CatDrawing has a single Sheet.)
And then must update those text fields.
I have tried recordering a macro , but when i select and modify those texts , nothing seems to appear as code.
Also checked V5Automation documentation , and over the catia macros but i still didn't get it.
Don't really know how that ditto is defined , how i can get info about it so that i can access and modify those text fields.
See picture in attachment.Maybe is more descriptive
:(
Thank you.
Sorry my english is not very good.
RE: Modify Text in Title Blocks on every CatDrawing that is open.
Now I'm using r21 and I'm not able to do a search text string inside ditto (or 2D component instance as is known in v5).
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Modify Text in Title Blocks on every CatDrawing that is open.
I have also tried to manually search with Find , those text strings , but they can't be found.
Is there a way to create a macro so i can view the properties of that object ? Maybe if i can find how that TextBoxs are named..maybe i can change someway it's value.
RE: Modify Text in Title Blocks on every CatDrawing that is open.
So, i guess:
For Each Sheet
find text note in background
change text note's text
RE: Modify Text in Title Blocks on every CatDrawing that is open.
indocti discant et ament meminisse periti
RE: Modify Text in Title Blocks on every CatDrawing that is open.
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Modify Text in Title Blocks on every CatDrawing that is open.
RE: Modify Text in Title Blocks on every CatDrawing that is open.
CODE -->
Sub modify() Dim oDrawing As DrawingDocument Set oDrawing = CATIA.ActiveDocument Dim oSheets As DrawingSheets Set oSheets = oDrawing.Sheets Dim oSheet As DrawingSheet Set oSheet = oSheets.Item("Sheet.1") Dim oView As DrawingView Set oView = oSheet.Views.Item(2) oView.Activate Dim o2DComponents As DrawingComponents Set o2DComponents = oView.Components Dim o2DComponent As DrawingComponent Set o2DComponent = o2DComponents.Item(1) For i = 1 To 100 Dim oText As DrawingText Set oText = o2DComponent.GetModifiableObject(i) oText.Text = "Alex" Next i End SubAdapt the code to your needs.
RE: Modify Text in Title Blocks on every CatDrawing that is open.
RE: Modify Text in Title Blocks on every CatDrawing that is open.
Regards
RE: Modify Text in Title Blocks on every CatDrawing that is open.
Excellent idea Alex, star from me.
Cozmin, iata codul tau (here is your code) , of course it can be improved
CODE --> CATScript
Sub CATMain() Dim oDrawing As DrawingDocument Set oDrawing = CATIA.ActiveDocument Dim oSheets As DrawingSheets Set oSheets = oDrawing.Sheets Dim oSheet As DrawingSheet Set oSheet = oSheets.Item("Sheet.1") Dim oView As DrawingView Set oView = oSheet.Views.Item(2) oView.Activate Dim o2DComponents As DrawingComponents Set o2DComponents = oView.Components Dim o2DComponent As DrawingComponent Set o2DComponent = o2DComponents.Item(1) ' Retrieve the modifiable text of the ditto Dim oText As DrawingText Set oText = o2DComponent.GetModifiableObject(1) Count = o2DComponent.GetModifiableObjectsCount For i = 1 To Count Set oText = o2DComponent.GetModifiableObject(i) If oText.Text = "Text 1" Then oText.Text = "A1" ElseIf oText.Text = "Text 2" Then oText.Text = "B1" ElseIf oText.Text = "Text 3" Then oText.Text = "C1" ElseIf oText.Text = "Text 4" Then oText.Text = "D1" ElseIf oText.Text = "Text 5" Then oText.Text = "E1" End If Next ''i End SubEric, j'étais presque sûr que Cozmin ne sera pas obtenir une réponse rapide
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...
RE: Modify Text in Title Blocks on every CatDrawing that is open.
Thank you all a lot for your support.
CatScript :
Sub CatMain()
For I = 1 To CATIA.Documents.Count
Here Code posted By Alex or Fernando
Next
End Sub
------------------------
Thank you again. Best wishes.