AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

c# Autocad Map 3D 2012 get user drawn object

1 REPLY 1
Reply
Message 1 of 2
enriquev
622 Views, 1 Reply

c# Autocad Map 3D 2012 get user drawn object

Is it possible to send a string to execute to Map and find out what objects has the user drawn in an easier way? I feel that like what I am doing is too much...

This is the command:

    acad.DocumentManager.MdiActiveDocument.SendStringToExecute("_MPOLYGON ",false,false,true);

As of now, what I do is I subscribe to the object appended event, and to the command ended event, then I call the sendStringToExecute and from there I check all the new objects coming in the DB and keep a reference to the ones I find the user has drawn.

So first:

HostApplicationServices.WorkingDatabase.ObjectAppended+=newObjectEventHandler(activeDB_ObjectAppended);

and

    acad.DocumentManager.MdiActiveDocument.CommandEnded+=newCommandEventHandler(MdiActiveDocument_CommandEnded);

While the command is executing:

void activeDB_ObjectAppended(object sender,ObjectEventArgs e){            polyDessinIds.Add(e.DBObject.Id);
}

Autocad adds objects to the database WHILE the _MPOLYGON command is being executed, so I keep a reference to all them. Autocad adds points and lines to the database while the user is drawing. For example, the first and second click that for a line seem to be put in the database. Also when a polygon is added to the working db it does not mean it is the last one. The last added object is not guaranteed to be the real object either.

Then when the command is ended, I look for the correct objectId, even if there are many polygons that were drawn, there is only 1 valid objectId that references the one or the many polygons drawn.

foreach(ObjectId obj in polyDessinIds){if(obj.IsErased==false&& obj.ObjectClass.Name=="AcDbMPolygon")
{
mPolygons
= obj;//there should be only one valid at this pointbreak;

}

I am wondering if there is a better and more reliable way to do this? Maybe something like when you prompt for selecting objects, this returns a selection set with all the objects. Is there a way to "promptForPolygon" or something similar that will just return me the new objects once the user has drawn them?

Tags (2)
1 REPLY 1
Message 2 of 2
enriquev
in reply to: enriquev

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

Post to forums  

Autodesk Design & Make Report

”Boost