Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Recommended Posts

Hello all. I found a couple posts via my search that led me to the "ImportFile()" function in VBS. I've imported an IGES file then saved it with the "SaveMCAs()" function. But what I can't figure out is how to save an STL file from the new .mcx file that I created. Something like an "ExportFile()" command. Is this only possible with a Chook? Any ideas? confused.gif

Link to comment
Share on other sites

I was wondering if anyone had any clues about my question above. If there is an import command in VBScript, then is there also an export function too? I need to take either my IGES file or a mastercam file and export, or "save as..." an STL file.

 

I have not found any VBScript thus far. I had an idea that maybe I could open up the mastercam file with a chook, then open up a blank STL file, and write the database information using the "wr_stl" function. Any better ideas would be much appreciated.

Link to comment
Share on other sites

Thanks for the help MasterShake. It's cool to be working internationally. I put your function prototype in my code. I also was able to get MR2 installed last night. So one of those things allowed CFile_DoFileSave to work (after I switched my paths to CStrings). I was able to open a mastercam file and output an STL file.

 

The file that was saved was in Binary formate. I"m wondering if there is anyway to specify any other parameters for saving. I need to save my STL in ASCII format. I'm thinking I'll have to use the wr_stl function. Thanks for getting me this far.

Link to comment
Share on other sites

here is my sample code.

cool.gif

code:

	FILE *fp=0;

MC_BOOL succf;

ent e;

 

DB_LIST_ENT_PTR eptr;

p_2d sel_pt;

double t=0.0;

fp=fopen("c:ascii.stl","wt");

if(fp&&MC_NOERROR==select_ent ("select surface or solid entity", &e, &eptr, sel_pt, &t, ALIVE_BIT, SURF_ID|SOLID_ID, select_color, &succf)&&succf)

{

 

wr_stl(0.003, fp, "", e.ent_idn, TRUE, TRUE);

fclose(fp);

}

 


Link to comment
Share on other sites

I'm trying to write my STL without any user input. I have some code that I used with Xform_rotate. What it does is select all of the entities in the database, and rotates each of them. Instead of requiring the user to select the surfaces or bodies to write to the STL, I'd like to simply save all of them using "get_ent". Here is a sample of my code:

 

while (bSuccf)

{

get_ent(&ptr, &e_ptr, &entity, ALIVE_BIT,

P_ID|L_ID|A_ID|S_ID|SURF_ID|SOLID_ID|SPLINE_ID|N_ID|W_ID|D_ID,

&bSuccf);

count++;

}

count--;

 

ptr = db_start;

 

while (count > 0)

{

get_ent(&ptr, &e_ptr, &entity, ALIVE_BIT,

P_ID|L_ID|A_ID|S_ID|SURF_ID|SOLID_ID|SPLINE_ID|N_ID|W_ID|D_ID,

&bSuccf);

 

if (bSuccf)

{

FILE * f=0;

f = fopen("C:Program Filesmcamxchook_testsSave_STLblank.stl", "wt");

wr_stl(0.003, f, "", '0', true, true);

fclose (f);

e_ptr = NULL;

}

count--;

}

 

I may not be using get_ent correctly. I'm open to suggestions because this method does not work. Also, do I have to use DoFileOpen to first open the file I call blank.stl? To create it, I opened notepad and saved it with the .stl extension. Any help is appreciated.

Link to comment
Share on other sites
  • 2 weeks later...

hi,

if you want to save all/selected entity,

you dont have to use get_ent() function.

smile.gif

 

 

code:

 

 

 

ent e;

DB_LIST_ENT_PTR dPtr, foundPtr;

MC_BOOL succf;

 

FILE *fp=NULL;

 

/**

* @par Purpose:

* Write the database to an open STL file

*

* @param[in] err_tol error tolerance value

* @param[in] f Pointer to the open STL file

* @param[in] fname Name of the open STL file

* @param[in] ent_idn Specific entity to output or if '0', output all, or if '-1', output only selected entities

* @param[in] ascii_data Set to TRUE if the data is to be written in ASCII text

* @param[in] silent Set to TRUE if no warnings, progress reports, or messages are to be presented to the user

*/

//all entity

fp = fopen("C:test.stl", "wt");

if(fp)

{

wr_stl(0.01, fp, "", 0, true, true);

fclose (fp);

}

 

//only selected

fp = fopen("C:test.stl", "wt");

if(fp)

{

wr_stl(0.01, fp, "", -1, true, true);

fclose (fp);

}

 

 

//specific entity by entity mask/selection mask/levels, etc..

fp = fopen("C:test.stl", "wt");

 

if(fp)

{

dPtr=db_start;

do

{

get_ent(&dPtr, &foundPtr, &e, ALIVE_BIT, SURF_ID|SOLID_ID, &succf );

if(succf&&e.eptr)

{

wr_stl(0.01, fp, "", e.ent_idn, true, true);

}

}

while(succf);

fclose (fp);

}

 

 

 


Link to comment
Share on other sites

Thanks Mastershake. I did get a similar code to what I posted above to work. I also got your code to work, that is much simpler.

 

I'm trying to learn how the section of your code e.ent_idn works. I am going to look through the help on it. I'm going to be writing some code to 1)select all entities on one level 2)select some entities on one level for a solid extrude, and 3) select entities on another level for my toolpath containment boundary.

 

Thanks again for your input, any other information/help is appreciated.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...