Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Modify Text in Title Blocks on every CatDrawing that is open. 4

Status
Not open for further replies.

CozminC

Industrial
Jan 30, 2014
14
RO
Indicator1.jpg


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.
 
Replies continue below

Recommended for you

FYI:
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.
 

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.
 
 http://files.engineering.com/getfile.aspx?folder=9c012154-50be-4d55-9839-e89a0e40abb6&file=2.jpg
Drafting is one of the worst workbenches when recording macros...I never used r19 but in r18 ou could search a text string even inside the ditto, that's why you could use a macro to search and modify the text string.

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

 
As long as it is possible to edit manually those text fields , i assume that it is possible by coding too.

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.
 
If you first Explode the 2D Component Instance, you can modify its elements.

So, i guess:
For Each Sheet
Explode background Elements
find text note in background
change text note's text​
Next Sheet
 
Faudrait peu etre contacter Renault pour savoir comment travailler avec les dessins...

Eric N.
indocti discant et ament meminisse periti
 
If it is not exploded, I do not think it is possible to modify its objects.
 
It can be done !

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 Sub

Adapt the code to your needs.

 
 http://files.engineering.com/getfile.aspx?folder=f5f73e76-9c52-404e-a049-713744798a83&file=Picture.png
I have asked someone at work who has experience in vb for catia and making macros and told me that the table is a 'vigniette' (french term) , or a 'editable detail' and it can be modified by macro (as long as it is possible to edit it manually by double clicking the text fields end edit them).Unfortunatly he didnt want to tel me more , just search for it in catia help. I did search for it and didnt find anything alike :(
 
Alex thank you. Now i left from work and heading home.I will try your script and come back with a feedback.

Regards
 
Hi,

Excellent idea Alex, star from me.

Cozmin, iata codul tau (here is your code) , of course it can be improved :)

Code:
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 Sub

Eric, j'étais presque sûr que Cozmin ne sera pas obtenir une réponse rapide


Regards
Fernando

 
Your code included in a For loop , is doing right what i needed.It's changing those text fields on every CatDrawing that is opened.
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top