using System ;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Interop;//添加Autocad(即com)引用
using Autodesk.AutoCAD.Interop.Common;//添加axdblib(即dbx)引用
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
[assembly: CommandClass(typeof(ClassLibrary.CQSClass))]
namespace ClassLibrary
{
/// <summary>
/// Summary description for CQSClass.
/// </summary>
public class CQSClass
{
public CQSClass()
{
//
// TODO: Add constructor logic here
//
}
// Define Command "AsdkCmd1"
//师兄 QQ 361865648 解决群中同志们的问题: 如何建立用户坐标系
[CommandMethod("myucs")]
static public void test() // This method can have any name
{
// Put your command code here
//如何建立用户坐标系?如何建立旋转的ucs?
//六行解决问题
AcadDocument doc=(AcadDocument)Application.DocumentManager.MdiActiveDocument.AcadDocument;
double[] p0={10,10,0};//圆点
double[] p1={10,15,0};//x轴方向
double[] p2={-10,10,0};//Y轴方向
//增加临时ucs(用户坐标系)
AcadUCS myucs=doc.UserCoordinateSystems.Add(p0,p1,p2,"myucs");
doc.ActiveUCS=myucs;//将临时坐标系设为当前坐标系
}
}
}