[macro]Function library file

[macro]Function library file

dan_mickle
Participant Participant
776 Views
2 Replies
Message 1 of 3

[macro]Function library file

dan_mickle
Participant
Participant

Hello PowerMill Community,

I'm currently working on improving the efficiency of my workflow by centralizing all my functions into a few library files. The goal is to be able to call these functions as needed across various macros I’m developing.

Issue Encountered: I load the library file at the start of each macro by using an include statement, but I’m encountering an issue where the main function of the library file enters a loop, repeating indefinitely no matter what I code inside the main function.

Objective: My aim is to have a centralized library of functions that I can easily call from, which would significantly streamline the process of developing and maintaining macros.

Question: Is there a workaround or a method within PowerMill that allows for the effective use of function libraries without the main function looping? Any guidance or tips on how to implement this would be greatly appreciated as it would simplify my new workflow system.

Thank you in advance for your help!

0 Likes
Accepted solutions (1)
777 Views
2 Replies
Replies (2)
Message 2 of 3

icse
Advisor
Advisor
Accepted solution

I dont think the library should contain a main method

 

the .inc file(Library)

function DoSomething(entity $tp) {
	//Code
}

function DoSomeOtherThings(string $input) {
	//Code
}

 

the macro

include myfunctions.inc
function Main() {
	foreach $tp in folder('toolpath') {
		call DoSomething($tp)
	}
}
Message 3 of 3

dan_mickle
Participant
Participant

If I try to call a file with functions and no main function, it errors out. 

Edit: Nevermind, I'm dumb. The file that's calling the function needs to have the main function, the function library doesn't need to have a main function

I structured it like this and it worked.

include testFunctionLibrary
function main() {
message info "test"
call resetBlockForm()
}

 

0 Likes