.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Send Command Executes after exiting command method

25 REPLIES 25
Reply
Message 1 of 26
chockalingam
6012 Views, 25 Replies

Send Command Executes after exiting command method

Hi,

  I used send command for Export Layout

  But the line only executes after exiting command method.

 Can anyone help in this case.

 

thanks in advance.

25 REPLIES 25
Message 21 of 26

Hi Everyone! I want to use this code in .net 2.0 and there is no LINQ. So I am using a library called LINQBridge to implement LINQ Objects but still i have problem with piece of code that needs linq.lambda.expressions ! Can Anyone Help Me? (In my case i need to use commands syncronously in autocad 2013)

Message 22 of 26
_gile
in reply to: alisepehrnia77

Hi,

 

AutoCAD 2013 installs the .NET Framewok 4.0.

Why don't you target it?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 23 of 26
alisepehrnia77
in reply to: _gile

Hi again!

Sorry i was wrong about my case. I need to run it for Autocad 2007, 2008 and 2009.

Any help would be appreciated

Message 24 of 26
_gile
in reply to: alisepehrnia77

You can try this way (also from Tony Tanzillo) which does not use Linq.

 

    public static class EditoExtension
    {
        static MethodInfo runCommand = 
            typeof(Editor).GetMethod("RunCommand", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

        public static PromptStatus Command(this Editor ed, params object[] args)
        {
            if (Application.DocumentManager.IsApplicationContext)
                throw new InvalidOperationException("Invalid execution context for Command()");
            if (ed.Document != Application.DocumentManager.MdiActiveDocument)
                throw new InvalidOperationException("Document is not active");
            return (PromptStatus)runCommand.Invoke(ed, new object[] { args });
        }
    }

 

 

If it still doesn't work, you have to P/Invoke the unmanaged acedCmd method.

 

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

        /// <summary>
        /// Call an AutoCAD command (works synchronously).
        /// </summary>
        /// <param name="args">A ResultBuffer containing the command name followed by command inputs.</param>
        public static void Command(ResultBuffer args)
        {
            acedCmd(args.UnmanagedObject);
        }

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 25 of 26
alisepehrnia77
in reply to: _gile

Thank you very much _gile.

I will test it to see if it works or not.

Message 26 of 26
Soojung_Kim
in reply to: chockalingam

Hi, I'm trying to use this method but ran into an issue where I get 'null' for the MethodInfo object. I made a post about it. If anyone can help me out, that would be great. Thanks! https://forums.autodesk.com/t5/net/question-re-send-command-executes-after-exiting-command-method/td...

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost