.NET

Reply
Valued Contributor
GrzesiekGP
Posts: 67
Registered: ‎02-03-2012
Message 1 of 4 (1,406 Views)
Accepted Solution

SendStringToExecute and echoCommand

1406 Views, 3 Replies
03-19-2013 12:33 AM

Hello,

 

I've searched a lot, but I didn't find any solution for my problem.

 

I've function written in C#:

    [CommandMethod("GDF")]
        public void doDimLinear()
        {
            DF.doDimLinear();
        }

 In DF class, in doDimLinear function at the end I have:

doc.SendStringToExecute("dimlinear ", false, false, false);

 

And everything works OK, my function is switching layer, setting dimension style and invoking dimlinear function.

 

But when I want to repeat last command (by spacebar, right mouse) I have dimlinear command instead of GDF.

 

Can anyone help me?

My guees is you have to use acedCmd instead

Search for this  method here

http://adndevblog.typepad.com/autocad/

 

Quick example, works good on A2010

 [System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", EntryPoint = "acedCmd", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
extern static private int acedCmd(IntPtr resbuf);
[CommandMethod("dimlin")]
public void acedCmdDimLinear()
{
ResultBuffer rb = new ResultBuffer();
// RTSTR = 5005
rb.Add(new TypedValue(5005, "_.DIMLINEAR"));
// start the insert command
acedCmd(rb.UnmanagedObject);
bool quit = false;
// loop round while the insert command is active
while (!quit)
{
// see what commands are active
string cmdNames = (string)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("CMDNAMES");
// if the INSERT command is active
if (cmdNames.ToUpper().IndexOf("DIMLINEAR") >= 0)
{
// then send a PAUSE to the command line
rb = new ResultBuffer();
// RTSTR = 5005 - send a user 3 pause to the command line
rb.Add(new TypedValue(5005, "\\")); rb.Add(new TypedValue(5005, "\\")); rb.Add(new TypedValue(5005, "\\"));
acedCmd(rb.UnmanagedObject);
}
else
// otherwise quit
quit = true;
}
}

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 4 (1,391 Views)

Re: SendStringToExecute and echoCommand

03-19-2013 02:33 AM in reply to: GrzesiekGP

My guees is you have to use acedCmd instead

Search for this  method here

http://adndevblog.typepad.com/autocad/

 

Quick example, works good on A2010

        [System.Security.SuppressUnmanagedCodeSecurity]
        [DllImport("acad.exe", EntryPoint = "acedCmd", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
        extern static private int acedCmd(IntPtr resbuf);

        [CommandMethod("dimlin")]

        public void acedCmdDimLinear()
        {

            ResultBuffer rb = new ResultBuffer();

            // RTSTR = 5005

            rb.Add(new TypedValue(5005, "_.DIMLINEAR"));

            // start the insert command

            acedCmd(rb.UnmanagedObject);



            bool quit = false;

            // loop round while the insert command is active

            while (!quit)
            {

                // see what commands are active

                string cmdNames = (string)Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("CMDNAMES");

                // if the INSERT command is active

                if (cmdNames.ToUpper().IndexOf("DIMLINEAR") >= 0)
                {

                    // then send a PAUSE to the command line

                    rb = new ResultBuffer();

                    // RTSTR = 5005 - send a user 3 pause to the command line

                    rb.Add(new TypedValue(5005, "\\")); rb.Add(new TypedValue(5005, "\\")); rb.Add(new TypedValue(5005, "\\"));

                    acedCmd(rb.UnmanagedObject);

                }

                else

                    // otherwise quit

                    quit = true;

            }

        }

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
GrzesiekGP
Posts: 67
Registered: ‎02-03-2012
Message 3 of 4 (1,383 Views)

Re: SendStringToExecute and echoCommand

03-19-2013 03:27 AM in reply to: Hallex

Seems to work:

       ResultBuffer rb = new ResultBuffer();
            // RTSTR = 5005
            rb.Add(new TypedValue(5005, "_.dimlinear"));
            utilities.acedCmd(rb.UnmanagedObject);

 

Thank you!

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 4 of 4 (1,374 Views)

Re: SendStringToExecute and echoCommand

03-19-2013 03:49 AM in reply to: GrzesiekGP

Glad you get it worked

Cheers :smileyhappy:

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.