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: 

Export/save tool holder

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
1017 Views, 5 Replies

Export/save tool holder

Trying to export some tool holders from someone else's project (so I don't know the specific holders) so I can simulate in vericut. annoyingly I have to export as a DGK, open in powershape, export DXF, open in fusion360 and create a revolved solid from that profile, export as STL or Iges, then open in vericut. however, I can live with that.

 

Now I can't even export as anything other than a DGK when I click save tool holder from the tool settings box. when i select DXF for example, choose a file name and click save, no file ever gets created! 

Labels (1)
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

To export dxf:

FUNCTION MAIN {
//
// Save active tool holder to dgk, and convert to dxf
// Sample macro (without error handling) for Autodesk Manufacturing Data Exchange Utility COM-object
// For prepare read Autodesk Manufacturing Data Exchange Utility Help  '-Registering the Autodesk Manufacturing Data Exchange Utility as a COM object'
// This macro calls the Powershell script, and may need to be configured for the operating system to run properly.
   IF NOT entity_exists('tool','') {
      MESSAGE INFO 'Please activate tool'
      RETURN
   }
   ENTITY T=entity('tool','')
   IF size($T.HolderSetValues) == 0 {
      MESSAGE INFO 'Missing holder'
      RETURN
   }
   STRING DXF=""
   $DXF=FILESELECT "Please select DXF file"
   IF lcase(substring($DXF,length($DXF)-4)) != '.dxf' {
      RETURN
   }
   STRING DN=dirname($DXF)
   STRING DGK=substring($DXF,0,length($DXF)-3)+'dgk'
   STRING CmdText='EXPORT TOOLHOLDER ; FILESAVE "'+$DGK+'"'
   DoCommand $CmdText
   STRING PS1=$DN+'\ExpHolderDXF.ps1'
   STRING Success=$DN+'\Success.txt'
   STRING Bat=$DN+'\ExpHolderDXF.bat'
   IF file_exists($DXF) {
      DELETE FILE $DXF
   }
   IF file_exists($PS1) {
      DELETE FILE $PS1
   }
   IF file_exists($Success) {
      DELETE FILE $Success
   }
   IF file_exists($Bat) {
      DELETE FILE $Bat
   }   
// Create Exchange COM object with powershell
// See Autodesk Manufacturing Data Exchange Utility Help -'The COM interface'
   $CmdText='$'+'SDX=New-Object -Comobject sdx.DelcamExchange'
   $CmdText=$CmdText+crlf+'$'+'SDX.Attach()'
   $CmdText=$CmdText+crlf+'$'+'SDX.Option("INPUT_FORMAT") = "dgk"'
   $CmdText=$CmdText+crlf+'$'+'SDX.Option("OUTPUT_FORMAT") = "AutoCad"'
   $CmdText=$CmdText+crlf+'$'+'SDX.Option("INPUT_FILE") = "'+$DGK+'"'
   $CmdText=$CmdText+crlf+'$'+'SDX.Option("OUTPUT_FILE") = "'+$DXF+'"'
   $CmdText=$CmdText+crlf+'$'+'SDX.Execute()'
   $CmdText=$CmdText+crlf+' WHILE (' + '$' + 'SDX.Finished() -ne 1 ) { }'
   $CmdText=$CmdText+crlf+'$'+'SDX.Detach()'
   $CmdText=$CmdText+crlf+'0 | Out-File -Filepath "'+$Success+'"'
   FILE OPEN $PS1 FOR WRITE AS output
   FILE WRITE  $CmdText TO output
   FILE CLOSE output
   $CmdText='powershell -file "'+$PS1+'"'
   FILE OPEN $bat FOR WRITE AS output
   FILE WRITE  $CmdText TO output
   FILE CLOSE output
   
   OLE FILEACTION "open" $Bat
// Waiting
   WHILE NOT file_exists($Success) {
      INT I=1
   }
   DELETE FILE $PS1
   DELETE FILE $BAT
   DELETE FILE $Success
   IF file_exists($DXF) {
       MESSAGE INFO $DXF +' created'
   } ELSE {
      MESSAGE INFO 'Error occured'
   }

}
Message 3 of 6
5axes
in reply to: Anonymous

Different solution to do that :

 

  • You can export from powermill directly the Holder under the STL Format and use this STL file in Vericut 
// Export l'outil active en 3D STL

// Export au format métrique
$powermill.export.OutputMetricSTL = 1
// Définir la tolérance de triangulation
$powermill.Export.TriangleTolerance = 0.1

STRING $Tname=$tool.name
STRING $Filename="C:\temp\" + $Tname + ".stl"

// Export avec TIP + SHANK + Holder pour outil complet
EDIT TOOL $Tname EXPORT_STL TIP SHANK HOLDER NO_OFFSET $Filename
  • You can export directly from Powermill under the STL format
//------------------------------------------------------------------------------------------------------------------
//
// Export du porte-outil au format DXF 
//
//------------------------------------------------------------------------------------------------------------------
//
// Macro à lancer depuis un menu utilisateur Tool.
// Exemple fichier tool.xml à mettre dans le répertoire macro
// Ne pas oublier de sauver le projet avant l'export .. les fichiers TXF seront sauver dans le projet dossier Export Tool
//
//---------------------------------------------------------------------------------------------------
// <?xml version="1.0" ?>
//<menupage>
//   <button command='MACRO "ExportDXF" "%s"' label="Export DXF"  multiple_selection="allowed" />
//</menupage>
//---------------------------------------------------------------------------------------------------
// Variable $Selected_Tool : Nom de l'outil sélectionné
//
// Version 1.0 du 20/07/2017 PowerMILL 2017
// Version 1.1 du 14/10/2018 PowerMILL 2017 Export  end_mill / tip_radiused / ball_nosed / drill
// Version 1.2 du 17/10/2019 PowerMILL 2019 Export  end_mill / tip_radiused / ball_nosed / drill / form / routing
//---------------------------------------------------------------------------------------------------
FUNCTION Main ( STRING $Selected_Tool ) {

	  STRING $ProjectName = project_pathname(1)
	  
	  IF $ProjectName == "" {
		STRING $Msg = "Impossible to export the Model as a DXF file, You need first save your Project !"
		MESSAGE ERROR $Msg
		MACRO ABORT 
	  }
  
	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
}
  • You can use my tool http://5axes.free.fr/Outil.htm to import a PowerMill Database and export the tool directly under the Vericut Format or any other Cam Format
Message 4 of 6
Michaelangelo631
in reply to: 5axes

@5axes 

 

 I was trying to run your macro to export the holder as a dxf.  I got an error and was not sure why.  Can you give me a hand when you get a chance.

 

Regards,

Mike

Message 5 of 6
5axes
in reply to: Michaelangelo631

this macro must be launch via an user menu by selecting the tool to export. 

Tool.xml 

<?xml version="1.0" ?>
<menupage>
   <button command='MACRO "ExportDXF" "%s"' label="Export DXF"  multiple_selection="allowed" />
</menupage>
Message 6 of 6
roberto_perez
in reply to: 5axes

no funciona

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report