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

Something to start ...

Code:
Sub Change_NameID()
   

   Dim oDrawing As DrawingDocument
    Set oDrawing = CATIA.ActiveDocument
    
    Dim oSheets As DrawingSheets
    Set oSheets = oDrawing.Sheets
    
    Dim oSheet As DrawingSheet
    Set oSheet = oSheets.Item(1)
    
    Dim oView As DrawingView
    Set oView = oSheet.Views.Item(4) 'Put The Section view item number
    oView.Activate
    
   oView.SetViewName "Section view ", "B", ""



       End Sub
 
Hi AlexLozoya,

thanks for your answer, but i need to change the value of text which indicates the source of cut view ( you can see the picture ... )

[ponder] can someone help me to resolvre this problem?
 
Code:
oView.SetViewName "", "B", "" ' <----- just change the letter "B" with the letter of your choice..
 
thanks for your answer ferdo...
but if i double clic on this text i can change it without affecting the cut view name ... and i want to do that with a macro ... i hope that you understand what i mean...
 
AlexLozoya: i want to change the value of this text without changing the name of the cut view ... manually it's possible ... but with macro i dont know how ...
 
Hi,

Technically speaking, that text and name of the view should be connected (you know, paper can support anything...). If you will modify only the text it will be linked to what (suppose you want to change A with B for example) ? Who will see the drawing will look to what view (B-B if existing) ? Or is something bit more specific ?

Still, if you want to do it in macro, your mark-up is a text, you can tell to user to select the text and in macro, in selection, you can replace old text with new one.

Regards
Fernando

 
if the user select this "text" ... catia dont consider it as text ... so you can't change it ... this is the problem ...

i dont believe that we can't make this simple task with CATIA VBA ... it's sad ...
 
Hi,

First select the text like in your mark-up, then run this CATScript

Code:
Language="VBSCRIPT"

Sub CATMain()

Dim myString 'As Double
myString = "ENTER TEXT"
myString = InputBox ("Please enter the text", myString, "What ever you want")

Set drawingDocument1 = CATIA.ActiveDocument
Set selection1 = drawingDocument1.Selection

selection1.Item(1).Value.Text = myString

End Sub

Regards
Fernando

 
Thanks Fernando, your code work perfectly ...

I can change this text with this method, but my objectif is to do that without the intervention of the user ... i dont know why catia dont consider it as text, so i can access to it with texts collection ...

anyone can help me ?
 
If i use this code with my drawing ( ) :

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 drawingComponents1 = drawingView1.Texts
MsgBox drawingComponents1.Count
End Sub

why the result is 0? it's confusing [mad]

[machinegun] CATIA
 

i created this "text" by creating a cut view ... we can't know the type of this object ?
 
[3eyes] it's a strange problem ... for me in this case textsCollection.count return 0!

 
if it's a drawing text ... why we can't found it in texts collection ?
 
Hi,

I saw your question on stackoverflow, ...if you want an answer, you have to explain very clear the whole scenario, put your code here (as much as you can, to understand what you want to do) and only after that we can help you more.

Anyway, definitely that letter A is a drawing text, as is shown in second attachment picture, the query was search a drafting text string (letter A). If you want to change without user intervention, you have to find a method to replace that string with another one defined in code by you (eventually using search function).



Regards
Fernando

 
drawingView1 = drawingViews1.Item(3).value ?


Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top