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

Status
Not open for further replies.

JeniaL

Mechanical
Jun 3, 2014
547
IL
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:
Sub CATMain()
    ChangeRoughnessValue.Show (0)
End Sub

form
download.aspx


and the code inside the form
Code:
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
 
Replies continue below

Recommended for you

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:
Selection1.clear

Most of time you work with an item in the selection object, you need to use .Value at the end...
Code:
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:
Text.Text = "1234
"

You should also check to see if there is something in the selection before changing it
Code:
If selection1.count <> 0 then
     'Do something to it
Else
     'Don't do anything because you may get an error
End if

 
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

- Romania
- EU
 
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.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top