recording errors in API generated Parts

Programming and macros
m2shell
Posts: 133
Joined: Mon Jun 28, 2021 2:07 pm
Answers: 0
Location: Brooklyn NY
x 121
x 56

recording errors in API generated Parts

Unread post by m2shell »

Hola all

I'm putting together a macro that takes excel data and creates parts from a library of templates.

For the most part things are working, but I'd like to expand the error reporting somehow. I am logging errors I can predict (zero conditions, template not found, etc), but I'd like to be able to record & report errors that Solidworks has during modeling and drawing phases. I know there are a few conditions where the part gets made but for instance a sketch will have an error because of a dimension problem but the Part will save fine. But I'd like to know about those errors sooner rather than later because they mean bad input data that I don't currently have a filter for.

Parts are created with the swApp.NewDocument method using a Template name variable.

I'm not even sure what to search for in the API reference for modeling error flags. Any help would be appreciated in this!

Thanks

M
User avatar
JSculley
Posts: 606
Joined: Tue May 04, 2021 7:28 am
Answers: 55
x 8
x 837

Re: recording errors in API generated Parts

Unread post by JSculley »

See Feature::GetErrorCode2 in the API help.
m2shell
Posts: 133
Joined: Mon Jun 28, 2021 2:07 pm
Answers: 0
Location: Brooklyn NY
x 121
x 56

Re: recording errors in API generated Parts

Unread post by m2shell »

JSculley wrote: Fri Jun 14, 2024 9:42 am See Feature::GetErrorCode2 in the API help.
Okay cool, so for each generated part I'd go through all the features in the tree to check for errors using GetErrorCode2
Let me give it at try!

Thanks!
User avatar
AlexB
Posts: 459
Joined: Thu Mar 18, 2021 1:38 pm
Answers: 25
x 249
x 406

Re: recording errors in API generated Parts

Unread post by AlexB »

Additionally, you can access the "What's Wrong" dialog information by using IModelDocExtension.GetWhatsWrong(). It will output an array of problematic features, and array of error codes, and an array of warnings.
https://help.solidworks.com/2023/englis ... Wrong.html

I have this running in one of my apps to check for rebuild errors.
image.png
image.png (6.52 KiB) Viewed 190 times
Compared to the SW window:
image.png
Post Reply