One way is that you pass the ObjectIdCollection of the entities you want to edit, the other one is iterating the current block.
For scaling a moving you can make a function that receive the ObjectIdCollection
Code:
public void ScaleAndMove(ObjectIdCollection objIds, double scaleFactor = 2)
{
Document currentDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
const double gridSize=5;
using (Transaction tr = currentDoc.Database.TransactionManager.StartTransaction())
{
try
{
Entity ent;
foreach (ObjectId objId in objIds)
{
//Open Object as Entity, anything that can be drew is an entity
ent = objId.GetObject(OpenMode.ForWrite) as Entity;
//Use the center of the entity as scale point
Point3d min = ent.GeometricExtents.MinPoint,
max = ent.GeometricExtents.MaxPoint,
mid = new Point3d((min.X + max.X) / 2, (min.Y + max.Y) / 2, (min.Y + max.Y) / 2);
//Scale using the selected factor
ent.TransformBy(Matrix3d.Scaling(scaleFactor, mid));
//If the entity is an attribute definition,
//it will be moved to the nearest grip point
//Assuming that the grid is size 5
if (ent is AttributeDefinition)
{
AttributeDefinition attDef = ent as AttributeDefinition;
//Use the position defined in the attDef
Point3d currentPos = attDef.Position;
//Gets the nearest point
double x = (Math.Round(currentPos.X / gridSize) * gridSize),
y = (Math.Round(currentPos.Y / gridSize) * gridSize),
z = (Math.Round(currentPos.Z / gridSize) * gridSize);
//Move
Vector3d vec = currentPos.GetVectorTo(new Point3d(x, y, z));
attDef.TransformBy(Matrix3d.Displacement(vec));
}
}
tr.Commit();
}
catch (Autodesk.AutoCAD.Runtime.Exception)
{
tr.Abort();
//Something goes wrong in AutoCAD
}
catch (System.Exception)
{
tr.Abort();
//Something else goes wrong
}
}
}