Community
PowerMill Forum
Welcome to Autodesk’s PowerMill Forums. Share your knowledge, ask questions, and explore popular PowerMill topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Tips & Tricks

94 REPLIES 94
Reply
Message 1 of 95
GlennM.MCAM
13968 Views, 94 Replies

Tips & Tricks

Hi all!

I thought it would be a good idea to post some tips and tricks for certain actions. Some of you will know them, other don't.
Please post as much tips & tricks as you want. Here are mine:

 

 

Since it is not possible to export the stockmodel as a dmt file, I save the viewmill state as dmt and use that as a block.

 

 

If you need a selection of your model and want to save this selection, use this macro:

CREATE LEVEL ; MODELCOMPSET EDIT LEVEL # ACQUIRE SELECTED

Greetings,

Glenn


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
94 REPLIES 94
Message 41 of 95
JonimoosePrime
in reply to: 5axes


@5axes wrote:
    SESSIONPAR BOOL DraftAngle = 0

 SESSIONPAR? That's a new one, do those get saved like project par's do they get wiped out on close? There have been a few times I wanted a variable to be sticky while the project was open but didn't need it to last after closing and that looks like exactly waht I need? And the help even appears to show that you can store dictionaries and objects there where

 

EDIT PAR CREATE blah "blah"

seems to be much more limited in its variable types.

Message 42 of 95
GlennM.MCAM
in reply to: GlennM.MCAM

Explanation

 

Macro 1

Often I use template projects for electrode milling. In order not to forget to save the project as a new project (which I did a couple of times...), I run this macro at the end of my workplane macro (first macro after importing). This will check if the model name and the project name are the same so I don't accidentally save the original template project.

 

Macro 2 (SaveProjectWithModelNameAndPath.mac)

If the names don't match, it runs a macro that saves the project in the folder of the model with the name of the model in the explorer tree. First you will get a popup that asks if the location and name is correct.

 

Note that some checks are present in both macros because I run the 2nd macro manually when I'm not using the 1st macro (for non electrode milling). That also the reason why this is seperated in 2 macros.

 

Code

 

Macro1

 

 

STRING LIST models = {}
FOREACH md IN FOLDER('model') {
     IF position($md.name, "Planes") == -1 { //ignore "planes"
          INT k = add_last($models, $md.name)
     }
}
STRING ModelName = ''
IF size($models) == 1 {
     $ModelName = $models[0]
} ELSE { //If multiple models, choose one
     $ModelName = INPUT ENTITY MODEL "Choose model"
}

STRING ProjectName = project_pathname(1) 

IF NOT ($ModelName == $ProjectName) {
BOOL nomatch = FALSE
$nomatch = QUERY "Project name and model name don't match. Save as new project?"
IF $nomatch {
macro L:\macros\SaveProjectWithModelNameAndPath.mac
}
}

 

Macro 2 (SaveProjectWithModelNameAndPath.mac)

 

 

STRING LIST models = {}
FOREACH md IN FOLDER('model') {
     IF position($md.name, "Planes") == -1 { //ignore "planes"
          INT k = add_last($models, $md.name)
     }
}
STRING ModelName = ''
IF size($models) == 1 {
     $ModelName = $models[0]
} ELSE { //If multiple models, choose one
     $ModelName = INPUT ENTITY MODEL "Choose model"
}
STRING ModelPath = entity('Model','$ModelName').path
$ModelPath = dirname(ModelPath) 
STRING saveas = $ModelPath + '\' +  $ModelName

//if project exist, notify this and ask to save.
IF dir_exists($saveas) { 
BOOL projectexists = FALSE
$projectexists = QUERY "Project already exists. Save it?"
IF $projectexists {
  PROJECT SAVE
}
MACRO ABORT

//if project doesn't exist, save it as modelname in model location
} ELSE { 
		BOOL NameCheck = FALSE
		STRING $Question = "Is this path and modelname correct?" +CRLF+ $saveas
		$NameCheck = QUERY $Question
		IF $NameCheck {
		PROJECT SAVE AS $saveas 
		STRING $Message = "Project succesfully saved in" +CRLF+ $saveas
		MESSAGE INFO $Message
		}
}

 

Glenn

 

 


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
Message 43 of 95
precicam
in reply to: GlennM.MCAM

Probably known to many but I'll post it nonetheless.

 

If you are having a hard time understanding the data structure of powermill variables and entities, the debug macro tool is very helpful.

 

I've written a short macro that just loads the various active entities into variables so that I can browse through their data structure via the debug macro tool :

 

Macro :

 

ENTITY $tpEnt1 = entity('toolpath', '')
ENTITY $tpEnt2 = entity('tool', '')
ENTITY $tpEnt3 = entity('boundary', '')

ENTITY $tpEnt3 = entity('ncprogram', '')

// And so on..

 

Capture.PNG

 

Message 44 of 95
5axes
in reply to: GlennM.MCAM

Right click on the Tool Database Result Search Windows columns header

Use the function Copy

CopyData.jpg

 

Paste  these datas in a new Excel sheet  (Ctrl+V)  Smiley Wink

 

Excel.jpg

Message 45 of 95
Eskondedo
in reply to: GlennM.MCAM

Simple but I use and abuse this macro, it selects plunge moves missing leadins and/or plunges into stock then inverts the selection and locks the good moves and inverts back and automatically brings up the leadlink window to apply different leadins.  You can use this over and over again creating as many lead in options as you want in a single toolpath ensuring every cut move has a leadin! Smiley LOL

 

EXPLORER SELECT Toolpath ; NEW
EDIT TOOLPATH SELECT UNSAFE_PLUNGES
EDIT TPSELECT ; SELECT INVERT
EDIT TOOLPATH ; LOCK ALL
EDIT TPSELECT ; SELECT INVERT
FORM LEADLINK

 

Hope this helps someone

Message 46 of 95
NanchenO
in reply to: GlennM.MCAM

Using the wrong cutter compensation on a machine  (wear instad of full_radius) could be a real pain on the machine.

 

I use this macro to apply the correct compensation according to the machine type (full_radius or wear) and define a user variable that I use in the postpro to make sure that the correct one is activated.

 

FOREACH ent IN folder("NCProgram\Machine1") {
		ACTIVATE NCprogram $ent
		STRING nc = 'NCProgram\Cincinnati\' +$ent.Name
FOREACH tp in components(entity('ncprogram', '')) {
   IF $tp.RootType == 'nctoolpath' {
		EXPLORER SELECT Toolpath $tp NEW
		ACTIVATE TOOLPATH $tp.name
		EDIT TPPAGE SWCutterComp
		if $CNCCutterCompensation.Active == 1 {
			if $Toolpath.CNCCutterCompensation.Type == 'full_radius' {
				EDIT TOOLPATH $tp RECYCLE
				YES
				EDIT PAR 'Toolpath.CNCCutterCompensation.Type' 'wear'
				EDIT TOOLPATH $tp REAPPLYFROMGUI
				Yes
			DEACTIVATE TOOLPATH
			ACTIVATE TOOLPATH $tp.name
			}
		}
		EDIT TPPAGE SWUDSettings
		BOOL $chk = 0
		$chk = ERROR(entity('toolpath','').UserParameters.COMP)
		if $chk {
			EDIT USERPAR toolpath_strategy SELECT 'COMP'
			EDIT USERPAR toolpath_strategy  'normal' NAME "COMP"
			CREATE USERPAR toolpath_strategy $tp
			EDIT USERPAR toolpath_strategy $tp "COMP" "${CNCCutterCompensation.Type}"
			}
		}
		edit par "entity('toolpath','').userparameters.COMP" "${CNCCutterCompensation.Type}"
		DEACTIVATE TOOLPATH
	}
}

Works fine and I had no longer problems since the guys use it. Note that I made a special script in the postpros to check it:

 

function Compensation_fausse()
{
  // Interrupt processing if cutter compensation type is wrong in NCProgram (user parameter udp_COMP)
  if (GetParam("%p(udp_COMP)%") != "full_radius")
	{
	(MessageBox("Stop postprocessing: Cutter compensation wrong in" + GetParam("%p(Toolpath Name)%") + "  !", ppOk) == ppIdOk);
	UserError("Stop postprocessing: Cutter compensation wrong in" + GetParam("%p(Toolpath Name)%") + "  !");
	}
  return StandardResponse();
}

It's a bit tricky but could save a lot of troubles on the machines.

 

 

Olivier

Message 47 of 95
GlennM.MCAM
in reply to: NanchenO

Hi,

this macro detects if there is a old spark gap in the project notes. If there is nothing detected, you will get a popup to ask what the old spark gap was. After this, you fill in a new spark gap (positive value) and it recalculates the toolpaths, limits and boundaries. The new spark gap value is stored in the project notes so it can be automatically detected when changing to another spark gap.

 

Screencast: https://autode.sk/2GW1E4d

 

REAL oldsparkgap = 0
REAL newsparkgap = 0

IF ($project.notes == "") {
	MESSAGE INFO "       No previous sparkgap found!" +CRLF+ "Press OK to set the previous sparkgap."
	$oldsparkgap = INPUT "Previous Sparkgap?"
	$project.notes = $oldsparkgap
	$newsparkgap = INPUT "New Sparkgap?"
	
} ELSE {
	$oldsparkgap = REAL($project.notes)
	$newsparkgap = INPUT "New Sparkgap?"
}

FOREACH $tp.Computed IN FOLDER ('toolpath') {
	INVALIDATE TOOLPATH ALL
	YES
	}
	
	INVALIDATE BOUNDARY ALL
	YES
	
FOREACH tp IN FOLDER('toolpath') {
	ACTIVATE TOOLPATH $tp.name
	DEACTIVATE BOUNDARY
	DEACTIVATE TOOL
	EDIT TOOLPATH # RECYCLE
	YES
	REAL RadialThicknessSG = ($Thickness + $oldsparkgap - $newsparkgap)
	REAL AxialThicknessSG = ($AxialThickness + $oldsparkgap - $newsparkgap)
	$Thickness = $RadialThicknessSG
	$AxialThickness = $AxialThicknessSG
	
	REAL LimitZmax = ($ZRange.Maximum.Value + $oldsparkgap - $newsparkgap)
	REAL LimitZmin = ($ZRange.Minimum.Value + $oldsparkgap - $newsparkgap)
	$ZRange.Maximum.Value = $LimitZmax
	$ZRange.Minimum.Value = $LimitZmin
	EDIT TOOLPATH # REAPPLYFROMGUI
	YES
	
	//If toolpath has a boundary: apply new sparkgap, select the boundary surfaces and calculate
	IF entity_exists(entity('boundary','')) { 
		EDIT MODEL ALL DESELECT ALL
		EDIT BOUNDARY ; SELECT_SURFACES
		FORM BOUNDARY ;
		REAL BoundaryThicknessSG = ($boundary.Thickness + $oldsparkgap - $newsparkgap)
		REAL BoundaryAxialThicknessSG = ($boundary.AxialThickness + $oldsparkgap - $newsparkgap)
		$boundary.Thickness = $BoundaryThicknessSG
		$boundary.AxialThickness = $BoundaryAxialThicknessSG
		EDIT BOUNDARY ; ACCEPT BOUNDARY ACCEPT
		EDIT BOUNDARY ; CALCULATE
		EDIT MODEL ALL DESELECT ALL
			IF NOT $boundary.Computed {
			MESSAGE ERROR "Not all boundaries could be calculated automatically!"
			DEACTIVATE TOOLPATH
			DEACTIVATE BOUNDARY
			$project.notes = $newsparkgap
			MESSAGE INFO "Toolpaths and boundaries have been edited with an offset of $newsparkgap"
			MACRO ABORT			
			}
		DEACTIVATE BOUNDARY
	}
}

BOOL calcAlltp = FALSE
STRING $questionLine = "Calculate all toolpaths?"
$calcAlltp = QUERY $questionLine
	IF $calcAlltp {
		BATCH PROCESS
		DEACTIVATE TOOLPATH
	}

