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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to call a macro in the middle of a program?

CHASEONHO
18-Opal

How to call a macro in the middle of a program?

HI,

 

For synchronous toolkits, the macro is executed after the program function returns and a handle is returned to the creo.

 

Is there no way to use macros in the middle of a program in a synchronous toolkit?
Can you tell me if there is a way to use a macro in the middle of a program in a synchronous toolkit and run the handle back to the toolkit?

 

Since we did not find an API to extract the piping BOM, we need to extract the piping BOM using a macro.
For each model, you must extract all piping BOMs for each simplified representation.

 

If you know how to throw a macro in the middle of code in a synchronous toolkit and get back to the toolkit, Please let me know.

 

Thanks,

 

Warm Regards,
SeonHo

 

PS. attached photo was show what i need[ PIPING BOM]image_1.jpg

1 ACCEPTED SOLUTION

Accepted Solutions

There is no direct way to do this.

 

I found following work around:

Create separate toolkit DLL application which has macro execute code.

When you want to execute macro than load dll and call the required DLL methods.

 

This is like calling another application from your current application so that macro executes in sync.

API's which can help you are:

ProToolkitTaskExecute

 •ProToolkitDllLoad()
•ProToolkitTaskExecute()
•ProToolkitDllUnload()
•ProToolkitDllIdGet()
•ProToolkitDllHandleGet()

View solution in original post

14 REPLIES 14

There is no direct way to do this.

 

I found following work around:

Create separate toolkit DLL application which has macro execute code.

When you want to execute macro than load dll and call the required DLL methods.

 

This is like calling another application from your current application so that macro executes in sync.

API's which can help you are:

ProToolkitTaskExecute

 •ProToolkitDllLoad()
•ProToolkitTaskExecute()
•ProToolkitDllUnload()
•ProToolkitDllIdGet()
•ProToolkitDllHandleGet()

Thank you for your reply.
But is not this about the interaction between J-Link and the C-Toolkit?
I have tested and return PRO_TK_E_NOT_FOUND

 

PS excute.c call other dll function.  basefunction.c has PRO_DLL_EXPORT function.

You are able to load "TASKTEST.dll" in Creo ?

 

after your method executes .. you can see the application  TEMPDLL in Auxiliary application. you should click on in and try to start. if you get any error in starting then you have some issue with DLL. May be the way its built.

Yes, I can load TASKTEST.dll in CREO.

If define function to menu in BASE_FUNCTOIN.c that function is work well.

What is the error you are facing now ?

 

Is function from DLL executing ?

ProToolkitTaskExecute was return -4(PRO_TK_E_NOT_FOUND)

This error is may be because of name mangling

 

use following macro to export method and try once.

#define EXPORT extern "C" __declspec(dllexport)

Sorry, it works!

Thanks a lot!!

 

is MAGIC LINE!!!!!!!!!!!!!

#define EXPORT extern "C" __declspec(dllexport)

Uhm... it works... but..

The macro does not run in the middle of the code.
The macro will run after all programs have finished.
regret...

It worked me when I called from Jlink code. IT should work for C code also. Try adding sleep after function call.

I add "Sleep(5000)" after ProToolkitTaskExecute, but execute macro after finished code.

status = ProToolkitTaskExecute(real,"A",input_arguments,&output_arguments,&function_return);
	Sleep(5000);

When I was facing same issue in Jlink then I used this workaround of calling macro code from DLL and it worked for me.

 

If you have sometime than why don't you try same thing ?

Create Jlink application. On button click you load DLL and call macro method.

I can not handle Java.
So if you have to create an application for JLink to solve this problem, it will take a long time.
After all, C TOOLKIT can not run macros in the middle of code.
I had to search for another way.

 

Thank you for your help.

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

At the end of the mapkey call the button command again and manage your reentry by a static var or configure the button command.

Top Tags