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

Export Wizard with Visual Basic

4 REPLIES 4
Reply
Message 1 of 5
hugo_wy
442 Views, 4 Replies

Export Wizard with Visual Basic

Hi.

I am using PowerShape 2015 R2 and Visual Basic 2010 Express.

I am doing a program and i am stuck with this situation.


I need do export everything that is VISIBLE.

 

If i use this macro and run it in PowerShape, it works fine.
FILE EXPORT WIZARD
NEXT
D:\Moldes\tmp_elec.dgk
EXPORTTYPE VISIBLE
WIZEXPORT
EVERYTHING PARTIALBOX

 

But if i use it with Visual Basic 2010, don´t work.
PSHAPE.Execute("FILE EXPORT WIZARD")
PSHAPE.Execute("NEXT")
PSHAPE.Execute("D:\Moldes\tmp_elec.dgk")        'It stops here. Don´t use the path.
PSHAPE.Execute("EXPORTTYPE VISIBLE")
PSHAPE.Execute("WIZEXPORT")
PSHAPE.Execute("EVERYTHING PARTIALBOX")

 

Note:
This works in Visual Basic, but don´t export everything that is VISIBLE, like "Workplanes" that aren´t activated.
PSHAPE.Execute("FILE EXPORT D:\Moldes\tmp_elec.dgk")

4 REPLIES 4
Message 2 of 5
DG_APPS
in reply to: hugo_wy
Message 3 of 5
DG_APPS
in reply to: hugo_wy

<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>
Message 4 of 5
DG_APPS
in reply to: DG_APPS

WRITE HTML IN JAVASCRIPT FOR SAVE FILE DKG WITH VISIBLE

 

pshape.Exec ("print 'EXPORTTYPE VISIBLE'");
pshape.Exec ("print 'NEXT'");
pshape.Exec ("print 'EXPORTTYPE VISIBLE'");
Message 5 of 5
DG_APPS
in reply to: hugo_wy

SEE MY "function Apply_click()"

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

Post to forums  

Autodesk Design & Make Report