BOOL activatestkmd = FALSE
STRING $questionLine1 = "Calculate all stockmodels?"
STRING $questionLine2 = "This will calculate all toolpaths!"
STRING $question = $questionLine1 +CRLF+ $questionLine2
$activatestkmd = QUERY $question
	IF $activatestkmd {
		FOREACH stkmd IN FOLDER ('stockmodel') {
			ACTIVATE STOCKMODEL $stkmd.name
			EDIT STOCKMODEL # CALCULATE
			UNDRAW STOCKMODEL #
			DEACTIVATE STOCKMODEL\r
			BATCH PROCESS
			DEACTIVATE TOOLPATH
		}
	}

DEACTIVATE TOOLPATH
DEACTIVATE BOUNDARY
$project.notes = $newsparkgap
MESSAGE INFO "Toolpaths and boundaries have been edited with an offset of $newsparkgap"

 

 


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
Message 48 of 95
Anonymous
in reply to: GlennM.MCAM

Hi.

 

Works very nice:).

 

But how can i get this work if i wan't to have separate folders and toolpaths inside them for roughing and finishing in same pm-project?

 

Normally i make finishing toolpaths first, then copy them to another folder, change name for folder, change thicknes and recalculate them for roughing.

This macro change all thicknes in pm-project, so i should make another project for different undersize.

Message 49 of 95
GlennM.MCAM
in reply to: Anonymous

For finishing and roughing electrodes we make different projects and don't use folders.

The macro could be edited to use folders, but at this moment I don't have the time to do this.

 

Glenn


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
Message 50 of 95
Anonymous
in reply to: GlennM.MCAM

Ok

 

Br.

 

Timo

Message 51 of 95
GlennM.MCAM
in reply to: Anonymous

Last week there was a PowerMill 2019 update training and got this pdf with some tips and tricks which I've attached.

People that are having troubles with bad surface results should take a look at the last 3 pages.

 

Glenn


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
Message 52 of 95
iamcdn79
in reply to: GlennM.MCAM

How do you achieve this result after displaying your triangles?

 

Capture.PNG


Intel Core i9 13900KF CPU
128 GB Kingston Beast DDR4 SDRAM
PNY RTX A2000 6GB Video Card
WD 1 TB SSD Hard Drive
Windows 11 Pro

Message 53 of 95
GlennM.MCAM
in reply to: iamcdn79

-


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
Message 54 of 95

Hi,

You have to re-triangulate (e.g. in the point distribution tab of a toolpath, change the maximum edge length).

Thanks,
Paolo



Paolo Bastianelli

Technical Consultant
Message 55 of 95

Hi Paolo,
correct, I completely forgot this and you did tell us that (it was a hot day Smiley LOL )

Glenn


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
Message 56 of 95
cam1
in reply to: GlennM.MCAM

Hi Glenn,

This would work great for us thanks for sharing. I am having a problem though when I run it I get this error. When using the second Macro I get the same thing with the first one also. 

 

Thanks Mike

Capture1.JPGCapture.JPG

 

Message 57 of 95
GlennM.MCAM
in reply to: cam1


@cam1wrote:

Hi Glenn,

This would work great for us thanks for sharing. I am having a problem though when I run it I get this error. When using the second Macro I get the same thing with the first one also. 

 

Thanks Mike

Capture1.JPGCapture.JPG

 


Please remove '// ignore "planes" ' in both macros. My bad, sorry.

 

Glenn


Intel i7 4790 @ 3.60GHz -16GB RAM - Nvidia Quadro K620 - 250GB SSD - Win 7 Pro x64 SP1
PowerMILL Premium 2019.1 - PowerINSPECT Ultimate OMV 2017 SP6
Message 58 of 95
Anonymous
in reply to: 5axes

Hi 5axes !

 

In PM 2019 - this macro always show 0.00

 

Can it be repaired ?

 

Thanks.

Message 59 of 95
5axes
in reply to: Anonymous

It's not an issue with the macro  but certainly with your  PC configuration and the release of PMILL ( have you instaled the last hot fix ?)

 

On my pc the macro works fine in 2017, 2018 as well as 2019

Message 60 of 95
Anonymous
in reply to: iamcdn79

dd.PNG
HI iamcdn79
 
To set the triangulation you have to set the parameters that I have underlined in the picture.
I tried these parameters and I got good results, the only problem is that the calculation of the path becomes much heavier and longer so you need a good computer to do this. I advise you to save the project before making these settings.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums