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

Disabling DROPGEOM

57 REPLIES 57
SOLVED
Reply
Message 1 of 58
Kyudos
14975 Views, 57 Replies

Disabling DROPGEOM

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;
        }
    }
}
Tags (3)
57 REPLIES 57
Message 2 of 58
Kyudos
in reply to: Kyudos

The above is a solution I found 🙂
Message 3 of 58
legWZPED
in reply to: Kyudos

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.

Message 4 of 58
Alexander.Rivilis
in reply to: Kyudos

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

Message 5 of 58
Kyudos
in reply to: legWZPED

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

Message 6 of 58
troma
in reply to: Kyudos

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

Mark Green

Working on Civil 3D in Canada

Message 7 of 58
Kyudos
in reply to: troma

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.

Message 8 of 58
Kyudos
in reply to: Kyudos

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.

Message 9 of 58
legWZPED
in reply to: Kyudos

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.
Message 10 of 58
Kyudos
in reply to: legWZPED

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.

Message 11 of 58
Kyudos
in reply to: Kyudos

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.

Message 12 of 58
legWZPED
in reply to: Kyudos

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!

Message 13 of 58
gennadykhSSDP9
in reply to: Kyudos

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

Message 14 of 58
Kyudos
in reply to: gennadykhSSDP9

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

Message 15 of 58
gennadykhSSDP9
in reply to: Kyudos

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

Message 16 of 58
Kyudos
in reply to: gennadykhSSDP9

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).

 

Message 17 of 58
gennadykhSSDP9
in reply to: Kyudos

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.

Message 18 of 58
jtinaco
in reply to: Kyudos

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

Message 19 of 58
ArchD
in reply to: Kyudos

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
Message 20 of 58
tom8K9S4
in reply to: Kyudos

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

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

Post to forums  

Autodesk Design & Make Report

”Boost