精简版Circle
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Circle
{
public partial class Form1 : Form
{
private SldWorks swApp;
private string stDefaultTemplatePart;
private ModelDoc2 swModel;
private ModelView swModelView;
private ModelDocExtension swModelEx;
private FeatureManager swFeatMgr;
public Form1()
{
InitializeComponent();
}
private void bt_generate_Click(object sender, EventArgs e)
{
double length = Convert.ToDouble(tb_length.Text);
double width = Convert.ToDouble(tb_width.Text);
double high = Convert.ToDouble(tb_high.Text);
ConnectSw();
NewPart();
FrameMax();
//单位转换, mm to m
length /= 1000;
width /= 1000;
high /= 1000;
//选择基准面
swModelEx = swModel.Extension;
swModelEx.SelectByID2("上视基准面", "PLANE", 0, 0, 0, false, 0, null, 0);
//新建草图
SketchManager swSketchMgr = swModel.SketchManager;
swSketchMgr.InsertSketch(true);
swSketchMgr.CreateCornerRectangle(0, 0, 0, length, width, 0);
swSketchMgr.InsertSketch(true);
//视角
ViewShow("等轴测");
//拉伸
swModelEx.SelectByID2("草图1&#