Guest

csharp and python-scripts-for-mastercam

Recommended Posts

Guest

This is a powerful new add in I created that allows you to access the NEThook_3.dll functions via a script (text) file. 

It also contains some c++ SDK functions that I will be updating gradually.

This is similar to the old vbscript api. A user interface is launched and scans the targeted files into a list view.

After that simply select the item in the list to run your script.

Download here - > Github

Share this post


Link to post
Share on other sites
Guest
11 hours ago, LeoC said:

Thank you for your contribution.

 

LeoC

I plan to add a code generating software to write scripts from a user interface dialog, it will be very fast coding then.

Share this post


Link to post
Share on other sites

I think this is a great idea.

However I couldn't get it to work in 2020.  Are you interested in any constructive feedback regarding the execution?

Share this post


Link to post
Share on other sites
Guest
4 hours ago, Zaffin_D said:

I think this is a great idea.

However I couldn't get it to work in 2020.  Are you interested in any constructive feedback regarding the execution?

Yes, Zaffin, your suggestions are always welcome. 

It works for me on multiple pc's and bersions, is it  possible there are some files missing? Did you receive an error message either in the mclogr or messagebox?

Share this post


Link to post
Share on other sites
Guest

Would you check if the files need to be unblocked please? 

Right click -> Properties -> Unblock

The Source code. ->: This is our chook library.  -> This Is our Nethook Library . 

The .py files need to be located in a folder called scripts in the chook folder.The NetSDK.dll and NetSDK.ft files need to be in the chooks folder. The IronPython files need to be in the c:/program files/Mcam2018 folder.

In the project we should have access to all  of the functions in the Nethook_3.dll file & all the functions in the NetSDK.dll. 

Here is a simpler example of loading a file with python :

	//This is our Nethook Entry Point, Here we are calling a function from python

	//The function we are calling will in turn call functions from this dll file

	//

	public: virtual Mastercam::App::Types::MCamReturn RunScript(int param)

	{









		auto pythonengine = IronPython::Hosting::Python::CreateEngine();

		auto scope = pythonengine->CreateScope();

		pythonengine->ExecuteFile("script.py", scope);

		auto scriptrunner = scope->GetVariable("Scriptrunner");

		auto scriptrunnerInstance = pythonengine->Operations->CreateInstance(scriptrunner);

		auto result = pythonengine->Operations->InvokeMember(scriptrunnerInstance, "runscript");

		auto stringresult = dynamic_cast<System::String^>(result);



		return Mastercam::App::Types::MCamReturn::NoErrors;

	}



	};

}
          

 

Share this post


Link to post
Share on other sites
Guest

The examples scripts in this project are looking for geometry, so if there isn't any they won't do much!

Share this post


Link to post
Share on other sites

Is there a readme file? Do you need to use IronPython? I program python a bit and I program with mastercam I'd like to try this out, and contribute as well. Thanks. 

Share this post


Link to post
Share on other sites
Guest

There are notes on the github for where the files need to be stored in the mastercam folder, the iron python files are included in the download.

4 minutes ago, MachiningMike said:

Do you need to use IronPython?

Yes this works with Iron Python and the NEThook_3.dll

Share this post


Link to post
Share on other sites
Guest

Copying the files to the indicated directories and loading the chook icon should get you rollkng , let me know if u have any issues.

Share this post


Link to post
Share on other sites
Guest
3 hours ago, Reece L Gibson said:

Very Clever ........I am impressed.....

keep the up the good work!

Thank you, stay tuned, lots of new content to come this year!!!

Share this post


Link to post
Share on other sites
Guest

*New -> PythonScriptsForWindows :

A windows 64 bit application that exectutes Iron Python scripts. 

Same concept as PythonScriptsForMastercam except this is a non Mastercam solution.

Included example programmatically create a winform with a button and event handler!!

Share this post


Link to post
Share on other sites

I think it could be more valuable to create an interface with C-hook instead of net-hook. Net-hook, while easy to use, has big limitations. It also does not seem to be updated with support for all toolpaths.

Share this post


Link to post
Share on other sites
Guest
2 hours ago, zero_divide said:

I think it could be more valuable to create an interface with C-hook instead of net-hook. Net-hook, while easy to use, has big limitations. It also does not seem to be updated with support for all toolpaths.

Hi, we can create an interface with the c++ sdk to McPython via a c++/cli wrapper dll .

The advantage of using a nethook is that it supports multiple versions of mastercam.

 

Which operations were you hoping to create access? 

For which version of Mastercam please?

 

The topic of c++/cli dlls for the chook sdk operations is under discussion here -> 

 cli

The tutorial for creating c++/cli nethooks and downloading the sdk is here -> 

 

I will add the linking to the sdk tutorial shortly, thank you for the feedback.

Share this post


Link to post
Share on other sites
Guest
5 hours ago, zero_divide said:

I think it could be more valuable to create an interface with C-hook instead of net-hook. Net-hook, while easy to use, has big limitations. It also does not seem to be updated with support for all toolpaths.

Just for clarity the reason the chook interface takes longer is because Iron Python auto-magically inherents all the functionality of nethook_3.dll where-as the chook sdk functions have to be manually interfaced one by one.

Share this post


Link to post
Share on other sites
13 hours ago, baby byte said:

为了清楚起见,chook接口花费更长的时间的原因是因为Iron Python自动神奇地继承了nethook_3.dll的所有功能,其中chook sdk函数必须手动逐个接口。

😀

  • Haha 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us