×
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 causing catia to terminate

macro causing catia to terminate

macro causing catia to terminate

(OP)
seems to be pretty easy code. got no errors. but something causing catia to terminate. any ideas?
can do that using titleblock macro but i want a little bit of customization using user form window.

main code

CODE --> vba

Sub CATMain()
    ChangeRoughnessValue.Show (0)
End Sub 

form


and the code inside the form

CODE --> vba

Private Sub ChangeRoughness_Click()

Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument
Dim selection1 As selection
Set selection1 = drawingDocument1.selection
'----SEARCH FOR A TEXT---
selection1.Search "Name=*TitleBlock_Text_125,all"
'---END OF SEARCH---

If CheckAAA.Value = True Then
            selection1.Item(1).Text = "1234"
        End If
    
    'End If
End Sub

Private Sub CheckAAA_Click()

End Sub 

RE: macro causing catia to terminate

If you are in the vba editor, you can press f8 key to go through your code line by line. The line that is highlighted has Not been executed yet. If you have several sub routines that are waiting for button clicks, you need to put stops in the beginning of those subs(click left margin in vba editor) so you can continue to use f8 key when you get into the other subs.

Name your buttons so others can look at the code and tell what they are and what they are for for...I don't know what checkAAA does. Is it a checkbox? I would also continue to use the same variable name you have used before to make integrating codes easier for you...Google Hungarian notation, at least that is the variable naming style I like.

I would get rid of the CheckAAA_Click event, you can right click on you form and pick view code instead of double clicking features to get to it.

A good practice is to clear your selection before adding to it because you don't know what the user has picked.

CODE --> vba

Selection1.clear 

Most of time you work with an item in the selection object, you need to use .Value at the end...

CODE --> vba

selection1.item(1).value.text 

I think it would be better to set a variable with item type for the text object so you can get intellisense to help you. I haven't done much with drawings so you will need to look for that information.

Try using ...

CODE --> vba

Text.Text = "1234 
"

You should also check to see if there is something in the selection before changing it

CODE --> vba

If selection1.count <> 0 then
     'Do something to it
Else
     'Don't do anything because you may get an error
End if 

RE: macro causing catia to terminate

Hi,

Some commands which you can use from PowerInput very nice and easy are marked like permanent restriction in programming, in v5 or v6. An example is CATIA.StartCommand "FrmActivate" (in both CATIA versions) . As a consequence you will get an click ok to terminate (or just CATIA hanging for ever...). Maybe this is your case. Check this issue with your CATIA support/vendor.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU

RE: macro causing catia to terminate

Macro causing CATIA to terminate? That's my fetish!

RE: macro causing catia to terminate

(OP)
yes causing and it's definitely not these lines

Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument
Dim selection1 As selection
Set selection1 = drawingDocument1.selection

i'm truing to replace some text that were created by titleblock macro. i don't believe this may be a problem.

RE: macro causing catia to terminate

(OP)
so the problem was V5R52 SP2. with sp3 everything is running ok. also deletion of a text thru vb will cause r25 sp2 to terminate.

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