how to use the saveas4 function

Dear all
i am new to the solidworks API...
currently i can draw a cylinder with the dll...and after the drawing i
want to save the part as STL format...
i looked into the API help file and found maybe saveas4 can be used.
but some errors when compiling...
cannot figure out where is the problems
void MenuItemCB(void)
{
LPMODELDOC pModelDoc;//define pModelDoc pointer
TheApplication->GetSWApp()->get_IActiveDoc(&pModelDoc);//obtain
pModelDoc pointer
LPPARTDOC pPartDoc;// define pPartDoc pointer
pModelDoc->QueryInterface(IID_IPartDoc,(LPVOID *)&pPartDoc);//obtain
pPartDoc pointer
VARIANT_BOOL retval;//define retval
pModelDoc->SelectByID(auT("Front"),auT("PLANE"),0,0,0,&retval);
pModelDoc->InsertSketch();//enter sketching drawing
double P1[3];// defind and evaluate p1 & p2
P1[0]=0;
P1[1]=0;
P1[2]=0;
double P2[3];
P2[0]=0;
P2[1]=0.1;
P2[2]=0;
pModelDoc->ICreateCenterLine ( P1, P2 );//draw the center line through
P1, P2
pModelDoc->ClearSelection();//clear selection
LPSKETCHSEGMENT retval2;//define retval2
pModelDoc->ICreateLine2 ( 0, 0, 0, 0.03, 0, 0, &retval2 );//draw line
pModelDoc->ICreateLine2 ( 0.03, 0, 0, 0.03, 0.09, 0, &retval2 );//draw
line
pModelDoc->ICreateLine2 ( 0.03, 0.09, 0, 0, 0.09, 0, &retval2);
pModelDoc->ICreateLine2 ( 0, 0.09, 0, 0, 0, 0, &retval2 );//draw line
pModelDoc->InsertSketch();//quit sketch
VARIANT_BOOL retvala;//define retvala
VARIANT_BOOL retvalb;//define retvalb
VARIANT_BOOL retvalc;//define retvalc
VARIANT_BOOL retvald;//define retvald
VARIANT_BOOL retvale;//define retvale
VARIANT_BOOL retvalf;
pModelDoc->SelectByID(auT("Line2"), auT("SKETCHSEGMENT"),0,
0,0,&retvala);//
pModelDoc->SelectByID(auT("Line3"), auT("SKETCHSEGMENT"),0,
0,0,&retvalb);
pModelDoc->SelectByID(auT("Line4"),
auT("SKETCHSEGMENT"),0,0,0,&retvalc);
pModelDoc->SelectByID(auT("Line5"),
auT("SKETCHSEGMENT"),0,0,0,&retvald);
pModelDoc->SelectByID(auT("Point2"),
auT("SKETCHPOINT"),0,0,0,&retvale); //
pPartDoc->FeatureRevolve (6.28318530718, 0, 0, 0);//
pModelDoc->BlankSketch ( );//
pModelDoc->ShowNamedView2(auT("*Isometric"),7);//
pModelDoc->ViewZoomtofit2();//
////////the above codes are used to draw the cylinder and clear the
sketch
pModelDoc->SaveAs4("Cylinder.stl", swSaveAsCurrentVersion,
swSaveAsOptions_SaveReferenced, &retvalf);
/////this want to be added to save the part as STL format...
but the compiling errors is that error C2039: 'SaveAs4' : is not a
member of 'IModelDoc'
what is the problem?
and also i am not sure if it is right to define the parameters in the
saveas4 as swSaveAsCurrentVersion, swSaveAsOptions_SaveReferenced,
&retvalf);
thanks for all the help
Reply to
syshieley
Loading thread data ...
Running a simple record macro that accomplishes largely the same thing, SW auto inserts "Part.SaveAs2", which brings up a dialog box asking whether to export the selected body, or all bodies. Once confirmed, the stl is exported. Not having looked through the formatting for the command, it may be possible to auto-set the option, so that one does not have to contend with the dialog box.
Reply to
Brian
according to one of google friends's reply, i used MODELDOC2 other than MODELDOC, the problem solved...thanks so much finally i used the function as below: pModelDoc->SaveAs4(auT("D:\\Cylinder\\Cylinder.stl"), 0, 1, NULL, NULL, &retvalf);
it works
thanks
Reply to
syshieley

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.