效果如下:
窗体模块:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace AcTools
{public partial class MyForm : Form{public MyForm(){InitializeComponent();}private void button1_Click(object sender, EventArgs e){int num;int.TryParse(textBox1.Text,out num);Z.Drawcir(num);Z.Zoom();}}
}
主模块
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AcTools;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Colors;
using System.Runtime.CompilerServices;
using Wform = System.Windows.Forms;
using System.IO;
using System.Windows.Forms;
using Excel= Microsoft.Office.Interop.Excel.Application;
using Autodesk.AutoCAD.Windows;
//using UserControl = System.Windows.Controls.UserControl;
using System.Windows.Forms.Integration;
using Autodesk.AutoCAD.Internal;
//PaletteSet integrationnamespace AcTools
{public class Class1{[CommandMethod("xx")]public void XX(){Z.Zoom();MyForm form = new MyForm();form.Show();Z.Writemessage("已退出");}}
}
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AcTools;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Colors;
using System.Runtime.CompilerServices;
using Wform = System.Windows.Forms;
using System.IO;
using System.Windows.Forms;
using Excel= Microsoft.Office.Interop.Excel.Application;
using Autodesk.AutoCAD.Windows;
//using UserControl = System.Windows.Controls.UserControl;
using System.Windows.Forms.Integration;
using Autodesk.AutoCAD.Internal;
//PaletteSet integrationnamespace AcTools
{public static class Class1{private static PaletteSet pset;[CommandMethod("xx")]public static void XX(){ Line line = new Line(Point3d .Origin,new Point3d(100,100,0));object line2 = line.Clone();if (line2 is Line linecopy){linecopy.ReverseCurve();Z.db.AddEntityToModeSpace(linecopy);};Z.db.AddEntityToModeSpace(line);Z.Zoom();}}
}