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

How replicate PLINE grip menu on my custom entity?

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
maisoui
1341 Views, 12 Replies

How replicate PLINE grip menu on my custom entity?

Hi,

 

I'd like to replicate the PLINE grip menu on my custom entity : when grip is hovered, a menu is displayed (actions = Stretch Vertex, Add Vertex, Remove Vertex).

 

gripmenu.png

 

For now, I can display a context menu by:

  1. creating a AcDbGripData (in subMoveGripPointsAt method)
  2. Specifying a custom GripOperation (function ptr) for hover
  3. Creating a CMenu in my custom GripOperation function
  4. Displaying my menu like this : 
    BOOL result = pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, p.x + 15, p.y + 20, AfxGetMainWnd());
    (where p is a POINT representing the current cursor location)

I don't know if this is the right way because the point of the grip is blue (as if it was warm), while for the PLINE it becomes orange (see the image above).

And I like to know how to begin move grip process? The PLINE menu launches the command GRIP_STRETCH. I tried to use the same command but I was unable to execute it with:

 

acedCommand(RTSTR, _T("_.grip_stretch"), RTENAME, pickSet, RTNONE);

 

Maybe someone can provide an example? All suggestions are welcomed.

 

Regards,

Jonathan

 

--
Jonathan
12 REPLIES 12
Message 2 of 13
fenton.webb
in reply to: maisoui

Check out the class AcDbMultiModesGripPE class in dbMultiModesGrip.h in the ObjectARX SDK




Fenton Webb
AutoCAD Engineering
Autodesk

Message 3 of 13
maisoui
in reply to: fenton.webb

Thank you for your answer. It could be a good solution, but I'm using OARX 2010 and I guess AcDbMultiModesGripPE appeared in OARX 2012 or 2013. Is there another solution or it's only a new feature of next OARX?

--
Jonathan
Message 4 of 13
Balaji_Ram
in reply to: maisoui

Hello,

 

The API for multi-functional grips was introduced in ObjectARX 2012 although AutoCAD had it as a feature in 2011.

Sorry, there is no way to get it using 2010 SDK.



Balaji
Developer Technical Services
Autodesk Developer Network

Message 5 of 13
maisoui
in reply to: Balaji_Ram

Ok. Thank you for your anwser. I was able to reproduce this feature with a little time and perseverance.

Regards,

Jonathan

 

--
Jonathan
Message 6 of 13
eriver_2000
in reply to: maisoui

I also encounter this problem, in the hover function, how to start movegrip process, could you share your solution? thanks

Message 7 of 13
maisoui
in reply to: eriver_2000

Hi,

 

I opted for the following solution : simulate a mouse click on the grip point using SendInput. Here is my function

 

void BcGripFunctions::makeGripHot(const POINT & pt)
{
	POINT ptOriginal;
	GetCursorPos(&ptOriginal);

	//move mouse cursor (to simulate click on the right point
	INPUT Input = {0};

	long fScreenWidth = GetSystemMetrics(SM_CXSCREEN) - 1;
	long fScreenHeight = GetSystemMetrics(SM_CYSCREEN) - 1;

	float fx = pt.x * (65535.0f / fScreenWidth);
	float fy = pt.y * (65535.0f / fScreenHeight);

	Input.type = INPUT_MOUSE;
	Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE;
	Input.mi.dx = (long)fx;
	Input.mi.dy = (long)fy;
	SendInput(1, &Input, sizeof(INPUT));
	ZeroMemory(&Input, sizeof(INPUT));

	//simulate mouse (left) click
	Input.type = INPUT_MOUSE;
	Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
	SendInput(1, &Input, sizeof(INPUT));
	ZeroMemory(&Input, sizeof(INPUT));

	Input.type = INPUT_MOUSE;
	Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
	SendInput(1, &Input, sizeof(INPUT));
	ZeroMemory(&Input, sizeof(INPUT));

	//restore original position
	fx = ptOriginal.x * (65535.0f / fScreenWidth);
	fy = ptOriginal.y * (65535.0f / fScreenHeight);

	Input.type = INPUT_MOUSE;
	Input.mi.dwFlags = MOUSEEVENTF_MOVE|MOUSEEVENTF_ABSOLUTE;
	Input.mi.dx = (long)fx;
	Input.mi.dy = (long)fy;
	SendInput(1, &Input, sizeof(INPUT));
	ZeroMemory(&Input, sizeof(INPUT));
}

 

The process is :

  1. User hovers a grip point
  2. In my gripHoverOperation implementation, I display a CMenu
  3. If user chooses "Stretch" option, I simulate a mouse click on the grip point to make it hot (and start movegrip process)

I'm aware this solution isn't a perfect solution, but it's the only one I found. I use it for a while and my customers did not report any issue.

I hope this will be helpful.

Regards,

 

--
Jonathan
Message 8 of 13
Balaji_Ram
in reply to: maisoui

Hi Jonathan,

 

Glad to know you have found a solution that works without any issues.

 

In future if you need to implement it using multi-mode grips you may find this useful :

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

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 9 of 13
maisoui
in reply to: Balaji_Ram

Nice, thank you for your link. I will try it.

Regards,

--
Jonathan
Message 10 of 13
eriver_2000
in reply to: maisoui

Good solution! Thank you for help, I will try it..

Regards

 

Message 11 of 13
maisoui
in reply to: eriver_2000

I tried the solution of Balaji and If you have no need of using OARX 2010, I advice you use this easier and more confortable solution.

 

One question for Balaji : I have not been able to define a specific cursor for my GripMode. I use :

gripMode.CursorType = kcCrosshairPlus;

To obtain this:

 gripmode_cursor.png

 

In my solution, I use a transient entity with an AcEdInputPointMonitor to draw it near the cursor.

Can you help me?

 

Regards,

--
Jonathan
Message 12 of 13
eriver_2000
in reply to: maisoui

Thanks for your help first, but I encounter another problem, when I right click the grip point quickly enough, and before the hover menu shows(follow your method), CAD application may crash,perhaps, it is because CAD pop up its own right click menu when my hovergripfun executing, 

Is this the true cause?

And is there a possible solution?

 

Regards

Message 13 of 13
eriver_2000
in reply to: eriver_2000

 I find the reason. It is because I pass  acedGetAcadFrame() to the menu's TrackPopupMenu() , I changed it to acedGetAcadDwgView(), then, CAD works well when pop my hover menu.

Thanks!

 

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

Post to forums  

”Boost