TheSwamp

Code Red => .NET => Topic started by: jsr on January 02, 2011, 08:26:14 AM

Title: SendStringToExecute
Post by: jsr on January 02, 2011, 08:26:14 AM
Hi Everybody

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

Thanks.
Title: Re: SendStringToExecute
Post by: Kerry 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);
Title: Re: SendStringToExecute
Post by: jsr 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.
Title: Re: SendStringToExecute
Post by: Kerry 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.
Title: Re: SendStringToExecute
Post by: gile 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;
        }
Title: Re: SendStringToExecute
Post by: Glenn R 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 ;)