Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding
Announcements
We are currently migrating data within this board to improve the community. During this process, posting, replying, editing and other features are temporarily disabled. We sincerely apologize for any inconvenience caused and appreciate your understanding. Thank you for your patience and support.

Disabling DROPGEOM

Kyudos
Collaborator Collaborator
19,625 Views
63 Replies
Message 1 of 64

Disabling DROPGEOM

Kyudos
Collaborator
Collaborator

EDIT: For convenience I'm just adding the latest builds to this first post 🙂

 

********

I've found that dealing with OLEDRAGDROP / DROPGEOM as well as grip editing makes the handling for my custom objects unnecessarily complicated.

 

Hence I'm posting my solution to disabling this function for my objects, I don't know if its the best way, but it works.

 

In your AcApDocManagerReactor::documentLockModeChanged handler you can use something like this:

 

if (_tcsicmp(pGlobalCmdName, _T("OLEDRAGDROP")) == 0 || 
_tcsicmp(pGlobalCmdName, _T("DROPGEOM")) == 0 ||
_tcsicmp(pGlobalCmdName, _T("DRAGENTER")) == 0)
{
    // Prevent objects from being dragged
    for (int i = 0; i < aLastSelectionArray.length(); i++)
    {
        AcDbObjectId objId = aLastSelectionArray[i];
	MyObject* pObj = IsMyObject(objId);

        if (pObj != NULL)
        {
            this->veto();
            break;
        }
    }
}

 

Reply
Reply
Accepted solutions (3)
19,626 Views
63 Replies
Replies (63)
Message 2 of 64

Kyudos
Collaborator
Collaborator
The above is a solution I found 🙂
Reply
Reply
Message 3 of 64

Anonymous
Not applicable

Thanks for tackling this obnoxious problem! I'm a newbie at digging into the guts of AutoCAD, so could you spell out how to implement this? Explain-it-like-I'm-five style.

Reply
Reply
Message 4 of 64

Alexander.Rivilis
Mentor
Mentor

This solution disable command if in current selection set is at least one MyObject entity. It will be cool to filter MyObject entities and start continue command without them. IMHO

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Reply
Reply
0 Likes
Message 5 of 64

Kyudos
Collaborator
Collaborator

I've attached a sample project to demonstrate this - I've only tested it on AutoCAD 2016 x64 though.

 

The above sample only prevents dragging and dropping of my custom objects, the sample project just globally disables it.

 

Two simple commands:

 

DISABLEDD

 

ENABLEDD

Reply
Reply
0 Likes
Message 6 of 64

troma
Mentor
Mentor
I downloaded your zip.
I have no idea what to do with it next.

Mark Green

Working on Civil 3D in Canada

Reply
Reply
Message 7 of 64

Kyudos
Collaborator
Collaborator

Well, if you aren't interested in how the code works, you can (if you have AutoCAD 2016) simply load up one of the included ARX files and use the commands to enable or disable drag and drop as you like.

Reply
Reply
0 Likes
Message 8 of 64

Kyudos
Collaborator
Collaborator

Actually - this doesn't work as well as I hoped.

 

It prevents DROPGEOM - so your entities will snap back to their starting positions.

 

In BricsCAD it prevents the Drag from being initiated in the first place - that would be better, but those commands don't come through in AutoCAD.

Reply
Reply
0 Likes
Message 9 of 64

Anonymous
Not applicable
I loaded the ARX file and it worked well for me! However, is there a way to have it default run "Disabledd" on startup?

I don't have the right program to open the arx files--was hoping I could open and edit it in notepad like a lisp, but nope.
Reply
Reply
0 Likes
Message 10 of 64

Kyudos
Collaborator
Collaborator

You can add commands to:

 

"C:\Program Files\Autodesk\AutoCAD 2016\Support\acad2016.lsp"

 

to run them on startup. Obviously the ARX would need to be loaded first - but you could add the load command in the same file.

Reply
Reply
0 Likes
Message 11 of 64

Kyudos
Collaborator
Collaborator

It seems a better option to disable drag-and-drop for a custom entity is something like this:

 

//----------------------------------------------------
void MyObject::dragStatus(const AcDb::DragStat status)
//----------------------------------------------------
{
  if (status == AcDb::kDragStart)
  {
    if (m_pDropTarget == NULL)
    {
      m_pDropTarget = new MyDropTarget;
      acedStartOverrideDropTarget(m_pDropTarget);
    }
  }
  else if (status == AcDb::kDragEnd)
  {
    if (m_pDropTarget != NULL)
    {
      acedEndOverrideDropTarget(m_pDropTarget);
      delete m_pDropTarget;
      m_pDropTarget = NULL;
    }
  }
}

Here MyDropTarget is derived from COleDropTarget and just disables dragging and dropping for the duration of the "drag".

 

