Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8916409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:14:09+00:00 2026-06-15T05:14:09+00:00

Is it possible to send a string to execute to Map and find out

  • 0

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 += 
new ObjectEventHandler(activeDB_ObjectAppended);

and

    acad.DocumentManager.MdiActiveDocument.CommandEnded += 
new CommandEventHandler(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 point
             break;
            }
 }

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:14:10+00:00Added an answer on June 15, 2026 at 5:14 am

    I don’t think you need all of that code, try to play with:

    ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.SelectLast()
    

    Which should give you the last entity drawn or used.

    Some more explanation here:

    http://72.77.202.9/index.php?topic=20267.0
    

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to find a way to create commands that I can send to
Possible Duplicate: String won't url encode in iOS I am using ASIHttpRequest to send
Is it possible to send pre-compressed files that are contained within an EARfile? More
is it possible to send 2 consecutive TCP packets out as seen in this
Is it possible to execute a String as method? Let's say I have a
I have a method send() that I wish to execute/call every 1 second. I'm
Why is it possible to send in a WCF DataService the following JSON string:
Is it possible to send an intent only to one service when this one
Is it possible to send data to another C++ program, without being able to
is it possible to send back two parameters when calling a delegate method? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.