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
form

and the code inside the form
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
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
Most of time you work with an item in the selection object, you need to use .Value at the end...
CODE --> vba
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
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 ifRE: macro causing catia to terminate
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
RE: macro causing catia to terminate
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