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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Translate the entire conversation x

Toolkit JLink RunMacro mapkey length limit?

RoDes
12-Amethyst

Toolkit JLink RunMacro mapkey length limit?

Is there a limit to the length of the mapkey that I can run in the BaseSession.RunMacro(String mapkey) command in JLink toolkit?

 

I have code that dynamically generates a mapkey to extend its functionality. I group all the mapkey parts that it generates together in one long String. Then I run that macro right before returning control to Creo. I decided to do it this way, to make the mapkey run sequentially.

Depending on the number of parts in the assembly, this mapkey becomes long. Very long. Creo hangs when control is returned to it. I can only force quit Creo at that point. The debugger runs until the end of the code and then returns control to Creo, and it starts to hang. On shorter mapkeys, it is not a problem. Control returns to Creo. The mapkey gets executed. The code functions.

 

The problematic mapkey is 4000 lines and 200 000 characters long. Is it known what the limit is? Either a formal limit or a practical limit? Then I could decide when to develop or use a workaround.

 

Creo version is 8.0.8.0. I use JLink, the free version. My program runs synchronous.

ACCEPTED SOLUTION

Accepted Solutions
RoDes
12-Amethyst
(To:RoDes)

Summarizing RandyJones and RPN's helpful answers:

 

RandyJones:

Limits for mapkeys can be found here: https://www.ptc.com/en/support/article/CS114528

 

There is no limit in total length anymore and characters on a line has been increased from 81 to 260.

 

RPN's suggestion that solved my specific problem:

instead of using RunMacro(<superlong mapkey string here>), save the superlong mapkey string in a temporary config file, load it in the session and fire via RunMacro(%mapkeyname)

 

RPN also provides other useful tips in this thread.

View solution in original post

9 REPLIES 9
RandyJones
20-Turquoise
(To:RoDes)

Article CS114528 implies there is no limit any more:
https://www.ptc.com/en/support/article/CS114528

 

It does not say specifically if that also applies to RunMacro() or only applies to config.pro/mapkeys.pro mapkeys.

RoDes
12-Amethyst
(To:RandyJones)

Thanks for the article link.

That does confirm to me that it's not a mapkey limit that's giving my program troubles. It is something else.

 

I do have a line that's longer than 81 chars, and less than 260. But it occurs pretty often, and does not seem related to the problem.

RPN
17-Peridot
17-Peridot
(To:RoDes)

Try to divide this longer lines in multiple ones.  

RPN
17-Peridot
17-Peridot
(To:RoDes)

You did not mentioned how you fire the MK, But personally I would save the sequence in a temporary config file, load it and fire via %, or however, it can be a memory issue. And synchrones mode may is not perfect for this scenario..

RoDes
12-Amethyst
(To:RPN)

I used session.RunMacro(mapkey); where mapkey was a Java String that has all the mapkey in it.

 

I did try your approach: save the sequence in a temporary config file, load it and fire via %, and that does change the situation. It no longer hangs, now it crashes. Not yet the outcome I wanted, but something different to be stuck on. Thanks for the idea.

RoDes
12-Amethyst
(To:RoDes)

It seems like my new crash was related to a specific part, and not a general crash.

RoDes
12-Amethyst
(To:RoDes)

I am not sure which of the answers of RandyJones or RPN to accept. RandyJones offers the answer to the literal question. While RPN's suggestion helped me further along.

RPN
17-Peridot
17-Peridot
(To:RoDes)

As far I know there are no limits, but check the Doku for the order, if I remember correctly you need to reverse, so Last in First fired. 
It depends on your calls. 
But check the trail file, here you see when Creo crashes. And I think there is still a limit of the line length in the config file. The best is to make it manual first, next save and replace with your vars before run, and again check the line size after replace. 
And this is much easier to maintain, it is not part of the code. Just a simple search and replace. 🙃

RoDes
12-Amethyst
(To:RoDes)

Summarizing RandyJones and RPN's helpful answers:

 

RandyJones:

Limits for mapkeys can be found here: https://www.ptc.com/en/support/article/CS114528

 

There is no limit in total length anymore and characters on a line has been increased from 81 to 260.

 

RPN's suggestion that solved my specific problem:

instead of using RunMacro(<superlong mapkey string here>), save the superlong mapkey string in a temporary config file, load it in the session and fire via RunMacro(%mapkeyname)

 

RPN also provides other useful tips in this thread.

Announcements


Top Tags