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

The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.

How to be notified that a special part has been redrawn?

Emilie
1-Newbie

How to be notified that a special part has been redrawn?

Hi!

I'm working on a project where I need to know when a part or an assembly has been redrawn. I'm using the notification PRO_MDL_DISPLAY_PRE so when someone Hide or Show a part or an assembly I receive a notification and I print the name and the type of the model by the notification:

//get and print the type of the given model

ProError getModelType(ProMdl model, ProMdlType* mdlType)

{

ProError err;

err = ProMdlTypeGet(model, mdlType) ;

if (err == PRO_TK_NO_ERROR)

{

Printf(" Model Type ");

if (*mdlType == PRO_MDL_UNUSED) ConnectorLog::log("PRO_MDL_UNUSED");

if (*mdlType == PRO_MDL_ASSEMBLY) ConnectorLog::log("PRO_MDL_ASSEMBLY");

if (*mdlType == PRO_MDL_PART) ConnectorLog::log("PRO_MDL_PART");

if (*mdlType == PRO_MDL_DRAWING) ConnectorLog::log("PRO_MDL_DRAWING");

if (*mdlType == PRO_MDL_3DSECTION) ConnectorLog::log("PRO_MDL_3DSECTION");

if (*mdlType == PRO_MDL_2DSECTION) ConnectorLog::log("PRO_MDL_2DSECTION");

if (*mdlType == PRO_MDL_LAYOUT) ConnectorLog::log("PRO_MDL_LAYOUT");

if (*mdlType == PRO_MDL_DWGFORM) ConnectorLog::log("PRO_MDL_DWGFORM");

if (*mdlType == PRO_MDL_MFG) ConnectorLog::log("PRO_MDL_MFG");

if (*mdlType == PRO_MDL_REPORT) ConnectorLog::log("PRO_MDL_REPORT");

if (*mdlType == PRO_MDL_MARKUP) ConnectorLog::log("PRO_MDL_MARKUP");

if (*mdlType == PRO_MDL_DIAGRAM) ConnectorLog::log("PRO_MDL_DIAGRAM");

Printf("\n");

}

return err;

}

//get and print the name of the given model

ProError getModelName(ProMdl model, char* name)

{

ProError err;

ProName w_name;

err = ProMdlNameGet(model, w_name);

if (err == PRO_TK_NO_ERROR)

{

ProWstringToString (name, w_name);

Printf( "Model Name: %s", name);

}

return err;

}

//the callback for when a model has been displayed

ProError UserTestNotification(ProMdl mdl_handle)

{

char name[PRO_LINE_SIZE] = "";

getModelName(mdl_handle, name);

ProMdlType MdlType = PRO_MDL_UNUSED;

getModelType(mdl_handle, &MdlType);

return PRO_TK_NO_ERROR;

}

//init the notification

extern "C" int user_initialize()

{

ProError err = PRO_TK_NO_ERROR;

ProMode mode = PRO_MODE_UNUSED;

ProModeCurrentGet(&mode);

if(mode != PRO_TK_BAD_CONTEXT)

{

ProError err = PRO_TK_NO_ERROR;

err = ProNotificationSet(PRO_MDL_DISPLAY_PRE,(ProFunction) UserTestNotification);

}

return(0);

}

the problem is that I always get the name of the root parent of my model and the type is always PRO_MDL_ASSEMBLY. Is it possible to receive the precise information that a part has been displayed?

Thank you very much!

Emilie


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
1 REPLY 1
sully7
13-Aquamarine
(To:Emilie)

Emilie,

I tested similar code myself, it seems like that notification doesn't run recursively (aka, it doesn't run a component in a model). It only runs on the top-level model, regardless of which model or sub-component is changed.

From what I can tell, your best bet would be to build an array of the current state of every component in the model, save that array into memory, and then do a comparison of the current-state to the previous-state on every new model display change (using the notification). Problem is, that check could impact model performance depending on how large your models are.

Thanks,

Sully

President & Founder
CadActive Technologies - www.cadactive.com
Announcements


Top Tags