cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling ToolKit method in Object ToolKit C++

Highlighted
Level 6

Calling ToolKit method in Object ToolKit C++

Hi Guys,

 

I have a requirement where I need to call toolkit method in OTK C++.

Need to check if following attached code is right?

Application hangs up while executing the code.

 

CODE:

pfcDimension2Ds_ptr dims = drawing->ListShownDimensions(vw->GetModel(), pfcModelItemType:Smiley TonguefcITEM_DIMENSION);
for (int j = 0; j < dims->getarraysize(); j++)
{
pfcDimension2D_ptr soldimension2d = pfcDimension2D::cast( dims->get(j));
pfcDimension_ptr solDimension = pfcDimension::cast( dims->get(j));
if (soldimension2d->GetIsDisplayed())
{
if (soldimension2d->GetView() != NULL)
{
try
{
ProDimension feat = (ProDimension) wfcGetHandleFromObject( pfcObject::cast(solDimension) );
double *valD;
ProDimensionDisplayedValueGet(feat,valD);
}xcatchbegin
xcatchcip (Ex)
wLogger->log("ERROR IN Inspection Report Method....................");
cout<<Ex;
xcatchend
}// View associated to dimension
}// Dimension is displayed
}// Iterate dimensions

2 REPLIES

Re: Calling ToolKit method in Object ToolKit C++

 

I am not sure is there any way to directly call Toolkit API's.

Correct way of calling Toolkit API into otk is load DLL which has toolkit API and call it,

Go through API the document where it shows how to use otk API's

 

Following is the API document on how to use toolkit API,

 

Launching a Creo Parametric TOOLKIT DLL


The methods described in this section enable a Creo Object TOOLKIT C++ user to register and launch a Creo Parametric TOOLKIT DLL from a Creo Object TOOLKIT C++ application.

Methods Introduced:
•pfcBaseSession::LoadProToolkitDll
•pfcBaseSession::LoadProToolkitLegacyDll
•pfcBaseSession::GetProToolkitDll
•pfcDll::ExecuteFunction
•pfcDll::GetId
•pfcDll::IsActive
•pfcDll::Unload

 

 

 

Method "ExecuteFunction" can be used to call toolkit API

Re: Calling ToolKit method in Object ToolKit C++


@bdhamdhere wrote:

Hi Guys,

 

I have a requirement where I need to call toolkit method in OTK C++.

Need to check if following attached code is right?

Application hangs up while executing the code.

 

CODE:

pfcDimension2Ds_ptr dims = drawing->ListShownDimensions(vw->GetModel(), pfcModelItemType:Smiley TonguefcITEM_DIMENSION);
for (int j = 0; j < dims->getarraysize(); j++)
{
pfcDimension2D_ptr soldimension2d = pfcDimension2D::cast( dims->get(j));
pfcDimension_ptr solDimension = pfcDimension::cast( dims->get(j));
if (soldimension2d->GetIsDisplayed())
{
if (soldimension2d->GetView() != NULL)
{
try
{
ProDimension feat = (ProDimension) wfcGetHandleFromObject( pfcObject::cast(solDimension) );
double *valD;
ProDimensionDisplayedValueGet(feat,valD);
}xcatchbegin
xcatchcip (Ex)
wLogger->log("ERROR IN Inspection Report Method....................");
cout<<Ex;
xcatchend
}// View associated to dimension
}// Dimension is displayed
}// Iterate dimensions


whatever is colored in red is wrong. you cannot declare a pointer to a double an pass it to a function. the function has nowhere to store the resulting value - it is trying to write sizeof(double) bytes  to a space allocated for sizeof(*double). you need to declare a double and pass a pointer to a double to the function...

the second highlighted thing (feat)  is  wrong - you cannot pass the structure by value to the function which expects a pointer to a structure... 

double some_value = -1e6;
if( PRO_TK_NO_ERROR != ProDimensionDisplayedValueGet( &feat, &some_value)) {...}