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

Community Tip - You can change your system assigned username to something more personal in your community settings. X

J-Link_Creo 5_external_applications

VladiSlav
17-Peridot

J-Link_Creo 5_external_applications

Hello!


Please tell me how I can run external applications from Creo using J-Link (for example, a Windows calculator). I already created a button in the taskbar, now I want to assign it such functionality.

 

Best Regards!

1 ACCEPTED SOLUTION

Accepted Solutions

12 REPLIES 12

Thanks for the answer!


This I understood how to do, the code works.
But I need to open a website or application using a button from Creo. For this, I think that the created class object should be in the application session.
I don’t know how to add it there. If I'm on the right track at all..

 

Best Regards!

I think this is two separate task:

 

1) to open a website pfcWindow.Window.SetURL

 

2) Creo macros can call external application. From J-Link you can a macros

pfcSession.BaseSession.RunMacro
wfcWSession.WSession.ExecuteMacro

Okay, thanks)
I will try)
But I would still like to run the class, an example of which was sent by DavidBigelow.
I tried this:
Session curSession = pfcSession.GetCurrentSessionWithCompatibility(CreoCompatibility.C4Compatible);
UICommand uiCommand = curSession.UICreateCommand("Run_Appl", new Run());
but there was a mistake.

Many thanks to David Bigelow  and ysinitsyn  for your help!

I did it the way David Bigelow wrote it.

It's just that the class I was calling needed to be changed a bit.
If anyone is interested and will be useful:

 

class LaunchingExternalApps extends DefaultUICommandActionListener
{
      public LaunchingExternalApps() throws jxthrowable {
      }

      @Override
      public void OnCommand() throws jxthrowable
      {
          Runtime runtime = Runtime.getRuntime(); //getting Runtime object
          String[] s = new String[] {"<your browser>", "<your site>"};
          try
          {
              runtime.exec(s);
          }
              catch (IOException e)
          {
              e.printStackTrace();
          }
      }
}

Hello again!
Please tell me how the method pfcWindow.Window.SetURL works ?

I wrote like this:
Window www = (Window) pfcWindow.WindowOId_Create(0);
www.SetURL("<my site>");

But it doesn't work.

 

Best regards!

A piece of code from standard sample

// Code to display info file into Pro/E browser window
Window current_win = session.GetCurrentWindow ();
String line;
line = "file://";
line += session.GetCurrentDirectory();
line += InfoFile_name;
current_win.SetURL(line);

If nothing is happened and no errors, try to open browser window manually to clarify that the web page is changed to desired. Maybe, will be needed open browser by setting it size pfcWindow.Window.SetBrowserSize

Thanks!

It works!

Hello!
Here you say that you can use macros and run them in Creo.
Tell me, please, what am I doing wrong.

My code:

session.GetCurrentWindow().Activate();
String macro =  "~ Expand `main_dlg_cur` `DrwAssyTree` `node0:view_1 92 0 2 -1 \\\r\n" +
                "-1:View_Annotations -1 -1 0 -1 -1 -1`;\\\r\n" +
                "~ Select `main_dlg_cur` `DrwAssyTree` 1 `node0:view_1 92 0 2 -1 \\\r\n" +
                "-1:View_Annotations -1 -1 0 -1 -1 -1:note 0 68 0 24 -1 -1`;\\\r\n" +
                "~ Command `ProCmdEditDelete@PopupMenuTree`;";
session.RunMacro("macro");
((WSession)session).ExecuteMacro();
session.GetCurrentWindow().Activate();

The described macro should delete the detailed note in the drawing.
But at runtime, it does not.

I read the documentation, and saw that there are a lot of limitations, but I have not enough experience to assess which are the case in my case.
Tell me, please, what is the problem?
Thanks in advance!
Respectfully!

You might think about approaching the mapkey differently.

 

Assume you know the name of the note you want to delete. I am doing a "Control-F" to open the finder, selecting the type = Note, then entering in the name of the note I want to delete.   Then move the note to the right side of the selections, ultimately pressing the delete key.  This works consistently.  Also - I would check whether or not you need the "\" at the end of each line in your code... That is typically not required when running mapkey from code (at least in my experience).

 

Here is a mapkey that deletes a note by name using the Creo find command to find, select and then ultimately delete.

 

~ Key `main_dlg_cur` `proe_win` 9 578 409 38141958 0 794 586 1920 1139 711080 `Ctrl+F`;
~ Command `ProCmdMdlTreeSearch` ;
~ Open `selspecdlg0` `SelOptionRadio`;
~ Close `selspecdlg0` `SelOptionRadio`;
~ Select `selspecdlg0` `SelOptionRadio` 1 `Note`;
~ Update `selspecdlg0` `ExtRulesLayout.ExtBasicNameLayout.BasicNameList` `NOTE_1`;
~ Activate `selspecdlg0` `EvaluateBtn`;
~ Select `selspecdlg0` `ResultList` 0;
~ Select `selspecdlg0` `ResultList` -1;
~ Activate `selspecdlg0` `ApplyBtn`;
~ Activate `selspecdlg0` `CancelButton`;
~ Key `main_dlg_cur` `proe_win` 9 504 402 196608 512 794 586 1920 1139 727126 `Del`;
~ Command `ProCmdEditDelete`;

 

If you are trying to use the mouse to select things by window slection of an area on the drawing, you might have to record a trail file and hack that into your mapkey to perform the operations.  That is a more painful way to go... harder to create/debug.

 

Another option...   Use CREOSON... to identify the notes and their locations on the drawings:

 

Sample Request to get notes from a drawing

{
  "sessionId": "~sessionId~",
  "command": "note",
  "function": "list",
  "data": {
    "file": "box.drw",
    "name": "*"
  }
}

 

Would return something like this:

{
  "status": {
    "error": false
  },
  "data": {
    "itemlist": [
      {
        "name": "Note_2",
        "value": "Another test note",
        "encoded": false,
        "location": {
          "x": 2.5,
          "y": 4,
          "z": 0
        }
      }
    ]
  }
}

 

On a drawing - the Z value for the note location would always be "0".   But that would give you the coordinate locations and then you can easily go delete the note by name after using this:

{
  "sessionId": "~sessionId~",
  "command": "note",
  "function": "delete",
  "data": {
    "file": "box.drw",
    "name": "Note_2"
  }
}

 

Excellent!
Thank you so much, it worked!
I used the first method described by you.

👍 Cool!

Top Tags