Save File Example (C#)
This example shows how to save a file.
//-----------------------------------------------------------------
// Preconditions: Open a document.
//
// Postconditions: The model is zoomed to fit in the graphics area
// and the document is saved.
//------------------------------------------------------------------
using
Microsoft.VisualBasic;
using
System;
using
System.Collections;
using
System.Collections.Generic;
using
System.Data;
using
System.Diagnostics;
using
SolidWorks.Interop.sldworks;
using
SolidWorks.Interop.swconst;
using
System.Runtime.InteropServices;
namespace
SaveFile_CSharp.csproj
{
partial
class
SolidWorksMacro
{
ModelDoc2
swModel;
bool
boolstatus;
int
lErrors;
int
lWarnings;
public
void Main()
{
swModel = (ModelDoc2)swApp.ActiveDoc;
swApp.Visible = true;
// Make a change
swModel.ViewZoomtofit2();
boolstatus = swModel.Save3((int)swSaveAsOptions_e.swSaveAsOptions_Silent,
ref lErrors,
ref
lWarnings);
// Errors
Debug.Print("Errors
as defined in swFileSaveError_e: " +
lErrors);
// Warnings
Debug.Print("Warnings
as defined in swFileSaveWarning_e: " +
lWarnings);
}
public
SldWorks
swApp;
}
}