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

JLink OnBeforeModelSave

BrianToussaint
19-Tanzanite

JLink OnBeforeModelSave

I'm not too thrilled by seeing that there are different actions out there that kill Pro/E when you have an action listener for OnBeforeModelSave. I was fine with my setup on my local machine while doing limited testing. Then when I rolled it out to my users, they've been getting strange behavior and random crashes.

Here is my action listener class:

public class SaveAL extends DefaultSessionActionListener { public void OnBeforeModelSave(DescriptorContainer cont) {

try{ Session curSession = pfcGlobal.GetProESession();

Model mdl = curSession.GetCurrentModel();

//String modelName = mdl.GetFileName();

String mdlTypes = fsgetModelType.fsgetModelType(mdl);



//Undesignate and redesignate parameters

ReDesParam rdp = new ReDesParam(); rdp.ReDesParam(curSession, mdl);



//Family table verification

new FamilyTableVerify(mdl, mdlTypes);

}//end of try

catch (jxthrowable err){}

}//end of method



}//end of class



Here is my listener call in my sync app that I am calling.

//---------Add Action Listener----------------------

Session proeSession = pfcGlobal.GetProESession();

proeSession.AddActionListener(new SaveAL());



Do others use and/or see this issue with OnBeforeModelSave? Any help/advice would be helpful.



A side question..... Should I just put all of my class files out on the network and point my users to the network, or should I copy them to the users machines in my startup?



Thank you,

Brian Toussaint

CAD Administrator

Hoshizaki America, Inc.

1 REPLY 1

Brian,
looking at your code I see you use the current model instead of the model
given to the OnBeforeModelSave in the DescriptorContainer. I would suggest
to use DescriptorContainer passed to the method.

The class files can be stored either locally or on a network. I have used
both setups in the past. But as must engineers today uses laptops all
class files is now stored locally, so J-link application also works on
borrowed licenses.

For your information, last time I played with action listeners in J-link I
found out that the application is triggered on every Event covered by the
SessionActionListener interface which are:

void OnAfterDirectoryChange (String Path)
    Provides a notification function called after the current directory
has been changed.
void OnAfterWindowChange ( /*optional*/ Window NewWindow)
    Provides a listener method called after changing a window in
Pro/ENGINEER.
void OnAfterModelDisplay ()
    Provides a notification function called after displaying a model.
void OnBeforeModelErase ()
    This is the stener method called before erasing a model.
void OnBeforeModelDelete ()
    This is the listener method called before deleting a model.
void OnBeforeModelRename (DescriptorContainer2 Container)
    This is the listener method called before renaming a model.
void OnBeforeModelSave (DescriptorContainer Container)
    This is the listener method called before saving a model.
void OnBeforeModelPurge (DescriptorContainer Container)
    This is the listener method called before purging a model.
void OnBeforeModelCopy (DescriptorContainer2 Container)
    This is the listener method called before copying a model.
void OnAfterModelPurge (ModelDescriptor Desrc)
    This is the listener method called after purging a model.

So even though you only implement a method for OnBeforeModelSave all other
event are handled by the DefaultSessionActionListener. Any of those events
resulted in the Undo/Redo stack in ProE being reset. Because of this I
never set my application into production, as it would not have been
accepted by the users.

Bjarne Frandsen



"Brian Toussaint" <->
19-06-2008 20:47
Please respond to
"Brian Toussaint" <->


To
-
cc

Subject
[proecus] - JLink OnBeforeModelSave






I'm not too thrilled by seeing that there are different actions out there
that kill Pro/E when you have an action listener for OnBeforeModelSave.  I
was fine with my setup on my local machine while doing limited testing.
Then when I rolled it out to my users, they've been getting strange
behavior and random crashes.
Here is my action listener class:
public class SaveAL extends DefaultSessionActionListener {
public void OnBeforeModelSave(DescriptorContainer cont) {
try{
Session curSession = pfcGlobal.GetProESession();
Model mdl = curSession.GetCurrentModel();
//String modelName = mdl.GetFileName();
String mdlTypes = fsgetModelType.fsgetModelType(mdl);

//Undesignate and redesignate parameters
ReDesParam rdp = new ReDesParam();
rdp.ReDesParam(curSession, mdl);

//Family table verification
new FamilyTableVerify(mdl, mdlTypes);

}//end of try
catch (jxthrowable err){}

}//end of method

}//end of class
Here is my listener call in my sync app that I am calling.
//---------Add Action Listener----------------------
Session proeSession = pfcGlobal.GetProESession();
proeSession.AddActionListener(new SaveAL());
Do others use and/or see this issue with OnBeforeModelSave?  Any
help/advice would be helpful.
A side question..... Should I just put all of my class files out on the
network and point my users to the network, or should I copy them to the
users machines in my startup?
Thank you,
Brian Toussaint
CAD Administrator
Hoshizaki America, Inc.
----------
Announcements
Attention: Creo 7.0 Customers
Please consider upgrading
End of Life announcement here.

NEW Creo+ Topics:
PTC Control Center
Creo+ Portal
Real-time Collaboration