Community Tip - You can change your system assigned username to something more personal in your community settings. X
Hello all,
I'm trying to write toolkit for preventing working outside the working directory.
I tried 2 function:
1.pfcDefaultSessionActionListener::OnBeforeModelSave(pfcDescriptorContainer_ptr Container):
but I can't get any relevant information for where the object will be save.
2.pfcDefaultModelActionListener::OnAfterModelSave(pfcModelDescriptor_ptr Container)
more relevant function but here when I check:
Container->GetPath(),Container->GetDevice() the information I receive is not the new path I set.
Is there any why to do it right?
Many thanks!
Just correcting the names of the functions:
1. pfcDefaultSessionActionListener:: onBeforeModelSave(pfcDescriptorContainer_ptr Container)
2. pfcDefaultModelActionListener:: onAfterModelSave(pfcModelDescriptor_ptr Container)
Hi all,
tmaoz,
OnBeforeModelSave will not tell you the user-intended target directory, this is not what this method does...
Your best bet is OnAfterModelSave ( OnAfterModelSaveAll). This method will give you a model descriptor of the saved model and therefore the target directory, after this is up to you how to enforce your policies...
To get a full name from a model descriptor I would use something like this:
pfcModel_ptr model_ptr = session->GetModelFromDescr(pfc_mdl_descr);
xstring fpath = model_ptr->GetOrigin();
But when I use the function:
xstring fpath = model_ptr->GetOrigin();
fpath equal to the model that I'm saving and not the new direction I chose.
Thanks.
Hello all,
tmaoz,
This is correct, the return value will be the full file system path of the model currently in session.
The information from model descriptor :
auto drive_name = pfc_mdl_descr->GetDevice(); auto extension = pfc_mdl_descr->GetExtension(); auto file_name_with_extension_no_index = pfc_mdl_descr->GetFileName(); auto file_name_no_extension_no_index = pfc_mdl_descr->GetFullName();
auto directory_path_no_drive = pfc_mdl_descr->GetPath(); auto generic_name = pfc_mdl_descr->GetGenericName(); auto host = pfc_mdl_descr->GetHost(); auto instance_name_no_extension = pfc_mdl_descr->GetInstanceName();
Thinking more about your question - I don't believe Pro/E UI for 'Save' command have an option to prompt an end user for the destination directory. 'Save Backup' UI command indeed prompts an end user for the destination directory. There are config.pro options which would allow to store a model in session to the working directory via 'Save' command but I'm assuming you had taken care of config.pro options already.
It looks like you would need to write a couple of listeners:
HIH.
FV.