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: 

Save tools as DWG or DXF

24 REPLIES 24
SOLVED
Reply
Message 1 of 25
Anonymous
2261 Views, 24 Replies

Save tools as DWG or DXF

Hi,

 

Is it possible to save the active tool as DWG or DXF?

1.png

 

Thank you in advance,

 

24 REPLIES 24
Message 2 of 25
iamcdn79
in reply to: Anonymous

Yes as a dxf but I found it only worked when you write it out in the shank tab, the holder tab did not work for me

 

https://autode.sk/2CdCwlL


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 3 of 25
Anonymous
in reply to: iamcdn79

Hi @iamcdn79,

 

The same here for me, you can't save cutedge and holder. Do you thing it's possible to wrote a macro to output this in dxf?

 

Message 4 of 25
iamcdn79
in reply to: Anonymous

If it is possible to write a macro for that @rafael.sansao @5axes or @TK.421 would know.

 

You could import the holder portion of your holder shown in the attachment as a shank and manually enter the shank portion then write that out as a dxf


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 5 of 25
Anonymous
in reply to: iamcdn79

Thanks @iamcdn79,

 

Hope someone of them will tell or maybe help to write:-)

 

Message 6 of 25
5axes
in reply to: Anonymous

Hereafter a sample code.

The creation of the profile have been never finished . So you have to integrate the creation of the cutting profile according to the tool type. But it could be a good start for your own macro.

 

regards,

Message 7 of 25
Anonymous
in reply to: 5axes

Hi @5axes,

 

Thanks for the code, can you help me?, why I got this error?

1.png

 

Message 8 of 25
5axes
in reply to: Anonymous

Hello,

This type of macro is designed to be launch via an user menu. In this case the user menu is the menu tool. In your macro directory create a file Tool.xml with the following code :

<?xml version="1.0" ?>
<menupage>
   <button command='MACRO "ExportDXF" "%s" 0' label="Export DXF"  multiple_selection="allowed" />
</menupage>

And launch the macro by selecting the tool to export and the right button click  select the user menu and the fonction "Export DXF"

You can also modify the macro by changing the code to export the active tool info dxf.

Function Main()
{
STRING $Selected_Tool=entity('Tool','').Name

 

 

Message 9 of 25
5axes
in reply to: 5axes

One new version updated for end_mill / tip_radiused / ball_nosed / drill  tool type

 

exportdxf.jpg

Message 10 of 25
Anonymous
in reply to: 5axes

Hi @5axes,

 

It looks very good:-) great job.

 

Is it possible to give each section color.

Cut - yellow

Shank - green

Holder - red

 

And then close all lines.

1.png2.png

 

Thanks,

 

Message 11 of 25
5axes
in reply to: Anonymous

color and close the profil on the cutting side is not difficult. 

 

exportdxf_color.jpg

concerning the shank and the holder as the profil is made by PMILL , so it's not an easy modification. It's possible but you must get from the holder and shank definition the last point and create the last line.

 

 

Message 12 of 25
ps
Contributor
in reply to: 5axes

Hi 

I updated the macro to include Routing and form tools.

Message 13 of 25
rafael.sansao
in reply to: ps

Code rewritten and a little simpler. It is to work for all type of tool.

 

FUNCTION Main ( STRING $Selected_Tool ) {
	ACTIVATE TOOL $Selected_Tool
	REAL $tol_min = 0.0001
	REAL $tol_max = 0.001
	$powermill.Export.TriangleTolerance = $tol_min
	$Powermill.CurveEditor.SpunProfile.Tolerance = $tol_max
	STRING path = project_pathname(0)
	STRING $dirpath = project_pathname(0) + "/ExportTool"
	MKDIR $dirpath
	STRING $path_export = $dirpath + "/" + $Tool.Name + ".dxf"
	
	STRING pat = "export_tool_dxf"
	CREATE PATTERN $pat
	CALL Exec($path, "TIP", 1.0, 1.0, 0.0, $tol_min, $tol_max)
	CALL Exec($path, "SHANK", 0.0, 1.0, 0.0, $tol_min, $tol_max)
	CALL Exec($path, "HOLDER", 1.0, 0.0, 0.0, $tol_min, $tol_max)
	KEEP PATTERN $pat $path_export YES
	PURGE PATTERN $pat YES
}

FUNCTION Exec(STRING path, STRING name, REAL R, REAL G, REAL B, REAL tol_min, REAL tol_max) {
	STRING mName = $path + "\" + $name + '.stl'
	STRING $Cmd = "EDIT TOOL ; EXPORT_STL " + $name + " '" + $mName + "'"
	DOCOMMAND $Cmd
	IMPORT MODEL $mName
	CREATE PATTERN $name
	EDIT MODEL ALL DESELECT ALL
	EDIT MODEL $name SELECT ALL
	IF number_selected(entity('model',$name)) > 0 {
		EDIT PATTERN $name CURVEEDITOR NOGUI START
		CURVEEDITOR MODE SPUN_PROFILE
		CURVEEDITOR SPUN_PROFILE AXIS Z
		CURVEEDITOR SPUN_PROFILE ORIGIN X "0"
		CURVEEDITOR SPUN_PROFILE ORIGIN Y "0"
		CURVEEDITOR SPUN_PROFILE ORIGIN Z "0"
		CURVEEDITOR SPUN_PROFILE CREATE
		CURVEEDITOR SELECT ALL
		CURVEEDITOR COLOUR SELECTED $R $G $B
		CURVEEDITOR MODE FIT_POLYGONISE
		CURVEEDITOR FIT POLYGONISE $tol_min
		CURVEEDITOR MODE FIT_ARC
		CURVEEDITOR FIT ARC '$tol_max*10'
		CURVEEDITOR FINISH ACCEPT
	}
	PURGE MODEL $name YES
	DELETE FILE $mName
	EDIT Pattern "export_tool_dxf" INSERT Pattern $name
	PURGE PATTERN $name YES
}

Rafael Sansão

EESignature

Message 14 of 25
5axes
in reply to: rafael.sansao

EXPORT_STL ?

 

Message 15 of 25
rafael.sansao
in reply to: 5axes

Yes. The macro exports the tool temporarily in STL...
The end result is a .dxf file

Rafael Sansão

EESignature

Message 16 of 25
5axes
in reply to: rafael.sansao

Very original solution to get the result. Just a problem with SPUN_PROFILE that does not always detect the complete profile.

bug-export-dxf.jpg

Message 17 of 25
rafael.sansao
in reply to: 5axes

I performed several tests on complex tools and it worked well (seems to work fine on STL models).
Did you test using the macro and did not work? Could you send me the tool for me to test?

Rafael Sansão

EESignature

Message 18 of 25
5axes
in reply to: rafael.sansao

Yes the issue also occur with your macro as well as with the original function.

You will find herewith one template file of the tool. Just drag and drop this file in a Pmill Project.

Message 19 of 25
rafael.sansao
in reply to: 5axes

You're right. SPUN_PROFILE does not work for holder and shank (STL gets segmented), but it seems to work fine for the cutter.

Hybrid solution:

 

FUNCTION Main ( STRING $Selected_Tool ) {
	DEACTIVATE WORKPLANE
	ACTIVATE TOOL $Selected_Tool
	REAL $tol_min = 0.0001
	REAL $tol_max = 0.001
	$powermill.Export.TriangleTolerance = $tol_min
	$Powermill.CurveEditor.SpunProfile.Tolerance = $tol_max
	STRING path = project_pathname(0)
	STRING $dirpath = project_pathname(0) + "/ExportTool"
	MKDIR $dirpath
	STRING $path_export = $dirpath + "/" + $Tool.Name + ".dxf"
	
	STRING pat = "export_tool_dxf"
	CREATE PATTERN $pat
	CALL Exec_TIP($pat, $path, "TIP", 1.0, 1.0, 0.0, $tol_min, $tol_max)
	STRING $path_shank = $dirpath + "\shank.dgk"
	EXPORT TOOLSHANK ; $path_shank YES
	IF file_exists($path_shank) {
		CALL Exec_HOLDER($pat, $path_shank, 0.0, 1.0, 0.0, $Tool.Length)
	}
	STRING $path_holder = $dirpath + "\holder.dgk"
	EXPORT TOOLHOLDER ; $path_holder YES
	IF file_exists($path_holder) {
		CALL Exec_HOLDER($pat, $path_holder, 1.0, 0.0, 0.0, $Tool.Overhang)
	}
	KEEP PATTERN $pat $path_export YES
	PURGE PATTERN $pat YES
	TEXTINFO ACCEPT
}

FUNCTION Exec_TIP(STRING pat, STRING path, STRING name, REAL R, REAL G, REAL B, REAL tol_min, REAL tol_max) {
	STRING mName = $path + "\" + $name + '.stl'
	STRING $Cmd = "EDIT TOOL ; EXPORT_STL " + $name + " '" + $mName + "'"
	DOCOMMAND $Cmd
	IMPORT MODEL $mName
	CREATE PATTERN $name
	EDIT MODEL ALL DESELECT ALL
	EDIT MODEL $name SELECT ALL
	IF number_selected(entity('model',$name)) > 0 {
		EDIT PATTERN $name CURVEEDITOR NOGUI START
		CURVEEDITOR MODE SPUN_PROFILE
		CURVEEDITOR SPUN_PROFILE AXIS Z
		CURVEEDITOR SPUN_PROFILE ORIGIN X "0"
		CURVEEDITOR SPUN_PROFILE ORIGIN Y "0"
		CURVEEDITOR SPUN_PROFILE ORIGIN Z "0"
		CURVEEDITOR SPUN_PROFILE CREATE
		CURVEEDITOR SELECT ALL
		CURVEEDITOR COLOUR SELECTED $R $G $B
		CURVEEDITOR MODE FIT_POLYGONISE
		CURVEEDITOR FIT POLYGONISE $tol_min
		CURVEEDITOR MODE FIT_ARC
		CURVEEDITOR FIT ARC '$tol_max*10'
		CURVEEDITOR MODE ROTATE
		STATUS EDITING_PLANE YZ
		MODE TRANSFORM ROTATE ANGLE "-90"
		CURVEEDITOR FINISH ACCEPT
	}
	PURGE MODEL $name YES
	DELETE FILE $mName
	ACTIVATE PATTERN $pat
	EDIT PATTERN $pat INSERT Pattern $name
	EDIT PATTERN $pat DESELECT ALL
	PURGE PATTERN $name YES
}

FUNCTION Exec_HOLDER(STRING pat, STRING path_holder, REAL R, REAL G, REAL B, REAL offset) {
	EDIT PATTERN $pat INSERT FILE $path_holder
	EDIT PATTERN $pat CURVEEDITOR NOGUI START
	CURVEEDITOR COLOUR SELECTED $R $G $B
	CURVEEDITOR MODE TRANSLATE
	MODE COORDINPUT COORDINATES 0 $offset 0
	CURVEEDITOR FINISH ACCEPT
	DELETE FILE $path_holder
}

 

Rafael Sansão

EESignature

Message 20 of 25
Anonymous
in reply to: rafael.sansao

Hi @rafael.sansao,

 

I have copied you last macro, but I got this error message. How to solved

2018-10-25_2047.png

 

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report