I'm trying to write a vb.net routine to automate this:
I need to move, rotate, and scale EVERY object in a drawing.
I assume I need to create a selection set of ALL objects.
I can't see how to do this, I know how to have a user select polylines, or whatever.
I don't see a need for user interaction here, I just want ALL the objects into a selection set that I can process.
OR
is there another way of doing this transform operation on ALL objects without creating a selection set?
In autocad it would just be: "Align", enter, "ALL" enter, enter, pick 4 points. done
"Scale" enter "P" enter "1/12" enter.
donre.
(i've tried using synchronous command sending, but I can't get that to work, so I figured the 3d transform matrix was the wasy to go)
You can use Editor.SelectAll() with or without filter to select all or targeting entities for your transformation process. You can surely achieve the effect as you described as what user see how AutoCAD does it. For example shown in following pseudo-code:
public void MoveAllEntity()
{
Document dwg=Application.DocumentManager.MdiActiveDocument;
Editor ed=dwg.Editor;
PromptSelectionResult res=ed,SelectAll();
if (res.Status==PromptStatus.OK)
{
ObjectId[] selectedIds=res.Value.GetObjectIds();
//Here you may want to highlight all the selected entities
//so the code running is more like native AutoCAD command
//Ask user to pick based point,
//you may allow user to hit Enter for a default base point
Point3d basePt=SelectBasePoint(ed);
//Ask user for point to move to
//or a distance and direction (angle)
Point3d movetOPt=SelectDestination(ed);
Matrix3d mt=DiefineMyTransformMatris(basePt, moveToPt) //define an Matrix3d for move
//Do the move
using (Transaction tran=....)
{
foreach (ObjectId id in selectedIds)
{
//Open the entity and then
ent.TransformedBy(mt);
//Unhighlight the entity if you highlighted previously
}
tran.commit()
}
}
}
As you can see, the only user interrection needed is to pick 2 points.With Editor.SelectAll(), there is no need for user interaction to select entities.
Norman Yuan
OK, thanks, that is fine & would work I'm sure, except that I'm actually getting the points from a file as this routine is to work on multiple drawings (& also do so without actually opening the files (not necessary but nice).
I guess I need to just iterate all items (geometry/text) in the dwg database via the BlockTable & then in this case for me, the model space BlockTableRecord
If you want to do the transformation in side database, then you cannot use Editor.SelectAll(), because there is not Editor for side database.
Yes, if you only target entities in ModelSpace (or given layout in paperspace), you just get the space BlockTableRecord and then loop through all entities in that space.
Norman Yuan