Override/Customize AutoCAD 命令
Override/Customize AutoCAD Command
有没有办法override/customize现有的 AutoCAD 命令?
当我打电话时...
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
doc.SendStringToExecute("_.3DROTATE\n", true, false, true);
...它让我选择对象、指定基点和指定角度。
我已经有一个保存的基点,那么如何在我的代码中设置它以避免用户输入?
At Walmsley blog 你可以找到你想要的关于否决的一切。这是命令否决的示例:
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.GraphicsInterface;
namespace MyFirstOverrule
{
// This is our custom DrawableOverrule class.
// In this case we're just overruling WorldDraw
public class MyDrawOverrule : DrawableOverrule
{
public override bool WorldDraw(Drawable drawable, WorldDraw wd)
{
// Cast Drawable to Line so we can access its methods and
// properties
Line ln = (Line)drawable;
// Draw some graphics primitives
wd.Geometry.Circle(ln.StartPoint + 0.5 * ln.Delta, ln.Length / 5, ln.Normal);
// In this case we don't want the line to draw itself, nor do
// we want ViewportDraw called
return true;
}
}
public class Commands
{
//Shared member variable to store our Overrule instance
private static MyDrawOverrule _drawOverrule;
[CommandMethod("TOG")]
public static void ToggleOverrule()
{
// Initialize Overrule if first time run
if(_drawOverrule == null)
{
_drawOverrule = new MyDrawOverrule();
Overrule.AddOverrule(RXObject.GetClass(typeof(Line)), _drawOverrule, false);
Overrule.Overruling = true;
}
else
{
// Toggle Overruling on/off
Overrule.Overruling = !Overrule.Overruling;
}
// Regen is required to update changes on screen
Application.DocumentManager.MdiActiveDocument.Editor.Regen();
}
}
}
有没有办法override/customize现有的 AutoCAD 命令?
当我打电话时...
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
doc.SendStringToExecute("_.3DROTATE\n", true, false, true);
...它让我选择对象、指定基点和指定角度。 我已经有一个保存的基点,那么如何在我的代码中设置它以避免用户输入?
At Walmsley blog 你可以找到你想要的关于否决的一切。这是命令否决的示例:
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.GraphicsInterface;
namespace MyFirstOverrule
{
// This is our custom DrawableOverrule class.
// In this case we're just overruling WorldDraw
public class MyDrawOverrule : DrawableOverrule
{
public override bool WorldDraw(Drawable drawable, WorldDraw wd)
{
// Cast Drawable to Line so we can access its methods and
// properties
Line ln = (Line)drawable;
// Draw some graphics primitives
wd.Geometry.Circle(ln.StartPoint + 0.5 * ln.Delta, ln.Length / 5, ln.Normal);
// In this case we don't want the line to draw itself, nor do
// we want ViewportDraw called
return true;
}
}
public class Commands
{
//Shared member variable to store our Overrule instance
private static MyDrawOverrule _drawOverrule;
[CommandMethod("TOG")]
public static void ToggleOverrule()
{
// Initialize Overrule if first time run
if(_drawOverrule == null)
{
_drawOverrule = new MyDrawOverrule();
Overrule.AddOverrule(RXObject.GetClass(typeof(Line)), _drawOverrule, false);
Overrule.Overruling = true;
}
else
{
// Toggle Overruling on/off
Overrule.Overruling = !Overrule.Overruling;
}
// Regen is required to update changes on screen
Application.DocumentManager.MdiActiveDocument.Editor.Regen();
}
}
}