Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

CATIA VBA Sudden crash

Status
Not open for further replies.

Mech0T1

Automotive
May 11, 2021
2
0
0
CA
Hi, absolutely first time here and first post. Pardon me if I mess up some protocol.

For years I've used some macros in CATIA V5 to change the background colour. I use white, black, and blue backgrounds, with a toggle for the screen fade. This is simply much quicker than going Tools -> Options -> Visualization, etc.

They've worked fine for years, now they're suddenly crashing. The code is below. The line that is crashing is "Dim visualizationSettingAtt1 As VisualizationSettingAtt", as it says "User-defined type is not defined". This implies CATIA removed a previously-existing data type. Obviously my first go-to was the macro recorder, which I ran, which generated the exact same code! Meaning, even macro recorder-generated code crashes. How is this even possible?

Any thoughts?


Code:
Sub CATMain()

Dim settingControllers1 As SettingControllers
Set settingControllers1 = CATIA.SettingControllers

Dim visualizationSettingAtt1 As VisualizationSettingAtt  'This line crashes
Set visualizationSettingAtt1 = settingControllers1.Item("CATVizVisualizationSettingCtrl")

Dim double1 As Double
double1 = visualizationSettingAtt1.AntiAliasingOffset

visualizationSettingAtt1.SetBackgroundRGB 0, 0, 0

visualizationSettingAtt1.SaveRepository

End Sub

Edit : Probably should include.... CATIA V5-6R. Build day 08-26-2020.11.00. Service pack 4, Build Number 28, Hot Fix 65. This macro worked until the last week or two.
Edit 2 : Lol, apparently "Dim tmpDWGFile As DrawingDocument" no longer works either, same error. Seems like almost all of my macros are now broken.
 
Replies continue below

Recommended for you

Sorry MechOT1... it runs on my system. both as a CATScript, and from VBA.
what if you try to get rid of the "as VisualizationSettingAtt", i.e only "Dim visualizationSettingAtt1" ?...

regards,
LWolf
 
Hello LWolf, thank you for the quick reply.

I had the same idea - I tried "as variant" yesterday and no worky. When I tried now just doing "Dim vis..." without the "as vis...." I get "Class does not support Automation or does not support expected interface" on an EARLIER line (line 2, "Set settingControllers1 = CATIA.SettingControllers") which seems even more strange. I really wonder if some kind of reference has been removed, and I cannot possibly guess which one as there are like a hundred different references for CATIA objects in the References list.

I've asked our IT guys to look at it, hopefully they can come up with something. Thank you very much for checking that it works for you, lol, like I said they've worked for me for years until recently.

Just curious, are you running the same version of CATIA or something older? I really don't know if CATIA versions are harmonized everywhere (kinda like Windows versions) or if it's up to the customer to update as they see fit.
 
same release, your HF is higher :)
in CATIA VBA, look in Tools-References, see if any have exclamation marks on... if so, then tick those off. but only those

regards,
LWolf
 
MechOT1

You could try removing all the existing References and then re-adding them
I had a similar odd set of errors only on Products & Strings
But this seemed to work
 
Status
Not open for further replies.
Back
Top