Mimic contextual menu on grip hover

Mimic contextual menu on grip hover

O_Eckmann
Mentor Mentor
1,137 Views
5 Replies
Message 1 of 6

Mimic contextual menu on grip hover

O_Eckmann
Mentor
Mentor

Hi, 

 

I would like to mimic the contextual menu on polyline grip (Add vertex / Remove vertex) on another type of entity (MPolygon) with an OverRule on Grips (C#)

 

Solution is to implement a MultiModesGripPE. I've tried but I'm facing a problem. 

According to ObjectArx doc, the GripActionType could have 3 values :

 Immediate : call only one time MoveGripPointsAt which I should use to Remove Vertex

 Command : call an external command

 DragOn : call Movegrippointsat and dragging which should be the good solution to add a new vertex (new position during dragging).

 

With the 2 first option, I obtain a contextual menu which work fine, but with DragOn, AutoCAD doesn't show the contextual menu.

 

I've tried to follow this discussion http://forums.autodesk.com/t5/objectarx/how-to-handle-ctrl-click-in-move-grip-point/td-p/3725552  and compile project given by Balaji_Ram, but I've same issue : no contextual menu on LowerLeftGrip, only on other 3 not implemented grip actiontype Immediate.

 

I've tried on MAP 3D 2014, AutoCAD 2014 and AutoCAD 2015 without any difference : no contextual menu with DragOn ActionType.

 

I use french version of AutoCAD and Map3D on french version of WIndows 7 Pro, perhaps problem is localized with non US product.

 

Any idea on what I'm doing wrong? Thanks for any help.

 

Thanks

Olivier Eckmann

EESignature

0 Likes
1,138 Views
5 Replies
Replies (5)
Message 2 of 6

Balaji_Ram
Alumni
Alumni

 Hi olivier,

 

Happy new year to you !

 

I do not think DragOn is the option that you should be using for Adding a new vertex.

 

DragOn will let the grip editing start based on the grip that turned hot and will change the vertex of the polyline.

I think, you should be using the command grip edit option and inside the command do the following :

 

- Prompt for the new vertex input

- Show transient lines to show how the polyline would get modified.

 

i do not have a ready sample to show that, but in this blog post i had use the external command option to prevent a grip editing from starting. 

http://adndevblog.typepad.com/autocad/2013/12/grip-context-menu-using-acdbmultimodesgrippe.html

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 6

O_Eckmann
Mentor
Mentor

Hi Balaji,

 

Thanks to your answer and Happy new year.

If I use actiontype command, how can I know which grip was over when contextual menu is launched? I need this information to know between which vertex I need to add new one.

If I've correctly read with ActionType immediate or dragon, movegrippoint callback has a parameter gripdata to know which grip is used, but not in ActionTpe Command.

In your sample, is it the grimode.Mode = 1 or 0 to know info about grip used?

 

In your sample DevDaysGripMenusSample.zip, I try to understand your code. You use DragOn action with parameter for X or Y displacement, but I've never found how obtain this option (contextual menu + command line option). In which case DragOn can be useful?

 

Regards

 

Olivier

Olivier Eckmann

EESignature

0 Likes
Message 4 of 6

Balaji_Ram
Alumni
Alumni

Hi Olivier,

 

In the Devdays sample, if you have a grip mode setup to run a command, it is possible to know which grip initiated the command as follows :

 

In the "SetCurrentMode", the type of the GripData should let you know which grip was selected and the mode.

 

After the call to "SetCurrentMode", you will find the custom command getting invoked.

 

public override bool SetCurrentMode(Entity entity, GripData gripData, uint curMode)
{
    if (!(gripData is GripPointOverrule.MyGrip))
        return false;
    (gripData as GripPointOverrule.MyGrip).CurrentModeId = (GripMode.ModeIdentifier)curMode;

    GripPointOverrule.LowerLeftGrip llGripData = gripData as GripPointOverrule.LowerLeftGrip;

    GripPointOverrule.UpperRightGrip urGripData = gripData as GripPointOverrule.UpperRightGrip;

    GripPointOverrule.UpperLeftGrip ulGripData = gripData as GripPointOverrule.UpperLeftGrip;

    GripPointOverrule.LowerRightGrip lrGripData = gripData as GripPointOverrule.LowerRightGrip;

    return true;
}

Hope this helps.

 

Regards,

 

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 6

O_Eckmann
Mentor
Mentor

Hi Balaji,

 

sorry for delay, but I'm working on this project on evening at home, and I haven't tested your solution yet. I try this week-end and I'll give you a return, but it should work.

 

I've another problem in this project with specific MPolygon object. With MAP 3D 2010 to 2012, when I'm in my GetGripPoint entity passed as parameter is type of ImpEntity instead of MPolygon. With MAP 2014 and above it's OK. Is it possible to "cast" ImpEntity to MPolygon or to obtain info on MPolygon (via COM perhaps) from this ImpEntity.

Problem is the same in a transaction : GetObject fonction return an ImpEntity instead of MPolygon on MAP 2010 to 2012. 

I've post this problem here

 

Olivier

Olivier Eckmann

EESignature

0 Likes
Message 6 of 6

Balaji_Ram
Alumni
Alumni

Hi Olivier,

 

Sorry, I do not work with AutoCAD Map and do not know if that is possible to convert the impentity to an MPolygon.

 

This sounds like an issue that was fixed in the later releases of AutoCAD Map.

 

Maybe AutoCAD Map3d experts in that discussion forum might have a suggestion to overcome that.

 

Sorry for not being able to help with this.

 

Regards,

 

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes