Discussion: Options to create PowerMILL automation

VitorMartinsAugusto
Advocate
Advocate

Discussion: Options to create PowerMILL automation

VitorMartinsAugusto
Advocate
Advocate

Hi,

 

I would like to start a discussion about the different ways one can automate PowerMILL.

 

Disregarding templates, I can think of four different methods:

 

1) Using PowerMILL Macro language:

+ integrated inside PowerMILL

+ easy to learn and build up knowledge (from simple macro recording to complex macros)

+ does not need any SDK

+ does not need any installation

+ pretty powerfull programming lanuage

+ access to most parameters

+ works in any active PowerMILL window

- anyone can see the source code

- no GUI for the automation (only Input/Message boxes)

- limited interaction with Windows file system

- no interaction with other applications

- No access to PowerMILL events (activating, creating, deleting, ..., of entities)

 

2) HTML page with embedded Visual Basic Script or JavaScript

+ no SDK required

+ provides nice GUI (HTML)

+ works inside PowerMILL

+ works with any open PowerMILL window

- harder to learn than PowerMILL macro

- anyone can see the source code

- not very common in PowerMILL user base

- No access to PowerMILL events (activating, creating, deleting, ..., of entities)

 

3) Visual Basic or C# application

+ Uses official Delcam/Autodesk API

+ Provides DIRECT ACCESS to many parameters and functions

+ Relatively easy to use

+ pmill.Execute and pmill.ExExecute allow sending/receiving standard PowerMILL commands and their responses

+ Code is protected (but sent commands can be seen in PowerMILL shell)

+ Allows EMBEDDING the PowerMILL window inside the VB/C# application window for full integration

- Requires installing API

- Requires Visual Studio (can use the Express/Free edition)

- Only works with the FIRST PowerMILL window: if you open several PowerMILL sessions, you can only connect to the first

- No access to PowerMILL events (activating, creating, deleting, ..., of entities)

 

4) PowerMILL Plugin

+ Works INSIDE PowerMILL

+ Access to many PowerMILL events (activating, creating, deleting, ..., of entities), upon subscription

+ Fairly easy to distribute

+ Code is protected

+ Works with any open PowerMILL window

- Does not use Delcam/Autodesk API, so most interaction is done through pmill.Execute and pmill.ExExecute commands. At least I don't know how to use the API in this case. Perhaps there is a better way...

- Close to no documentation at all

- Difficult to understand the process of creating the plugin DLL and registering it, if you are not a programmer

- To test/debug you need to restart PowerMILL every single time you recompile the code

 

I hope this gives everybody a better understanding of the possibilities.

 

Also, I am interested to get further information about plugins:

 

- How to use the Autodesk PowerMILL API with plugins? Is that even possible?

- Is there newer documentation on API and Plugins?

- Is there a way to FULLY hide the GUI on PM2018 onwards (the NoGUI option leaves the menu bar visible)

- ...

 

Hope you guys find this useful. Perhaps I (or anyone) can include examples here for each scenario in the future.

 

Kind regards,

Vitor

Reply
2,580 Views
9 Replies
Replies (9)

Anonymous
Not applicable

This is a very interesting debate. I am using web pages with PowerMILL macros, too. It is in case you want to add it to your list. It is more useful and practical than using icons because it is possible to add images, pictures, important information, etc. Thank you.

5axes
Advisor
Advisor

Nice analyse of the different possibilities @VitorMartinsAugusto.

 

Personnaly i have made the choice of a mix between the method 1 and 3 ... A visual basic application to manage every interaction with other software or external data. And use of Macro execute via pmill.Execute or pmill.ExExecute commands. 

Pro : it's very flexible because every interaction with PMILL are made via a macro so you can addaped or modify the code without needs to compile every time the main application.

Cons : Macro execution time is 4 to 5 times longer since  Autodesk have released the 2018 version ( what's mainly why I  still using the 2017 release and as 2018 and 2019 doesn't bring advantage or new functionnalities, I prefer to stay with the 2017 release)

 

In your analyse you have also a 3b) method :

 

3b) Visual Basic for Application VBA ( embeded code in Excel )

 

+ Easy to use

+ pmill.Execute and pmill.ExExecute allow sending/receiving standard PowerMILL commands and their responses

+ Native interaction with other applications of the office suite

+ Code can be protected (but sent commands can be seen in PowerMILL shell)

+ Does not need any SDK

+ Does not need any installation ( Except Excel mainly used by CAM users in their professional environnement)

- You cannot embedded the PowerMILL window inside the Excel or Word window for full integration

- Only works with the FIRST PowerMILL window: if you open several PowerMILL sessions, you can only connect to the first one

- No access to PowerMILL events (activating, creating, deleting, ..., of entities)

 

 

VitorMartinsAugusto
Advocate
Advocate

Hi,

Attached is an example on how to use an HTML page with embedded Visual Basic Script.

 

This page can be called in different ways:

  • dragging the html file into the PowerMILL window
  • associating it to a button in a custom ribbon bar
  • ...

The beauty of this is the nice GUI for the automation and the fact that you have access to all Windows functionality, like printing things, etc.

 

The drawback is that you cannot protect your code - anyone can see what you are doing and how you are doing it.

Also, there is no way to "know" that things happend inside PowerMILL - that can only be done by using a Plugin that registers to Events.

 

Anyway, I hope you like it.

 

 

Cheers,

Vitor

Ye。xg
Advocate
Advocate

Are there any more examples? Or help documentation?

Thank you!

0 Likes

VitorMartinsAugusto
Advocate
Advocate

In PowerMILL 2019 go to (?) ->  Documentation -> Macro Programming Guide

 

Here you will find a rather good manual on Macro development for PowerMILL.

 

Start by following this course and make your own PowerMILL macros.

 

THEN try to make a .Net application (VB or C#) that connects to PowerMILL. Send/receive the same commands used in PowerMILL Macro, but add a propper user interface (GUI).

 

You can now easily add more advanced algorithms and you can benefit from a better debugger.

 

Once this is done, convert your application to a PowerMILL Plugin.

 

Regards,

Vitor

0 Likes

Anonymous
Not applicable

The best knowledge source for powermill macro are

1. Macro Programming Guide in power mill help

2. Powermill forum and old delcam forum 

3. Begginer to Advance macro films by Mr Grenier

 

I have a question, do you know any good place where I can pick up knowledge about scripts making/ plugins ?

With some practical examples, or sample codes ?

0 Likes

finello_mattia
Community Visitor
Community Visitor

Can you use Macro to analyze a file and understand how many faces need to be machined?

0 Likes

VitorMartinsAugusto
Advocate
Advocate

In my opinion this would be beyond the scope of PowerMILL's macro language capabilities.

 

I understand you want to analyse a "file", which is actually a CAD file, containing surfaces, solids, meshes, ...

 

Analysing the number of faces requires complicated algorithms which are very time consuming and a challenge for interpreted languages.

 

You could develop a software using C# that does such analysis and then connects to PowerMILL for data transfer and automation.

 

I would not know how to do it.

 

Kind regards,

Vitor

0 Likes

nguyenthinhvt95
Advocate
Advocate

Thank @VitorMartinsAugusto  for really clear information.

I'm using almost PowerMILL Macro in my job. Besides, I also use C# to connect PowerMill with another apps: Excel...

I used to try to write API but as you say It is really difficult to understand and use.

I think macro and C# are enough for me.

0 Likes