Skip to main content
11-Garnet
May 6, 2026
Solved

Fail to get the Datum Plane handle using ProModelItemInit or ProModelItemByNameInit

  • May 6, 2026
  • 2 replies
  • 47 views

Hi, I am trying to get the datum plane handle (FRONT plane) use ProModelItemInit or ProModelItemByNameInit but it is failing.
the reason is I want to use ProSelectionAlloc

Can some one please help me with it.

 

Thank you.

 

Best answer by VP_14440689
// this is the function that I created to get the return as ProSelection plane_sel and Datum plane ID (note it doenst give feature ID it gives datum plane ID).

// this we can use it in the API where we want ProSelection as datum plane or int plane id.

// for theory read the API docs for datum plane, in short they are treated as PRO_SURFACE in the CREO.

// here's the function
ProError err = GetPlaneSelectionFromFeatureID(drw_solid_mdl, 1, &plane_sel, &plane_surface_id);


//------------------------------------------------------------------------------------------------------------
// START OF PLANE SURFACE ACTION FUNCTION

static ProError PlaneSurfaceAction(ProGeomitem* p_handle, ProError status, ProAppData app_data) {

//---------------------------------------------------------
// Skip inactive geometry
//---------------------------------------------------------

ProBoolean inactive;
status = ProGeomitemIsInactive(p_handle, &inactive);

if (status != PRO_TK_NO_ERROR)
return PRO_TK_NO_ERROR;

if (inactive == PRO_B_TRUE)
return PRO_TK_NO_ERROR;

//---------------------------------------------------------
// Output selection
//---------------------------------------------------------

ProSelection* out_sel = (ProSelection*)app_data;


//---------------------------------------------------------
// Create selection
//---------------------------------------------------------

status = ProSelectionAlloc(NULL, (ProModelitem*)p_handle, out_sel);

if (status == PRO_TK_NO_ERROR)
{
logger::log_info("Plane selection allocated.");

return PRO_TK_USER_ABORT;
}

return PRO_TK_NO_ERROR;
}


ProError GetPlaneSelectionFromFeatureID(ProSolid solid, int feature_id, ProSelection* out_selection, int* out_surface_id) {


//---------------------------------------------------------
// Init feature
//---------------------------------------------------------

ProFeature plane_feat;

ProError err = ProFeatureInit(solid, feature_id, &plane_feat);

error_utils::CheckError(err, "ProFeatureInit");

if (err != PRO_TK_NO_ERROR)
return err;

//---------------------------------------------------------
// Temp data structure
//---------------------------------------------------------

struct PlaneData
{
ProSelection* selection;
int* surface_id;
};

PlaneData data;
data.selection = out_selection;
data.surface_id = out_surface_id;

//---------------------------------------------------------
// Visitor
//---------------------------------------------------------

auto PlaneSurfaceAction = [](ProGeomitem* p_handle, ProError status, ProAppData app_data) -> ProError

{

//-----------------------------------------------------
// Access data
//-----------------------------------------------------

PlaneData* data = (PlaneData*)app_data;

//-----------------------------------------------------
// Skip inactive
//-----------------------------------------------------

ProBoolean inactive;

status = ProGeomitemIsInactive(p_handle, &inactive);

if (status != PRO_TK_NO_ERROR)
return PRO_TK_NO_ERROR;

if (inactive == PRO_B_TRUE)
return PRO_TK_NO_ERROR;

//-----------------------------------------------------
// Surface
//-----------------------------------------------------

ProSurface surface;
status = ProGeomitemToSurface(p_handle, &surface);

if (status != PRO_TK_NO_ERROR)
{
return PRO_TK_NO_ERROR;
}

//-----------------------------------------------------
// Get surface ID
//-----------------------------------------------------

status = ProSurfaceIdGet(surface, data->surface_id);

if (status == PRO_TK_NO_ERROR)
{
logger::log_info("Plane surface ID: " + std::to_string(*(data->surface_id)));

}

//-----------------------------------------------------
// Create selection
//-----------------------------------------------------

status = ProSelectionAlloc(NULL, (ProModelitem*)p_handle, data->selection);

if (status == PRO_TK_NO_ERROR)
{
logger::log_info("Plane selection allocated.");

return PRO_TK_USER_ABORT;
}

return PRO_TK_NO_ERROR;
};

//---------------------------------------------------------
// Visit geometry
//---------------------------------------------------------

err = ProFeatureGeomitemVisit(&plane_feat, PRO_SURFACE, PlaneSurfaceAction, NULL, &data);

if (err != PRO_TK_USER_ABORT &&
err != PRO_TK_NO_ERROR)
{
return err;
}

if (*out_selection == NULL)
{
return PRO_TK_E_NOT_FOUND;
}

logger::log_info("Plane selection + surface ID created.");

return PRO_TK_NO_ERROR;
}

// END OF PLANE SURFACE ACTION FUNCTION
//------------------------------------------------------------------------------------------------------------

 

2 replies

Community Moderator
May 12, 2026

Hello VP_14440689,
 

 

Thank you for your question. 

