.NET

Reply
Moderator
1,465 Posts
277 Kudos
Registered: ‎04-09-2008
Post 11 of 18

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
18 Posts
0 Kudos
Registered: ‎04-04-2012
Post 12 of 18

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
1,465 Posts
277 Kudos
Registered: ‎04-09-2008
Post 13 of 18

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
278 Posts
22 Kudos
Registered: ‎11-29-2008
Post 14 of 18

Re: Override default commands

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

 

Very nice solution Alexander !!

Regards

 

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

Everything will work just as you expect it to, unless your expectations are incorrect.

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

Moderator
1,465 Posts
277 Kudos
Registered: ‎04-09-2008
Post 15 of 18

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
18 Posts
0 Kudos
Registered: ‎04-04-2012
Post 16 of 18

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
1,465 Posts
277 Kudos
Registered: ‎04-09-2008
Post 17 of 18

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
18 Posts
0 Kudos
Registered: ‎04-04-2012
Post 18 of 18

Re: Override default commands

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

Accepted. :smileyhappy:

 

Thanks again!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!