×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

[Macro CATIA] change cut view text

[Macro CATIA] change cut view text

[Macro CATIA] change cut view text

(OP)
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)

http://www.hostingpics.net/viewer.php?id=65419615c...

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,

RE: [Macro CATIA] change cut view text

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 

RE: [Macro CATIA] change cut view text

(OP)
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?

RE: [Macro CATIA] change cut view text

CODE -->

oView.SetViewName "", "B", "" ' <----- just change the letter "B" with the letter of your choice.. 

RE: [Macro CATIA] change cut view text

(OP)
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...

RE: [Macro CATIA] change cut view text

(OP)
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 ...

RE: [Macro CATIA] change cut view text

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: [Macro CATIA] change cut view text

(OP)
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 ...

RE: [Macro CATIA] change cut view text

Hi,

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

CODE --> CATScript

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: [Macro CATIA] change cut view text

(OP)
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 ?

RE: [Macro CATIA] change cut view text

(OP)
If i use this code with my drawing ( http://www.hostingpics.net/viewer.php?id=65419615c... ) :

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

RE: [Macro CATIA] change cut view text

(OP)

i created this "text" by creating a cut view ... we can't know the type of this object ?

RE: [Macro CATIA] change cut view text

Hi,

You have two pictures attached, both of them is showing same thing, that letter A is a text. First picture a used a macro to determine what is the selected element and second is by searching in CATIA text string case sensitive A .

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: [Macro CATIA] change cut view text

(OP)
3eyes it's a strange problem ... for me in this case textsCollection.count return 0!

RE: [Macro CATIA] change cut view text

(OP)
if it's a drawing text ... why we can't found it in texts collection ?

RE: [Macro CATIA] change cut view text

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: [Macro CATIA] change cut view text

drawingView1 = drawingViews1.Item(3).value ?

Eric N.
indocti discant et ament meminisse periti

RE: [Macro CATIA] change cut view text

(OP)
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!

RE: [Macro CATIA] change cut view text

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 --> CATScript

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: [Macro CATIA] change cut view text

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

Eric N.
indocti discant et ament meminisse periti

RE: [Macro CATIA] change cut view text

(OP)
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?

RE: [Macro CATIA] change cut view text

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: [Macro CATIA] change cut view text

(OP)
thank you again ferdo, it works!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources