Ah! Thank you sir. Alright I got it to do everything I need... Almost...
The only issue I have is that some of our tool names have a "/" forward slash in them. We have some tools that have fraction endmill descriptions(1/4 Endmill). So we have some tool names with a forward slash in them. Or like our threadmills, are made for both a 8/10-32 thread pitch.
These forward slashes mess with the Toollist. I think it has to do with the creation of the .jpg file. It populates the data in the table but the link to the picture is broken. In the folder there is no picture. I am not sure how to proceed with fixing this problem.
//-------------------------------------------------------------------------------------
// Ouvre un fichier pour écrire le tableau outil (Type HTML)
// Liste tous les outils
//
// Modif 06/06/2016 : Export via ecriture fichier
// Modif 06/07/2017 : Gestion des espaces dans les noms des projets
// : Format pour Chrome ou IE
// Modify: 7/20/2017: Added code to organize tools in correct order. All changes marked V1 CBJ
// Modify: 7/26/2017: Added continue code $tp must be a french thing? All changes marked V2 CBJ
//--------------------------------------------------------------------------------------
DIALOGS MESSAGE OFF
DIALOGS ERROR OFF
ECHO OFF DCPDEBUG UNTRACE COMMAND ACCEPT
//Check the name of the project and if it have been already save
STRING $projectName = project_pathname(1)
STRING Msg = ""
STRING Cmd = ""
IF $projectName == "" {
$Msg = "Unable to create documents for export, you must first save the project!"
MESSAGE ERROR $Msg
MACRO ABORT
}
// Création d'un répertoire Export_ExportTool dans le Projet en cours
// Répertoire Export ExportTool
STRING $ExportToolTempDir = project_pathname(0) + "/Tool_List"
MKDIR $ExportToolTempDir
STRING $ExportToolImg = ''
STRING $ToolName = ''
STRING $ModiToolName = ''
// Definition Fichier Html
STRING $Ligne=''
STRING $Fichier=$ExportToolTempDir+'/Tool_List.html'
//Ouverture fichier
FILE OPEN $Fichier FOR WRITE AS filename
$Ligne = "<html>"
FILE WRITE $Ligne TO filename
$Ligne = "<head>"
FILE WRITE $Ligne TO filename
$Ligne = "<title>Tool List</title>"
FILE WRITE $Ligne TO filename
$Ligne = "</head>"
FILE WRITE $Ligne TO filename
$Ligne = "<body lang=FR>"
FILE WRITE $Ligne TO filename
$Ligne = "<H1>"+$projectName + "</H1>"
FILE WRITE $Ligne TO filename
// Reorders Tools By Tool Number
FOREACH tl IN reverse(sort(folder('tool'),'number')) {
// Orders tools in project, added reverse to change order V1
ORDERSESSION Tool $tl.name FIRST
}
$Ligne = "<table border=1 cellspacing=1 cellpadding=1>"
FILE WRITE $Ligne TO filename
// Première ligne
$Ligne = "<TR>"
FILE WRITE $Ligne TO filename
$Ligne = "<TD><H3>Image</H3></TD><TD><H3>Name</H3></TD><TD><H3>Number</H3></TD><TD><H3>Diameter</H3></TD><TD><H3>Type</H3></TD><TD><H3>Corner Radius</H3></TD><TD><H3>Flute Length</H3></TD><TD><H3>Stick Out Length</H3></TD><TD><H3>Tool Overall Length</H3></TD><TD><H3>Holder</H3></TD>"
FILE WRITE $Ligne TO filename
$Ligne = "</TR>"
FILE WRITE $Ligne TO filename
/// Liste tous les outils
FOREACH tp IN folder('Tool') {
IF $tp.Number.value == 0 {
CONTINUE
//Checks tool number, if zero skips V2
}
// Depuis les Outils
$Ligne = "<TR>"
FILE WRITE $Ligne TO filename
// Image
$Ligne = "<TD>"
FILE WRITE $Ligne TO filename
$Ligne = '<div align="' + 'center"' + '>'
FILE WRITE $Ligne TO filename
// CREATION IMAGE
$ToolName = $tp.name
$ModiToolName=REPLACE($ToolName," ","_")
$ExportToolImg = $ModiToolName + ".jpg"
$ExportToolImg = REPLACE($ExportToolImg," ","_")
$ExportToolImg = $ExportToolTempDir + "/" + $ExportToolImg
$Cmd='FORM RAISE TOOLASSPREVIEWFORM "' + $ToolName + '"'
DOCOMMAND $Cmd
/// WAIT FORM Indispensable car sinon la Macro plante
// Il faut attendre la forme pour executer la suite
/// MACRO PAUSE "Outil $ToolName : $ExportToolImg"
WAIT FORM
// Generation Tool Preview
$Cmd='EXPORT TOOLASSEMBLYPREVIEW FILE "' + $ExportToolImg +'"'
DOCOMMAND $Cmd
YES
FORM CANCEL TOOLASSPREVIEWFORM
// DEFINITION IMAGE
// Pour Chrome
$Ligne = '<img src="./' + $ModiToolName + ".jpg" + '" alt="' + $ToolName + '"' + ' height="' + '10%"' +' />'
// Pour IE
//$Ligne = '<img src="./' + $ModiToolName + ".jpg" + '" alt="' + $ToolName + '"' + ' height="' + '100p"' +' />'
FILE WRITE $Ligne TO filename
$Ligne = "</div>"
FILE WRITE $Ligne TO filename
$Ligne = "</TD>"
FILE WRITE $Ligne TO filename
// Infos Outils
$Ligne = "<TD>"+$tp.name + "</TD><TD>" +$tp.Number.Value + "</TD><TD>" + round($tp.Diameter,3) + "</TD><TD>" + $tp.Type+ "</TD><TD>" + round($tp.TipRadius,3) + "</TD><TD>" + round($tp.Length,3) + "</TD><TD>" + round($tp.Overhang,3) + "</TD><TD>" + round(gauge_length($tp),3)+ "</TD><TD>" + $tp.HolderName + "</TD>"
FILE WRITE $Ligne TO filename
$Ligne = "</TR>"
FILE WRITE $Ligne TO filename
}
$Ligne = "</table>"
FILE WRITE $Ligne TO filename
$Ligne = "</body>"
FILE WRITE $Ligne TO filename
$Ligne = "</html>"
FILE WRITE $Ligne TO filename
FILE CLOSE filename
MESSAGE INFO "Export Finished: $Fichier"
// Ouverture fichier avec application associée
ole fileaction 'open' $Fichier