Continue to Site

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!

[Macro CATIA] change cut view text

Status
Not open for further replies.

sigmacoder

Mechanical
Mar 16, 2013
30
MA
Hi,

I'm currently working with CATIA V5, and i want to use Macros (VBA), but i have some problems!

My question is: how to change the text of a cut view? (see the picture)


i tried to use : myView.Texts.item(1) to access to this "text" but i think that CATIA dont consider it as text...



Thanks for your help,
 
Replies continue below

Recommended for you

hi ferdo,

my question is clear ... if it is a drawing text, why can't find it in the texts collection? this is my code:
Code:
Sub CATMain()
Set drawingDocument1 = CATIA.ActiveDocument
Set drawingSheets1 = drawingDocument1.Sheets
Set drawingSheet1 = drawingSheets1.Item(1)
Set drawingViews1 = drawingSheet1.Views
Set drawingView1 = drawingViews1.Item(3)
Set drawingTexts1 = drawingView1.Texts
MsgBox drawingComponents1.Count
End Sub

that return 0, so the texts collection is empty ... if it's a drawing text , the collection shouldn't be empty, i should find it in this collection.

thank you!
 
Did you searched in v5automation file what it means drawingComponents ?

Bellow is a code which is searching texts in all your drawing, see what you can get.

Code:
Language="VBSCRIPT"

Sub CATMain()

Dim drawingDocument1 As Document
Set drawingDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = drawingDocument1.Selection

selection1.Search "CATDrwSearch.DrwText,all"

For i = 1 to selection1.Count
MsgBox selection1.Item(i).Value.Text
Next

End Sub

Regards
Fernando

 
collection.item(x).value will return the object in the collection

Eric N.
indocti discant et ament meminisse periti
 
thank you ferdo, i didnt see your answer ... it's a smart solution, but :
selection1.Search "CATDrwSearch.DrwText,all"

will search in all the drawing document so it will consum lot of memory ... can i search just in the active view ? how can i do that?
 
Of course you can, just ask user to select a view, make it active in code, then use same code but instead of using

selection1.Search "CATDrwSearch.DrwText,all"
you can use
selection1.Search "CATDrwSearch.DrwText,sel"

or you can use the name of the view (if is a constant) then use same technique. The idea is to make first the selection...

Here is something which you can use also.

Regards
Fernando

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top