Hi, there is there anyway to track the transform when an object, for example Solid3d is moved? im trying to get the transform from the event i created with the database, for example database.ObjectModified
_db.ObjectModified += new ObjectEventHandler(OnObjectModified); void OnObjectAppended(object sender, ObjectEventArgs e) { void OnObjectAppended(object sender, ObjectEventArgs e) { }
One way is to watch for a solid3d in your event handler.
void Database_ObjectModified(object sender, ObjectEventArgs e) { if (e.DBObject.GetType().Name.Equals("solid3d")) { //Do whatever here..... } }
hi Bill, thanks for the reply. i got that e.DBObject but is there a way or property to track the changes of the transformation from e.DBObject? or maybe there is a property to get the current position or transform of a Solid3d?
sorry,
I really haven't looked into the matrix of an object at all.
here's a link from a search I just performed:
http://forums.autodesk.com/t5/NET/Extract-Matrix3D-from-a-Solid3D-Entity/m-p/2184451#M9634
I don't know if anyone has progressed on this subject or not.
Until one of the guru's post the right way of doing it here is an idea
Information at bottom is copied from docs
The code below adds Xdata to a box and uses the Extended Data group 1011(Look at info at bottom) with a 3dPoint(0,0,0)
which will update with parent object.
Look at the Attached pictue and notice the values for the Position
There are groups like scale and distince so you use other groups to see if it scaled or streched
So when the objectModified event is fired you check the Xdata to see what change and calculate what needed.
The steps below are what I did to produce the results in the picture
1. Draw a box
2. Run code below
3. Use AutoCAD Command XDLIST then enter "X" for AppName
4. Move Box
5. Run XDLIST
[CommandMethod("XdataSolid")] public void XdataSolid() { Database db = HostApplicationServices.WorkingDatabase; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ObjectId solidID = ed.GetEntity("Select Soild").ObjectId; using (Transaction tr = db.TransactionManager.StartTransaction()) { RegAppTable regTbl = (RegAppTable)tr.GetObject(db.RegAppTableId, OpenMode.ForWrite, false); RegAppTableRecord regRec = new RegAppTableRecord(); regRec.Name = "X"; regTbl.Add(regRec); tr.AddNewlyCreatedDBObject(regRec, true); Entity ent = solidID.GetObject(OpenMode.ForWrite) as Entity; ent.XData = new ResultBuffer(new TypedValue(1001, "X"), new TypedValue(1011, new Point3d(0, 0, 0))); tr.Commit(); }
1011. Unlike a simple 3D point, the world space coordinates are moved, scaled, rotated, and mirrored along with the parent entity to which the extended data belongs. The world space position is also stretched when the STRETCH command is applied to the parent entity and this point lies within the selection window.
1012. A 3D point that is scaled, rotated, or mirrored along with the parent, but not stretched or moved.
1013. Also a 3D point that is rotated, or mirrored along with the parent, but not scaled, stretched, or moved. The world direction is a normalized displacement that always has a unit length.