def getPathToSketchConstraintsFinder():
ai_engine_path = os.environ.get('SHAPER_SKETCH_CONSTRAINT_SUGGESTION_AI')
if not ai_engine_path:
- print('SHAPER_SKETCH_CONSTRAINT_SUGGESTION_AI variable is not set')
+ EventsAPI.Events_InfoMessage('Error', 'Error: SHAPER_SKETCH_CONSTRAINT_SUGGESTION_AI variable is not set').send()
return None
- print(ai_engine_path)
if not os.path.isfile(ai_engine_path):
- print('{} is not a file'.format(ai_engine_path))
+ EventsAPI.Events_InfoMessage('Error', 'Error: {} is not a file'.format(ai_engine_path)).send()
return None
file_extension = pathlib.Path(ai_engine_path).suffix
if file_extension == '.py' or file_extension == '.pyc':
return ai_engine_path
else:
- print('{} is not a python file'.format(ai_engine_path))
- pass
+ EventsAPI.Events_InfoMessage('Error', 'Error: {} is not a python file'.format(ai_engine_path)).send()
+ return None
return None
def getSketchConstraintsFinder():
ai_engine_path = getPathToSketchConstraintsFinder()
if not ai_engine_path:
- return
+ return None
p = pathlib.Path(ai_engine_path)
ai_engine_name = p.stem
ai_spec.loader.exec_module(ai_engine)
if not hasattr(ai_engine, 'AIEngine'):
- print('There is no AIEngine in {}'.format(ai_engine_path))
- return
+ EventsAPI.Events_InfoMessage('Error', 'Error: There is no AIEngine class in {}'.format(ai_engine_path)).send()
+ return None
ai_class_inst = getattr(ai_engine, 'AIEngine')()
+
+ predict_op = getattr(ai_class_inst, "Predict", None)
+ if not callable(predict_op):
+ EventsAPI.Events_InfoMessage('Error', 'Error: There is no Predict method in AIEngine in {}'.format(ai_engine_path)).send()
+ return None
+
return ai_class_inst
## Method to create error message
aMsg->setState(SketchPlugin_Offset::ID(), aHasSketchPlane);
// SketchRectangle is a python feature, so its ID is passed just as a string
aMsg->setState("SketchRectangle", aHasSketchPlane);
+
// SuggestConstraints is a python feature, so its ID is passed just as a string
- aMsg->setState("SuggestConstraints", aHasSketchPlane);
+ char* aConstraintsFinder = getenv("SHAPER_SKETCH_CONSTRAINT_SUGGESTION_AI");
+ aMsg->setState("SuggestConstraints", aHasSketchPlane && aConstraintsFinder && *aConstraintsFinder);
}
}
return aMsg;