.NET

Reply
Moderator
Alexander.Rivilis
Posts: 1,346
Registered: ‎04-09-2008
Message 11 of 18 (345 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
Posts: 15
Registered: ‎04-04-2012
Message 12 of 18 (335 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,346
Registered: ‎04-09-2008
Message 13 of 18 (320 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: 259
Registered: ‎11-29-2008
Message 14 of 18 (314 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,346
Registered: ‎04-09-2008
Message 15 of 18 (312 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
Posts: 15
Registered: ‎04-04-2012
Message 16 of 18 (291 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,346
Registered: ‎04-09-2008
Message 17 of 18 (289 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
Posts: 15
Registered: ‎04-04-2012
Message 18 of 18 (285 Views)

Re: Override default commands

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

Accepted. :smileyhappy:

 

Thanks again!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community