.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Event and Transform

5 REPLIES 5
Reply
Message 1 of 6
wen30
597 Views, 5 Replies

Event and Transform

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)          
{

}

 

 

5 REPLIES 5
Message 2 of 6
BillZndl
in reply to: wen30

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.....
            }
        }

 

 

Message 3 of 6
wen30
in reply to: BillZndl

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?

Message 4 of 6
BillZndl
in reply to: wen30

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.

 

Message 5 of 6
Anonymous
in reply to: BillZndl

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();
            }

 

 

 

 

 

 

 

World space position

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.

 

World space displacement

1012. A 3D point that is scaled, rotated, or mirrored along with the parent, but not stretched or moved.

World direction

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.

 

Distance

1041. A real value that is scaled along with the parent entity.

 

Scale factor

1042. Also a real value that is scaled along with the parent.

 

 

 

 

 

Message 6 of 6
wen30
in reply to: wen30

Thank you all for the info.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost