Drawing formatting gets scattered while applying UI parameters after loading drawing (Creo Toolkit)
Hi everyone,
I am facing an issue in my Creo Toolkit application and would appreciate any suggestions.
Workflow
- I launch my Toolkit application.
- A UI dialog is displayed where the user enters the required drawing parameters.
- When the user clicks the Apply button, the drawing is loaded using ProMdlFiletypeLoad().
- I then apply a drawing setup (.dtl) file using ProInputFileRead().
- The model parameters are updated.
- The model and drawing are regenerated.
Problem
When the drawing is first loaded, it appears correctly with the expected formatting and DTL settings.
However, as soon as the parameter update/regeneration begins, the drawing temporarily becomes scattered. Dimensions, tables, notes, and other annotations move from their correct locations, almost as if the drawing is momentarily using a different unit system (for example, inches instead of millimeters).
I would like to prevent the user from seeing this intermediate scattered state.
My questions
- Is this expected behavior when loading a drawing and then updating model parameters through Creo Toolkit?
- Is there a recommended sequence of Toolkit API calls to avoid this intermediate display?
- Should the drawing remain hidden until after parameter updates and regeneration are complete?
- Is there a way to regenerate the drawing completely before it is displayed to the user?
Below is my ApplyAction() function that implements this workflow.
// ApplyAction() implementation
Any guidance would be greatly appreciated. Thank you!
void ApplyAction(char* dialog, char* component, ProAppData app_data)
{
HandClearanceUiState* state = (HandClearanceUiState*)app_data;
if (state == NULL)
{
return;
}
state->pending_params.clear();
//----------------------------------------------------------------------
// Read UI values
//----------------------------------------------------------------------
ProError status = LoadCalibreFromDialog(dialog, state);
if (status != PRO_TK_NO_ERROR)
{
visit_items::log_info("Apply skipped because calibre is invalid.");
return;
}
status = ReadManualInputsFromDialog(dialog, state);
if (status != PRO_TK_NO_ERROR)
{
visit_items::log_info("Apply skipped because manual UI input could not be read.");
return;
}
status = UpdateAutoOdInputs(dialog, state);
if (status != PRO_TK_NO_ERROR)
{
visit_items::log_info("Apply skipped because auto OD values could not be calculated.");
return;
}
//----------------------------------------------------------------------
// Load drawing only once
//----------------------------------------------------------------------
if (state->drawing == NULL)
{
ProMdl drawing_mdl = NULL;
status = ProMdlFiletypeLoad(
L"D:\\CREO_TOOLKIT_CODE\\automation_day_three\\3H_master_model_2298XXE_caliber_2305\\hands_clearence_3h.drw",
PRO_MDLFILE_DRAWING,
PRO_B_FALSE,
&drawing_mdl);
state->drawing = (ProDrawing)drawing_mdl;
// Load the DTL file into the drawing
ProDirectoryChange(
L"D:\\CREO_TOOLKIT_CODE\\automation_day_three\\hand_clearence_poc\\text");
status = ProInputFileRead(
NULL,
L"D:\\CREO_TOOLKIT_CODE\\automation_day_three\\hand_clearence_poc\\config.pro",
PRO_CONFIG_FILE,
NULL, NULL, NULL, NULL);
visit_items::CheckError(status, "ProInputFileRead config.pro");
status = ProInputFileRead(
state->drawing,
L"drawing_setting.dtl",
PRO_DWG_SETUP_FILE,
NULL, NULL, NULL, NULL);
visit_items::CheckError(status, "ProInputFileRead dtl");
// Display drawing
status = ProMdlDisplay(state->drawing);
visit_items::CheckError(status, "ProMdlDisplay");
if (status != PRO_TK_NO_ERROR)
{
state->last_error = status;
return;
}
state->drawing = (ProDrawing)drawing_mdl;
int window;
if (ProMdlWindowGet(drawing_mdl, &window) == PRO_TK_NO_ERROR)
{
ProWindowActivate(window);
}
ProWindowRepaint(PRO_VALUE_UNUSED);
// Get the model referenced by the drawing
status = ProDrawingCurrentsolidGet(
state->drawing,
&state->solid);
visit_items::CheckError(status, "ProDrawingCurrentsolidGet");
if (status != PRO_TK_NO_ERROR)
{
state->last_error = status;
return;
}
}
//----------------------------------------------------------------------
// Update parameters
//----------------------------------------------------------------------
status = UpdateCreoParameters(
state->solid,
state->pending_params);
if (status != PRO_TK_NO_ERROR)
{
state->last_error = status;
return;
}
//----------------------------------------------------------------------
// Regenerate
//----------------------------------------------------------------------
status = visit_items::RegenerateDrawingAndRepaint(
state->drawing,
state->solid);
state->last_error = status;
if (status != PRO_TK_NO_ERROR)
{
return;
}
//----------------------------------------------------------------------
// Update drawing
//----------------------------------------------------------------------
std::wstring report = ClearanceErrors(state->pending_params);
hand_clearance_ui::FillDrwTables(state->drawing);
hand_clearance_ui::AutoSacleFitDrawing(state->drawing);
DimensionPosition(state->drawing);
//----------------------------------------------------------------------
// Apply drawing text rule
//----------------------------------------------------------------------
status = HandleHandOverVgp(dialog, state);
state->last_error = status;
}

