Hi Jerry,
My VBA bites, so maybe you can translate it. I tested this in a few ports, some of them rotated (dview) and it seemed to work.. YMMV, but I hope it gets you started.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
using BricscadApp;
using BricscadDb;
using RxNet.ApplicationServices;
using RxNet.Runtime;
using RxNet.Geometry;
using RxNet.RxGlobal;
namespace Bricscad
{
public static class Commands
{
// from papaerspace vp is active
[CommandMethod("doit")]
public static void test01()
{
try
{
// get app stuff
var app = Application.AcadApplication as AcadApplication;
var doc = app.ActiveDocument;
var mspace = doc.ModelSpace;
GlobalFunctions.MSpace();
//select an entity and copy
object opnt, oent, pairs = null;
doc.Utility.GetEntity(out oent, out opnt, "Select Entity");
AcadEntity entity = oent as AcadEntity;
AcadEntity[] ocol = { entity };
object[] ncol = doc.CopyObjects((object)ocol, doc.PaperSpace, ref pairs);
AcadEntity nentity = ncol[0] as AcadEntity;
// get the center of both entities bounding box
Point3d cenent = getBBCenter(entity);
Point3d cennent = getBBCenter(nentity);
// scale
nentity.ScaleEntity(cennent.ToArray(), doc.ActivePViewport.CustomScale);
// rotate
nentity.Rotate(cennent.ToArray(), doc.ActivePViewport.TwistAngle);
// move
nentity.Move(cennent.ToArray(),
doc.Utility.TranslateCoordinates(
cenent.ToArray(), AcCoordinateSystem.acUCS, AcCoordinateSystem.acPaperSpaceDCS, 0));
// delete
entity.Delete();
GlobalFunctions.PSpace();
}
catch (System.Exception ex)
{
GlobalFunctions.Printf("\n{0}\n{1}",
ex.Message, ex.StackTrace);
}
}
static Point3d getBBCenter(AcadEntity ent)
{
object omin, omax;
ent.GetBoundingBox(out omin, out omax);
Point3d min = new Point3d((double[])omin);
Point3d max = new Point3d((double[])omax);
return new Point3d(min[0] + ((max[0] - min[0]) / 2),
min[1] + ((max[1] - min[1]) / 2), 0);
}
}
}