<HTML>
<HEAD>
<script language="javascript">
// Connect to PowerShape
// const fs = require('fs');
var pshape = window.external;
// var nome cartella;
// var cartella = "ppp";
function CartellaDest_click()
{
// var fs = require('fs');
// pshape.Exec ("LET $name = model.selected");
var name = pshape.Evaluate ("model.selected");
// pshape.Exec ("LET $filenamemy = ''");
// pshape.Exec ("PRINT $filenamemy");
// document.Salva.CartellaDest.value = pshape.Evaluate ("$name");
var Filename = name;
var ModelPath = pshape.Evaluate ("model.path");
var N = Filename.substr(0,6);
if ( document.Salva.CodSt.value == "" ) {
document.Salva.CodSt.value = N;
}
// var NumPath = ModelPath.length();
// var NumName = name.length();
//var S = ModelPath.substr(0, ModelPath.length - name.length - 8 - 8 );
var npos = ModelPath.lastIndexOf("/");
var S = ModelPath.substr( 0 , npos );
var npos = S.lastIndexOf("/");
var S = S.substr( 0 , npos + 1 );
// pshape.Exec ("LET $N = RANGE($name; 1; 6 )");
// pshape.Exec ("LET $S = RANGE(model.path; 1; length(model.path) - length(model.selected) - 8 - 8)");
// document.Salva.CartellaDest.value = Full;
// VerDir = 'let bbb = directory["' + S + '"].exists';
// document.Salva.CartellaDest.value = VerDir;
// pshape.Exec (VerDir);
// var BVerDir = pshape.Evaluate ("PRINT $bbb");
// document.Salva.CartellaDest.value = BVerDir;
// pshape.Exec ("LET $full = concat($S;'DGK ';$N)");
//var CreaCartella = 'FILE CREATE DIR "' + Full + '"';
// pshape.Exec (CreaCartella);
// var Filenamemy = document.Salva.Descriz.value;
var Desc = document.Salva.Descr.value;
var Mat = document.Salva.Mat.value;
var Pz = document.Salva.Pz.value;
var Dgk = document.Salva.Estens.value;
var Cod = document.Salva.CodSt.value;
var Filenamemy = Desc + " " + Mat + " " + Pz;
if (document.getElementById('C').checked == true){
var Full = S + Dgk + " " + Cod;
document.Salva.CartellaDest.value = Full + "/" + Filenamemy;
} else {
var Full = S + Dgk + " " + Cod;
// var Filenamemy = Desc + " " + Mat + " " + Pz;
document.Salva.CartellaDest.value = Full;
}
var CreaFile = '"' + Full + '/' + Filenamemy ;
document.Salva.FileDest.value = Filenamemy + " " + Cod + "." + Dgk;
// pshape.Exec ("QUICKSELECTCOMPONENTONLY'");
// pshape.Exec ("print selection.number");
// var ControlComp = pshape.Evaluate ("selection.number");
// document.Salva.Comp.value = ControlComp;
// pshape.Exec ("FILE EXPORT WIZARD");
// pshape.Exec ("NEXT");
// pshape.Exec (CreaFile);
// pshape.Exec ("NEXT");
// pshape.Exec ("EXPORTTYPE VISIBLE");
// pshape.Exec ("NEXT");
// pshape.Exec ("EXPORTTYPE WORLD");
// pshape.Exec ("WIZEXPORT");
// pshape.Exec ("select clearlist");
pshape.Exec ("QUICK QUICKSELECTCOMPONENTONLY");
var ControlComp = pshape.Evaluate ("selection.number");
pshape.Exec ("print 'select clearlist'");
document.Salva.Comp.value = ControlComp;
} // end CartellaDest_click
function Apply_click()
{
if (document.Salva.Sel.value == "Selezionato") {
pshape.Exec ("DISPLAY BLANKEXCEPT");
}
// alert ("cosa si vede");
var Full = document.Salva.CartellaDest.value;
var Filenamemy = document.Salva.Descr.value;
var Dgk = document.Salva.Estens.value;
if ( Full != "" && document.Salva.CartellaDest.value != "") {
// document.Salva.CartellaDest.value = Full;
// var CreaCartella = 'FILE CREATE DIR "' + Full + '"';
var CreaCartella = 'FILE CREATE DIR "' + Full + '"';
pshape.Exec (CreaCartella);
// var CreaFile = '"' + document.Salva.CartellaDest.value + '/' + document.Salva.FileDest.value + '"';
// pshape.Exec ("FILE EXPORT WIZARD");
// pshape.Exec ("NEXT");
// pshape.Exec (CreaFile);
// pshape.Exec ("NEXT");
// pshape.Exec ("EXPORTTYPE VISIBLE");
// pshape.Exec ("NEXT");
// pshape.Exec ("EXPORTTYPE WORLD");
// pshape.Exec ("WIZEXPORT");
// pshape.Exec ("YES");
// pshape.Exec ("select clearlist");
var MyMacro = "let filename = '" + document.Salva.CartellaDest.value + "/" + "My_File_Export.mac'";
var CreaFile = 'PRINT "' + document.Salva.CartellaDest.value + '/' + document.Salva.FileDest.value + '"';
var RunMacro = "MACRO RUN '" + document.Salva.CartellaDest.value + "/" + "My_File_Export.mac'";
// document.Salva.FileDest.value = MyMacro;
// pshape.Exec ("let filename = 'My_File_Export.mac'");
pshape.Exec (MyMacro);
// verifica se ci sono Component
pshape.Exec ("QUICK QUICKSELECTCOMPONENTONLY");
var ControlComp = pshape.Evaluate ("selection.number");
pshape.Exec ("print 'select clearlist'");
pshape.Exec ("FILE OUTFILE OPEN REPLACE $filename");
pshape.Exec ("print 'select clearlist'");
pshape.Exec ("print 'QUICK QUICKSELECTCOMPONENTONLY'");
// pshape.Exec ("print selection.number");
document.Salva.Comp.value = ControlComp;
if ( ControlComp != "0" ) {
pshape.Exec ("print 'CONVERT COMPONENT'");
}
pshape.Exec ("print 'FILE EXPORT WIZARD'");
pshape.Exec ("print 'NEXT'");
pshape.Exec (CreaFile);
switch (document.Salva.Sel.value) {
case "Visible":
pshape.Exec ("print 'EXPORTTYPE VISIBLE'");
pshape.Exec ("print 'NEXT'");
pshape.Exec ("print 'EXPORTTYPE VISIBLE'");
break;
case "Selected":
pshape.Exec ("print 'EXPORTTYPE VISIBLE'");
pshape.Exec ("print 'NEXT'");
pshape.Exec ("print 'EXPORTTYPE VISIBLE'");
break;
case "All":
pshape.Exec ("print 'EXPORTTYPE ALL'");
pshape.Exec ("print 'NEXT'");
pshape.Exec ("print 'EXPORTTYPE ALL'");
break;
}
pshape.Exec ("print 'NEXT'");
if (document.Salva.World.value == "Active") {
pshape.Exec ("print 'EXPORTTYPE ACTIVE'");
} else if (document.Salva.World.value == "World") {
pshape.Exec ("print 'EXPORTTYPE WORLD'");
}
pshape.Exec ("print 'WIZEXPORT'");
pshape.Exec ("print 'Yes'");
pshape.Exec ("print 'select clearlist'");
if ( ControlComp != "0" ) {
pshape.Exec ("print 'UNDO'");
// pshape.Exec (,print "PRINT ERROR 'FINE ESPORTAZIONE!!!'",);
}
// if (document.Salva.Sel.value == "Selezionato") {
// pshape.Exec ("print 'DISPLAY UNBLANK'");
// }
pshape.Exec ("FILE OUTFILE CLOSE");
// document.Salva.FileDest.value = RunMacro;
pshape.Exec (RunMacro);
}
} // end of function point_click
function CHK_ON() {
if ( document.getElementById('C').checked == true ) {
document.getElementById('C').checked = true ;
}
else {
document.getElementById('C').checked = false ;
}
CartellaDest_click();
}
function MyQuit()
{
pshape.Exec ("BROWSER PSHOME");
pshape.Exec ("BROWSER HIDE");
}
</script>
</HEAD>
<BODY>
<h3>FILE EXPORT</h3>
<FORM NAME=Salva >
Part Name <INPUT TYPE="text" size="39" NAME="Descr" id="Descr" VALUE="T01" onchange="CartellaDest_click();" style="font-size: 18px ; font: bold ; color:blue;" > <p>
Material <INPUT TYPE="text" size="39" NAME="Mat" id="Mat" VALUE="MATERIAL" onchange="CartellaDest_click();" style="font-size: 18px ; font: bold ; color:blue;" > <p>
Num. Pezzi <INPUT TYPE="text" size="39" NAME="Pz" id="1pz" VALUE="1pz" onchange="CartellaDest_click();" style="font-size: 18px ; font: bold ; color:blue;" > <p>
Part Number <INPUT TYPE="text" size="31" NAME="CodSt" VALUE="" onchange="CartellaDest_click();" style="font-size: 18px ; font: bold ; color:blue;" > <p>
<INPUT TYPE=button VALUE=" UPDATE " onClick="CartellaDest_click();" style="font-size: 18px ; font: bold ; color:red;" >
<select name="Estens" id="Estens" onchange="CartellaDest_click();" style="width:100px;height:33PX;font-size: 16px ; font: bold ; color:white ; background-color:green;text-align: center;font-weight: 700;">
<option value="DGK">DGK</option>
<option value="X_T">X_T</option>
<option value="STEP">STEP</option>
<option value="IGS">IGS</option>
</select>
<select name="Sel" id="Sel" style="width:100px;height:33PX;font-size: 16px ; font: bold ; color:yellow ; background-color:blue;text-align: center;font-weight: 700;">
<option value="Visible">Visible</option>
<option value="Selected">Selected</option>
<option value="All">All</option>
</select>
<select name="World" id="World" style="width:100px;height:33PX;font-size: 16px ; font: bold ; color:yellow ; background-color:brown;text-align: center;font-weight: 700;">
<option value="World">World</option>
<option value="Active">Active</option>
</select>
<!-- Estensione <INPUT TYPE=text size="60" NAME=Estens id="Estensi" VALUE="DGK" > <p> -->
<p>
Number Components to Convert <INPUT TYPE=text size = "4" NAME=Comp VALUE="" > <p>
<hr>
<INPUT TYPE="checkbox" NAME=="C" VALUE="+ SUBDIR" id="C" title="+ SUBDIR" onclick="CHK_ON()" checked > + SUBDIR
<hr>
DIRECTORY Destination <INPUT TYPE=text size="90" NAME=CartellaDest VALUE="" style="font-size: 18px ; font: bold ; color:blue;" >
FILE Destination <INPUT TYPE=text size="90" NAME=FileDest VALUE="" style="font-size: 18px ; font: bold ; color:blue;" > <p>
<INPUT TYPE=button VALUE=" EXPORT " onClick="Apply_click();" style="font-size: 18px ; font: bold ; color:red; background-color:yellow;" >
<INPUT TYPE=button VALUE="Quit" onClick="MyQuit()" style="font-size: 18px ; font: bold ; color:yellow; background-color:blue;" >
</FORM>
</BODY>
</HTML>