Author Topic: SendStringToExecute  (Read 5204 times)

0 Members and 1 Guest are viewing this topic.

jsr

  • Guest
SendStringToExecute
« on: January 02, 2011, 08:26:14 AM »
Hi Everybody

Just a little query, Can we use only Hard Coded values in SendStringToExecute().

Thanks.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: SendStringToExecute
« Reply #1 on: January 02, 2011, 09:08:09 AM »

no, variables work
Code: [Select]
    string fullCmdLine = string.Format("_{0}\n", mnuItem.CommandName);
    Application.DocumentManager.MdiActiveDocument.SendStringToExecute(fullCmdLine, false, false, true);
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

jsr

  • Guest
Re: SendStringToExecute
« Reply #2 on: January 03, 2011, 01:17:20 AM »
Thanks Kerry

Can we use PAUSE or something equivalent to it inside the String passed to SendStringToExecute(). I mean instead of providing hard coded coordinate values can we allow user to pick points by himself, the way we do in autolisp.

Regards.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: SendStringToExecute
« Reply #3 on: January 03, 2011, 02:18:25 AM »

I have no idea, never tried it :)

My initial thought was that PAUSE is a legitimate symbol so perhaps it may work. Probably worth a try.

My next thought was why not select the points or entities from .NET and pass them with the command.

My next thought was that without sufficient information as to your intent I may as well stop talking to myself and have a nice glass of wine and think about something less taxing.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: SendStringToExecute
« Reply #4 on: January 19, 2011, 03:23:26 PM »
Hi,

I had to implement a 'pause' within a command today.
From a modeless dialog (palette) button I needed to launch the DTEXT command and wanted to avoid the user to specify size and rotation.
I use doc.SendStringToExecute because it's the only way I found to give the focus to AutoCAD window immediately: when I try the ed.GetPoint first, I have to click twice before being able to specify a point.

So, here's the way I figured it using a CommandWillStart event handler:

Code: [Select]
        private void cmdDoIt_Click(object sender, EventArgs e)
        {
            using (DocumentLock docLock = _doc.LockDocument())
            {
                // register the event handler
                _doc.CommandWillStart += new CommandEventHandler(PauseForPoint);

                // launch the command
                _doc.SendStringToExecute("_dtext ", true, false, false);
            }
        }

        void PauseForPoint(object sender, CommandEventArgs e)
        {
            // prompt for a point
            PromptPointOptions ppo = new PromptPointOptions("\nSpecify the text start point: ");
            PromptPointResult ppr = ed.GetPoint(ppo);
           
            if (ppr.Status == PromptStatus.OK)
            {
                // continue the command
                Autodesk.AutoCAD.Geometry.Point3d pt = ppr.Value;
                string cmd = string.Format("{0},{1},{2}   ", pt.X, pt.Y, pt.Z);
                _doc.SendStringToExecute(cmd, false, false, false);
            }
            else
                // cancel the command (escape)
                _doc.SendStringToExecute("\x1B", false, false, false);

            // unregister the event handler
            _doc.CommandWillStart -= PauseForPoint;
        }
Speaking English as a French Frog

Glenn R

  • Guest
Re: SendStringToExecute
« Reply #5 on: January 19, 2011, 05:19:09 PM »

I have no idea, never tried it :)

My initial thought was that PAUSE is a legitimate symbol so perhaps it may work. Probably worth a try.

My next thought was why not select the points or entities from .NET and pass them with the command.

My next thought was that without sufficient information as to your intent I may as well stop talking to myself and have a nice glass of wine and think about something less taxing.

ROFLMAO! That's exactly the way I work as well ;)