<class 'Part.OCCError'> how to reset wihout restarting FreeCAD?

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
mariwan
Posts: 469
Joined: Wed Jan 06, 2021 2:00 pm

<class 'Part.OCCError'> how to reset wihout restarting FreeCAD?

Post by mariwan »

Is there a way to reset the error you get in OCC without the need of closing and restarting FreeCAD?
I would like to reset the OCC if something bad happens which is not abnormal for Direct Modeling or Fillet, Chamfer.
If we don't have that, is it possible to achieve?
Thanks.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: <class 'Part.OCCError'> how to reset wihout restarting FreeCAD?

Post by TheMarkster »

You mean when FreeCAD hangs during an OCCT operation? Only 2 ways I know: 1) wait it out and hope it eventually finishes; 2) force close and restart. If you are fortunate and an autorecovery file has been recently saved you can usually recover your work. Save and save often. It could be useful if the autorecovery could be triggered from python, but I don't think it can, I think it is on a timer. Then you could trigger the save before doing something that is known to sometimes crash, like making a fillet.
User avatar
mariwan
Posts: 469
Joined: Wed Jan 06, 2021 2:00 pm

Re: <class 'Part.OCCError'> how to reset wihout restarting FreeCAD?

Post by mariwan »

Actually not,
When you run test code and develop something .. or even as you mentioned after an operation .. is there a way to reset the OCC engine without a hard restart .. I men maybe you unload-reload OCC?
is there any API for that?
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: <class 'Part.OCCError'> how to reset wihout restarting FreeCAD?

Post by TheMarkster »

I see. I don't know of a way, but there might be one. Why would this be needed? Do you have a simple example of when this would be useful?

Edit: Okay, I think I see now. You want to reset the error code.
User avatar
mariwan
Posts: 469
Joined: Wed Jan 06, 2021 2:00 pm

Re: <class 'Part.OCCError'> how to reset wihout restarting FreeCAD?

Post by mariwan »

During my development, I restart FreeCAD maybe hundred times due to different things. :?
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: <class 'Part.OCCError'> how to reset wihout restarting FreeCAD?

Post by TheMarkster »

mariwan wrote: Sun Dec 05, 2021 9:12 pm During my development, I restart FreeCAD maybe hundred times due to different things. :?
Yes, with imported files in a workbench you must restart. There is an option to get around this:

Code: Select all

import importlib
import yourmodule #yourmodule.py
importlib.reload(yourmodule) #reloads when yourmodule.py changes without need to restart
I have not used this much, so I don't know how well it works in all situations. I don't think you want in your release code, only while developing to speed things up some.
Post Reply