Page 1 of 1

recording errors in API generated Parts

Posted: Fri Jun 14, 2024 7:54 am
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

Re: recording errors in API generated Parts

Posted: Fri Jun 14, 2024 9:42 am
by JSculley
See Feature::GetErrorCode2 in the API help.

Re: recording errors in API generated Parts

Posted: Fri Jun 14, 2024 9:47 am
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!

Re: recording errors in API generated Parts

Posted: Fri Jun 14, 2024 9:58 am
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 944 times
Compared to the SW window:
image.png

Re: recording errors in API generated Parts

Posted: Mon Jul 15, 2024 8:53 am
by m2shell
Thanks all for the replies on this. I haven't had a chance to try implementing these ideas yet, but I appreciate the input. Will follow up when I get up for some air.

M