Refer to this: Override drag-drop behavior

 

Also note - you'll need to add _ARX_CUSTOM_DRAG_N_DROP_ to your pre-processor definitions if you want to use this method.

Reply
Reply
0 Likes
Message 12 of 64

Anonymous
Not applicable

I added the ARX file to my lsp startup suite, but I want it to run as though the "Disabledd" command has already been entered on startup, without having to actually enter it with each new session. If this were a standard lisp, I think I could just add a line of text in the code. I don't know how to edit ARX files to achieve the same effect.

Are you suggesting that I write a separate lisp that just runs the "Disabledd" command on startup? I don't mind doing that, just clarifying and ensuring that's the best way.

Edit: sorry, read up a little more on the method you mentioned and realize exactly what to do. Thanks!

Reply
Reply
0 Likes
Message 13 of 64

gennadykhSSDP9
Explorer
Explorer

Thank you very much for the sample solution.

It works fine in one session. I can prevent to run such operation in current drawing.

I'm wonder if it is possible to prevent drag-and-drop operation from one autocad session with loaded ARX to another acad without it.

Thank you,

Gennady

Reply
Reply
0 Likes
Message 14 of 64

Kyudos
Collaborator
Collaborator

Hi Gennady,

 

My first solution (the sample ARX) vetoes DROPGEOM - meaning that you can drag, but you can't drop.

 

My second (better) solution (not in the sample ARX) uses an override of the drop target to prevent the drag from even starting.

I imagine (not tested) that this method would prevent entities being dragged-and-dropped between ACAD instances.

 

Dan

Reply
Reply
Message 15 of 64

gennadykhSSDP9
Explorer
Explorer

Dan,

i did try your second solution. I like it better so drag-n-drop will be limited to custom components.

 

For some reason drag operation never finished in dragStatus with AcDb::kDragEnd.

It came via OnDropEx because it creates rectangle and OnDrop returns FALSE.

My custom component live in DBX, both ARX and DBX projects have _ARX_CUSTOM_DRAG_N_DROP_ predefined macro.

Do you know if somethin is missing?

Thank you,

Gennady

Reply
Reply
0 Likes
Message 16 of 64

Kyudos
Collaborator
Collaborator

Looking at my code I may have found some similar problem , since I actually have:

 

 

if (status == AcDb::kDragStart)
{
    ...
}
else
{
    ...
}

 

 

I'm never checking specifically for kDragEnd (remember you might get kDragAbort too).

 

Reply
Reply
0 Likes
Message 17 of 64

gennadykhSSDP9
Explorer
Explorer

actually i'm tracking all three options:

AcDb::kDragStart: to create CMyDropTarget object;

AcDb::kDragEnd: to delete CMyDropTarget object;

AcDb::kDragAbort: to delete CMyDropTarget object;

Never got to End or Abort options.

Did make CMyDropTarget global, did CoCreateInstance() in ctor, did register in OnDragEnter. Nothing helps.

I see following events sequence:

"Component dtor"

"drag started"

Looks like starting drag-and-drop will delete component from current drawing to clipping board and after that component is not belonging to Acad session anymore. Just a guess.

Reply
Reply
0 Likes
Message 18 of 64

Anonymous
Not applicable

The arx file won't load in 2017. Would you be able to post one for 2017 version? Thanks!

Reply
Reply
Message 19 of 64

ArchD
Collaborator
Collaborator

I'd also like to load this arx in 2017. Any way to update this? I've opened it in VS but can't figure it out. So bad at coding...

Archie Dodge
Applications Expert - Infrastructure Solutions Division
IMAGINiT Technologies
Reply
Reply
0 Likes
Message 20 of 64

Anonymous
Not applicable

Hi @Kyudos,

 

Kia Ora from New Zealand- I hope you are well in these crazy times..

 

I am constantly working with large drawings in Civil 3d 2020. Lag is a constant battle with large datasets and the DROPGEOM command is alive and well, providing me with ample frustration, usually only a long time after it's happened (although thankfully sometimes I see it happen and can undo right away). And it's not just me, it happens to my work mates too.

 

I have stumbled across your solution as the closest thing to fixing this, however trying to load your ARX file from this download into Civil 3D 2020 gives me this error message:

disabledragdrop.arx is incompatible with this version of AutoCAD.
AcRxDynamicLinker failed to load 'k:\autocad\autocad\lisp\disabledragdrop.arx'
k:\autocad\autocad\lisp\disabledragdrop.arxUnable to load DisableDragDrop.arx file.

 

I don't want to be this guy, usually i'll trawl the internet until I break down what I need and managed to bungle my way through it, but not this time. I seem to be hitting wall after wall.

 

Is there some way you could assist me in getting this to run in my version of AutoCAD?  It would be hugely appreciated.

 

Kind Regards,

 

Tom

Reply
Reply