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

AutoCAD2015 : AcedGetPoint function retun -5002

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
AlexOrando
901 Views, 4 Replies

AutoCAD2015 : AcedGetPoint function retun -5002

Hi? technical support team members.

I made one a dialog to select an option.

To view the window for selecting the Drawing1.dwg click the ok button.

Then select a Drawing1.dwg from the combo box.

 Next step executes the acedGetPoint function to output to the drawings in the Drawing1.dwg.

-5002(User Canceled:RTCAN) be returned from acedGetPoint function.

autocad2013, autocad2014 did not have all the problems.

 

I attach a zip file. Please help...

Alex
4 REPLIES 4
Message 2 of 5
nick83
in reply to: AlexOrando

quite hard to understand the problem. there is no attachments at all. so, just a guesswork 🙂

mb you try to use acedGetPoint from an application context?

try to use

#include <axlock.h>
...
...
// before acedGetPoint
AcAxDocLock docLock(acdbHostApplicationServices()->workingDatabase());

 

Message 3 of 5
AlexOrando
in reply to: nick83

thank you reply nick83

 

Basicaly document and database lock when I use it.

And it was work fine at autocad 2014 under version. This forum attachment function fail...fail... because of my internet explorer? I could't understood.

Below mycode.

 

CDlg00 dlg(CWnd::FromHandle(adsw_acadMainWnd()));
 INT_PTR nRT = dlg.DoModal();


 NsuSelectAcadWinDlg dlgWin;
 if (dlgWin.DoModal() != IDOK)
 {
  AfxMessageBox(L"fail dialog");
 }
 CString strDoc = dlgWin.GetDoc();

 strMsg.Format(_T("Take Win : %s"), strDoc);
 AfxMessageBox(strMsg);


 AcApDocumentIterator* pIter = acDocManager->newAcApDocumentIterator();
 if (pIter == NULL)
 {
  AfxMessageBox(L"NULL pIter");
 }

 AcApDocument* pDoc;
 bool bFound = false;

 for (; !pIter->done(); pIter->step())
 {
  pDoc = pIter->document();
  //AfxMessageBox(_T("1"));
  //AfxMessageBox(pDoc->fileName());
  CString strName = pDoc->fileName();
  if (strName != strDoc)
  {
   continue;
  }
  bFound = true;
  break;
 }
 delete pIter;

 
 if (bFound == true)
 {
  acDocManager->setCurDocument(pDoc);
  acDocManager->activateDocument(pDoc);

  ads_point ptRes;
  AcAxDocLock docLock(acdbHostApplicationServices()->workingDatabase());
  int ret = acedGetPoint(NULL, _T("\nselect point :"), ptRes);
  if (ret != RTNORM)
  {
   AfxMessageBox(L"RTNORM false");<---------------------------------------- It's return
  }
 }

Alex
Message 4 of 5
nick83
in reply to: AlexOrando

i have a bad news for you 🙂

actually, this code wont work at any autocad :).

you work in application context, so, for locking and unlocking you should use acDocManager->lockDocument(pDoc) and acDocManager->unlockDocument(pDoc).
BUT, this cant help to solve your problem :), because acedGetXXX function can be used just from document context, not an application context. 

 

my steps to reproduce the behavior of your code.
1. use CString strDoc = _T("Drawing2.dwg");
2. create 3 new drawings. (Drawing1.dwg, Drawing2.dwg, Drawing3.dwg)
3. try to run command from each of the documents.

"RTNORM false" appears at each command run (if the current document before command run was not Drawing2.dwg [ACRX_CMD_SESSION flag for command]).
autocad crashes after several runs [ACRX_CMD_TRANSPARENT flag for command]

so, the only way i see is to create a command for getting point or something like this and use sendStringToExecute (as i know. mb im wrong)

 

for example:

 

static void pProjectaaa_test() // your main command
{
	CString strDoc = _T("Drawing2.dwg");
	AcApDocumentIterator* pIter = acDocManager->newAcApDocumentIterator();
	if (pIter == NULL)
	{
		AfxMessageBox(L"NULL pIter");
	}
	AcApDocument* pDoc;
	bool bFound = false;
	for (; !pIter->done(); pIter->step())
	{
		pDoc = pIter->document();
		CString strName = pDoc->fileName();
		if (strName != strDoc)
			continue;
		bFound = true;
		break;
	}
	delete pIter;

	if (bFound == true)
	{
		acDocManager->setCurDocument(pDoc);
		acDocManager->activateDocument(pDoc);
		Acad::ErrorStatus es = acDocManager->lockDocument(pDoc);
		if (es != Acad::eOk) return;

		acDocManager->sendStringToExecute(pDoc,_T("MYGETPOINT "),true,false,false);
		acDocManager->unlockDocument(pDoc);
	}
}

static void pProjectMYGETPOINT()
{
	// for more info read objectarx help file for "sendStringToExecute"
	ads_point ptRes;
	int ret = acedGetPoint(NULL, _T("\nselect point :"), ptRes);
	if (ret != RTNORM)
	{
		AfxMessageBox(L"RTNORM false");
	}

	CString resMessage;resMessage.Format(_T("input point is (%.4f,%.4f,%.4f)"),ptRes[X],ptRes[Y],ptRes[Z]);
	acedAlert(resMessage.GetString());
	//... add everything here from your main command, 
}

ACED_ARXCOMMAND_ENTRY_AUTO(CUndergroundPlanApp, pProject, aaa_test, aaa_test, ACRX_CMD_SESSION, NULL)
ACED_ARXCOMMAND_ENTRY_AUTO(CUndergroundPlanApp, pProject, MYGETPOINT, MYGETPOINT, ACRX_CMD_TRANSPARENT | ACRX_CMD_NOHISTORY, NULL)

 

Message 5 of 5
AlexOrando
in reply to: nick83

thank you reply nick83.
I am ashamed to have overlooked a fundamental arx rule. However, our customers are some cases that the action by selecting the drawing. It looks like there is a way to solve the problem using the recommendations you have told us.

Thank you for your solutions.

Alex

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

Post to forums  

Autodesk Design & Make Report

”Boost