Your post {Fail to get the Datum Plane handle using ProModelItemInit or ProModelItemByNameInit | Community} has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.

Also, feel free to add any additional information you think might be relevant. It sometimes helps to have screenshots to better understand what you are trying to do.

Thanks,
Vivek N
Community Moderation Team

11-Garnet
May 12, 2026

I got the solution...@vnamboodheri, thanks for the message

 

Dale_Rosema
23-Emerald III
23-Emerald III
May 12, 2026

Can you post how you got the solution for someone who reads this post in the future?

VP_1444068911-GarnetAuthorAnswer
11-Garnet
May 13, 2026
// this is the function that I created to get the return as ProSelection plane_sel and Datum plane ID (note it doenst give feature ID it gives datum plane ID).

// this we can use it in the API where we want ProSelection as datum plane or int plane id.

// for theory read the API docs for datum plane, in short they are treated as PRO_SURFACE in the CREO.

// here's the function
ProError err = GetPlaneSelectionFromFeatureID(drw_solid_mdl, 1, &plane_sel, &plane_surface_id);


//------------------------------------------------------------------------------------------------------------
// START OF PLANE SURFACE ACTION FUNCTION

static ProError PlaneSurfaceAction(ProGeomitem* p_handle, ProError status, ProAppData app_data) {

//---------------------------------------------------------
// Skip inactive geometry
//---------------------------------------------------------

ProBoolean inactive;
status = ProGeomitemIsInactive(p_handle, &inactive);

if (status != PRO_TK_NO_ERROR)
return PRO_TK_NO_ERROR;

if (inactive == PRO_B_TRUE)
return PRO_TK_NO_ERROR;

//---------------------------------------------------------
// Output selection
//---------------------------------------------------------

ProSelection* out_sel = (ProSelection*)app_data;


//---------------------------------------------------------
// Create selection
//---------------------------------------------------------

status = ProSelectionAlloc(NULL, (ProModelitem*)p_handle, out_sel);

if (status == PRO_TK_NO_ERROR)
{
logger::log_info("Plane selection allocated.");

return PRO_TK_USER_ABORT;
}

return PRO_TK_NO_ERROR;
}


ProError GetPlaneSelectionFromFeatureID(ProSolid solid, int feature_id, ProSelection* out_selection, int* out_surface_id) {


//---------------------------------------------------------
// Init feature
//---------------------------------------------------------

ProFeature plane_feat;

ProError err = ProFeatureInit(solid, feature_id, &plane_feat);

error_utils::CheckError(err, "ProFeatureInit");

if (err != PRO_TK_NO_ERROR)
return err;

//---------------------------------------------------------
// Temp data structure
//---------------------------------------------------------

struct PlaneData
{
ProSelection* selection;
int* surface_id;
};

PlaneData data;
data.selection = out_selection;
data.surface_id = out_surface_id;

//---------------------------------------------------------
// Visitor
//---------------------------------------------------------

auto PlaneSurfaceAction = [](ProGeomitem* p_handle, ProError status, ProAppData app_data) -> ProError

{

//-----------------------------------------------------
// Access data
//-----------------------------------------------------

PlaneData* data = (PlaneData*)app_data;

//-----------------------------------------------------
// Skip inactive
//-----------------------------------------------------

ProBoolean inactive;

status = ProGeomitemIsInactive(p_handle, &inactive);

if (status != PRO_TK_NO_ERROR)
return PRO_TK_NO_ERROR;

if (inactive == PRO_B_TRUE)
return PRO_TK_NO_ERROR;

//-----------------------------------------------------
// Surface
//-----------------------------------------------------

ProSurface surface;
status = ProGeomitemToSurface(p_handle, &surface);

if (status != PRO_TK_NO_ERROR)
{
return PRO_TK_NO_ERROR;
}

//-----------------------------------------------------
// Get surface ID
//-----------------------------------------------------

status = ProSurfaceIdGet(surface, data->surface_id);

if (status == PRO_TK_NO_ERROR)
{
logger::log_info("Plane surface ID: " + std::to_string(*(data->surface_id)));

}

//-----------------------------------------------------
// Create selection
//-----------------------------------------------------

status = ProSelectionAlloc(NULL, (ProModelitem*)p_handle, data->selection);

if (status == PRO_TK_NO_ERROR)
{
logger::log_info("Plane selection allocated.");

return PRO_TK_USER_ABORT;
}

return PRO_TK_NO_ERROR;
};

//---------------------------------------------------------
// Visit geometry
//---------------------------------------------------------

err = ProFeatureGeomitemVisit(&plane_feat, PRO_SURFACE, PlaneSurfaceAction, NULL, &data);

if (err != PRO_TK_USER_ABORT &&
err != PRO_TK_NO_ERROR)
{
return err;
}

if (*out_selection == NULL)
{
return PRO_TK_E_NOT_FOUND;
}

logger::log_info("Plane selection + surface ID created.");

return PRO_TK_NO_ERROR;
}

// END OF PLANE SURFACE ACTION FUNCTION
//------------------------------------------------------------------------------------------------------------