Design Automation: Получение подробностей об ошибках построения моделей Inventor
При выполнении ряда операций с моделью Inventor-а могут возникать ошибки моделирования. Их легко увидеть при работе с десктопной версией приложения, однако в случае выполнения тех же действий на сервере Design Automation, где отсутствует пользовательский интерфейс, отследить, что же именно пошло не так, несколько сложнее.
В Inventor есть сущность Error Manager, которая также отображает сообщения в пользовательском интерфейсе десктопного приложения:
Используя объект ErrorManager в InventorAPI Вы можете получить доступ к этой информации. Это поможет быстрее разобраться в проблемах при обновлении модели и позволит предоставить информацию пользователю в случае, если что-то пошло не так.
В качестве примера у меня есть WorkItem, принимающий документ ipt и параметр "height", задающий высоту выдавливания. Код, выполняемый сервером, устанавливает значение высоты равное нулю и выводит информацию, полученную из объекта ErrorManager
- public void RunWithArguments(Document doc, NameValueMap map)
- {
- var em = inventorApplication.ErrorManager;
- LogTrace($"Checking ErrorManager before problem");
- LogTrace($"HasErrors = {em.HasErrors}");
- LogTrace($"HasWarnings = {em.HasWarnings}");
- LogTrace($"AllMessages = {em.AllMessages}");
- PartDocument pd = doc as PartDocument;
- pd.ComponentDefinition.Parameters["height"].Expression = "0";
- pd.Update2();
- LogTrace($"Checking ErrorManager after problem");
- LogTrace($"HasErrors = {em.HasErrors}");
- LogTrace($"HasWarnings = {em.HasWarnings}");
- LogTrace($"AllMessages = {em.AllMessages}");
- }
В отчёте выполнения WorkItem мы увидим:
- [06/15/2020 10:34:06] InventorCoreConsole.exe Information: 0 : RunWithArguments called
- [06/15/2020 10:34:06] InventorCoreConsole.exe Information: 0 : Checking ErrorManager before problem
- [06/15/2020 10:34:06] InventorCoreConsole.exe Information: 0 : HasErrors = False
- [06/15/2020 10:34:06] InventorCoreConsole.exe Information: 0 : HasWarnings = False
- [06/15/2020 10:34:06] InventorCoreConsole.exe Information: 0 : AllMessages = <ErrorsAndWarnings/>
- [06/15/2020 10:34:07] InventorCoreConsole.exe Information: 0 : Checking ErrorManager after problem
- [06/15/2020 10:34:07] InventorCoreConsole.exe Information: 0 : HasErrors = False
- [06/15/2020 10:34:07] InventorCoreConsole.exe Information: 0 : HasWarnings = True
- [06/15/2020 10:34:07] InventorCoreConsole.exe Information: 0 : AllMessages = <ErrorsAndWarnings><Warning Message="HiddenBox.ipt: Errors occurred during update"><Error Message="Extrusion1: Could not build this Extrusion"><Error Message="Extrusion distance is zero. Use Edit Extruded Feature to change the extrusion distance."/></Error></Warning></ErrorsAndWarnings>
- [06/15/2020 10:34:07] InventorCoreConsole.exe Warning: 0 : Inventor message: HiddenBox.ipt: Errors occurred during update
- [06/15/2020 10:34:07] InventorCoreConsole.exe Warning: 0 : Inventor inner xml: <Error Message="Extrusion1: Could not build this Extrusion"><Error Message="Extrusion distance is zero. Use Edit Extruded Feature to change the extrusion distance." /></Error>
Источник: https://forge.autodesk.com/blog/get-modeling-error-details-inventor
Опубликовано 26.06.2020