.NET

Reply
Moderator
Alexander.Rivilis
Posts: 1,406
Registered: ‎04-09-2008
Message 11 of 18 (382 Views)

Re: Override default commands

04-05-2012 06:23 AM in reply to: annse
The reason is that, in fact, AutoCAD arx-application, that handles command _REFEDIT (ie AcRefEd.arx) is loaded when you first run the command and overrides your command REFEDIT. Therefore, need to load AcRefEd.arx before your's dll-file will be loaded:
Autodesk.AutoCAD.Runtime.SystemObjects.DynamicLinker.LoadModule ("AcRefEd.arx", false,true);

 Also you can modify registry to AcRefEd.arx will loaded with AutoCAD startup:

 

HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\AutoCAD\RXX.X\ACAD-AYYY:ZZZ\Applications\AcadRefEdit
LOADCTRLS = 0x02 (instead of 0x0d)

 




Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Contributor
annse
Posts: 15
Registered: ‎04-04-2012
Message 12 of 18 (372 Views)

Re: Override default commands

04-05-2012 07:49 AM in reply to: Alexander.Rivilis

I've modified the registry. Even if I undefine _REFEDIT, my definition doesn't get called.

Moderator
Alexander.Rivilis
Posts: 1,406
Registered: ‎04-09-2008
Message 13 of 18 (357 Views)

Re: Override default commands

04-06-2012 03:17 AM in reply to: annse

This code was tested with AutoCAD 2011-2013:

 

using System;

using Autodesk.AutoCAD.Runtime;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.EditorInput;

 

[assembly: ExtensionApplication(typeof(Rivilis.RefEditSubst))]

[assembly: CommandClass(typeof(Rivilis.RefEditSubst))]

 

namespace Rivilis

{

    public class RefEditSubst : IExtensionApplication

    {

        void IExtensionApplication.Initialize()

        {

            // Preloading AutoCAD RefEdit command arx-file

            SystemObjects.DynamicLinker.LoadModule("AcRefEd.arx", false, false);

        }

        void IExtensionApplication.Terminate()

        {

            // Do plug-in application clean up here

        }

        //------------------------------------------------

        //     Command group MUST be "ACAD_MAIN"

        //------------------------------------------------

        [CommandMethod("ACAD_MAIN", "RefEdit", CommandFlags.UsePickSet)]

        public void RefEdit() // This method can have any name

        {

            Document doc = Application.DocumentManager.MdiActiveDocument;

            Editor ed = doc.Editor;

            ed.WriteMessage("MyRefEdit..");

            if (doc.Name.Contains("Test"))

            {

                ed.WriteMessage("selected ref..");

            }

            else

            {

                doc.SendStringToExecute("_ACAD_REFEDIT.REFEDIT ", true, false, false);

            }

        }

 

    }

}


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Mentor
KerryBrown
Posts: 269
Registered: ‎11-29-2008
Message 14 of 18 (351 Views)

Re: Override default commands

04-06-2012 04:37 AM in reply to: Alexander.Rivilis

 

Very nice solution Alexander !!

Regards

 

//-------------------------------------------------------

class keyThumper<T> : Lazy<T>;      another  Swamper

Moderator
Alexander.Rivilis
Posts: 1,406
Registered: ‎04-09-2008
Message 15 of 18 (349 Views)

Re: Override default commands

04-06-2012 04:41 AM in reply to: KerryBrown

Thanks! :smileyhappy:


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Contributor
annse
Posts: 15
Registered: ‎04-04-2012
Message 16 of 18 (328 Views)

Re: Override default commands

04-10-2012 01:02 AM in reply to: Alexander.Rivilis

Thank you, Alexander! Setting the command group did it.

Moderator
Alexander.Rivilis
Posts: 1,406
Registered: ‎04-09-2008
Message 17 of 18 (326 Views)

Re: Override default commands

04-10-2012 01:07 AM in reply to: annse

annse wrote:

Thank you, Alexander! Setting the command group did it.


What about accept solution: http://forums.autodesk.com/t5/FAQ-How-To-Using-Autodesk/Accepted-Solutions/td-p/2701533 ?


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Contributor
annse
Posts: 15
Registered: ‎04-04-2012
Message 18 of 18 (322 Views)

Re: Override default commands

04-10-2012 01:12 AM in reply to: Alexander.Rivilis

Accepted. :smileyhappy:

 

Thanks again!

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.