If you realy want/need scripting with .NET, you can use the following Editor extension method shared by Tony Tanzillo.
This method wraps the undocumented RunCommand() method which works the same as the AutoLISP 'command' function and accepts managed types as arguments.
C#
Code:
using System;
using System.Reflection;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
namespace InsertRotateJigSample
{
// From Tony Tanzillo (using reflection)
// http://www.theswamp.org/index.php?topic=43113.msg483306#msg483306
public static class EditorExtensions
{
public static PromptStatus Command(this Editor ed, params object[] args)
{
if (Application.DocumentManager.IsApplicationContext)
throw new InvalidOperationException("Invalid execution context for Command()");
if (ed.Document != Application.DocumentManager.MdiActiveDocument)
throw new InvalidOperationException("Document is not active");
return (PromptStatus)runCommand.Invoke(ed, new object[] { args });
}
static MethodInfo runCommand = typeof(Editor).GetMethod(
"RunCommand", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
}
}
VB
Code:
Imports System.Reflection
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Namespace InsertRotateJigSample
' From Tony Tanzillo (using reflection)
' http://www.theswamp.org/index.php?topic=43113.msg483306#msg483306
Module EditorExtensions
<System.Runtime.CompilerServices.Extension> _
Public Function Command(ed As Editor, ParamArray args As Object()) As PromptStatus
If Application.DocumentManager.IsApplicationContext Then
Throw New InvalidOperationException("Invalid execution context for Command()")
End If
If ed.Document <> Application.DocumentManager.MdiActiveDocument Then
Throw New InvalidOperationException("Document is not active")
End If
Return DirectCast(runCommand.Invoke(ed, New Object() {args}), PromptStatus)
End Function
Dim runCommand As MethodInfo = GetType(Editor).GetMethod( _
"RunCommand", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.[Public])
End Module
End Namespace
Adding this module to your project, you'd be able to use the Editor.Command() method as the AutoLISP 'command' function:
Code:
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
ed.Command("_insert", "221", "\", 1.0, 1.0, "\")