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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Session::GetCurrentModel method throws exception.

Harsh9592
7-Bedrock

Session::GetCurrentModel method throws exception.

Hi All,

I start learning Creo customization using Jlink. 

I start learning with getting the name of the current model in session but it can't work. 

here is mode code.

can somebody help me where am I making the mistake?

 

import com.ptc.cipjava.jxthrowable;
import com.ptc.pfc.pfcAsyncConnection.AsyncConnection;
import com.ptc.pfc.pfcAsyncConnection.pfcAsyncConnection;
import com.ptc.pfc.pfcModel.Model;
import com.ptc.pfc.pfcSession.Session;

public class AsyncTest {

	AsyncConnection conn = null;
	Session session = null;
	Model model = null;

	public static void main(String[] args) throws jxthrowable, Exception {
		// TODO Auto-generated method stub
		System.loadLibrary("pfcasyncmt");

		AsyncTest tt = new AsyncTest();

		tt.runCreo();

	}

	public void runCreo() throws jxthrowable {

		try {

			conn = pfcAsyncConnection.AsyncConnection_Connect(null, null, null, null);

			Thread.sleep(5000);
			session = conn.GetSession();

			model = session.GetCurrentModel();

			System.out.println(model.GetFileName());

			conn.Disconnect(null);
		} catch (Exception ex) {
			System.out.println(ex.getMessage());
			if (conn.IsRunning()) {
				conn.Disconnect(null);
			}
		}
	}

}

"conn.GetSession();" return 'Null' value.

I don't know why this happening.

Thanks in advance!!

 

1 REPLY 1
remy
21-Topaz I
(To:Harsh9592)

try:

conn = pfcAsyncConnection.AsyncConnection_Connect("", "", "", 10);

if this still does not fix your issue, you may file a case.

Top Tags