As far as I know, the Editor.Command() (this wrapper as the 2015 built-in one) needs to have all its arguments to run synchronously.
With AutoCAD 2015, the Editor.CommandAsync() allows what you want to do.
Public Async Sub TestCommand()
' ...
Await ed.CommandAsync("_.rotate", selSet, "", Editor.PauseToken, Editor.PauseToken)
' ...
End Sub
With prior versions of AutoCAD, you could easily write this in AutoLISP.
If you need .NET, you'll have to take the Jig route, here's a little C# sample.
public class CommandMethods
{
[CommandMethod("TEST")]
public void Test()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptSelectionResult selection = ed.GetSelection();
if (selection.Status != PromptStatus.OK)
return;
PromptPointResult pointResult = ed.GetPoint("\nBase point: ");
if (pointResult.Status != PromptStatus.OK)
return;
SelectionSet selSet = selection.Value;
Matrix3d ucs = ed.CurrentUserCoordinateSystem;
Point3d basePoint = pointResult.Value.TransformBy(ucs);
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Entity[] entities = new Entity[selSet.Count];
for (int i = 0; i < selSet.Count; i++)
{
entities[i] = (Entity)tr.GetObject(selSet[i].ObjectId, OpenMode.ForWrite);
}
// create a new instance of RotateJig
RotateJig jig = new RotateJig(entities, basePoint, ucs.CoordinateSystem3d.Zaxis);
// pass it to the Editor.Drag method
PromptResult result = ed.Drag(jig);
// if the user didn't cancel...
if (result.Status == PromptStatus.OK)
{
// apply the rotation to each entity
foreach (Entity entity in entities)
{
entity.TransformBy(jig.Rotation);
}
}
tr.Commit();
}
}
}
// the RotateJig inherits from DrawJid to deal with multiple entities
class RotateJig : DrawJig
{
private Entity[] entities;
private Point3d basePoint;
double angle = 0.0;
Vector3d axis;
// public property (needed from the calling method)
public Matrix3d Rotation { get; private set; }
// constructor
public RotateJig(Entity[] ents, Point3d basePoint, Vector3d axis)
{
this.entities = ents;
this.basePoint = basePoint;
this.axis = axis;
}
// dynamically rotate the entities
protected override bool WorldDraw(Autodesk.AutoCAD.GraphicsInterface.WorldDraw draw)
{
Autodesk.AutoCAD.GraphicsInterface.WorldGeometry geo = draw.Geometry;
if (geo != null)
{
geo.PushModelTransform(this.Rotation);
foreach (Entity ent in entities)
{
geo.Draw(ent);
}
geo.PopModelTransform();
}
return true;
}
// prompt the user to specify a rotation
protected override SamplerStatus Sampler(JigPrompts prompts)
{
JigPromptAngleOptions options = new JigPromptAngleOptions("\nSpecify rotation: ");
options.BasePoint = basePoint;
options.UseBasePoint = true;
options.Cursor = CursorType.RubberBand;
PromptDoubleResult result = prompts.AcquireAngle(options);
if (result.Value == angle)
{
return SamplerStatus.NoChange;
}
angle = result.Value;
this.Rotation = Matrix3d.Rotation(angle, axis, basePoint);
return SamplerStatus.OK;
}
}