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

acedGetCorner(), RECTANGLE Command & UCS

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
jason.teagle
1188 Views, 4 Replies

acedGetCorner(), RECTANGLE Command & UCS

As I understand it, acedGetCorner() will only ever draw the rectangle in the XY coordinate system of the drawing as currently displayed. So if you rotate the UCS in the Z axis by 45 degrees, it makes no difference; the rectangle still draws up and to the right. 

 

If you select the RECTANGLE command, however, the dragging rectangle draws as per the UCS, as expected. 

 

Is there a way to achieve this with acedGetCorner()? 

 

I have seen mention of acedGrDraw() to draw our own lines, which is all very well, but it gives zero information on how to make these calls during a user input operation - if that is even possible. I am perfectly willing to use acedGetPoint() and manually draw the rectangle if it is possible. 

 

How does RECTANGLE do it? Is there a more modern way to get a rectangle from the user then acedGetCorner()? Is there a way to specify a callback function where we can manually draw lines using acedGrDraw() during acedGetCorner()? Can I influence the DCS to get it to match the UCS somehow - if that makes sense? 

 

Expecting the user to work with it as it stands or to rotate the UCS to suit the graphics engine is bad karma - they shouldn't have to. 

 

4 REPLIES 4
Message 2 of 5
owenwengerd
in reply to: jason.teagle

What you describe is called a jig. See the AcEdJig class for more information.

--
Owen Wengerd
ManuSoft
Message 3 of 5
jason.teagle
in reply to: owenwengerd

Good point! I had forgotten about jigs. We have already used them for other areas of our software so I will look into creating one for this. I'm just a little grumpy that there isn't a built-in way of doing this - seems a bit of an oversight! 🙂

 

Thank you. 

 

Message 4 of 5
nick83
in reply to: jason.teagle

jig is prefered, but if you want exactly repeate RECTANGLE command, you can just use native command in your code 🙂

for example ( for acad 2010-2015):

struct resbuf rb;
acedGetVar(_T("CMDNAMES"), &rb);
CString cmd_ok( rb.resval.rstring );
AcDbObjectId rectId = NULL;
ads_name entcont_before, _entcont;
acdbEntLast(entcont_before);

int resRect = RTFAIL;
#if defined(_MSC_VER) && (_MSC_VER == 1500) // acad2010-2012
	resRect = acedCommand( RTSTR,_T("_rectang"),RTSTR,PAUSE,RTNONE);
#elif defined(_MSC_VER) && (_MSC_VER > 1500) // acad2013-2015
	resRect = acedCommandS(RTSTR,_T("_rectang"),RTSTR,PAUSE,RTNONE);
#endif

if ( resRect == RTNORM )
{
	while( true )
	{
		acedGetVar(_T("CMDNAMES"), &rb);
		CString cmd_now( rb.resval.rstring );
		if ( cmd_ok != cmd_now )
		{
			#if defined(_MSC_VER) && (_MSC_VER == 1500) // acad2010-2012
				acedCommand(RTSTR, PAUSE, 0);
			#elif defined(_MSC_VER) && (_MSC_VER > 1500) // acad2013-2015
				acedCommandS(RTSTR, PAUSE, 0);
			#endif			
		}
		else break;
	}

	if (acdbEntLast(_entcont) == RTNORM)
	{				
		if (_entcont[0]==entcont_before[0] && _entcont[1]==entcont_before[1])
		{
			acutPrintf(_T("\nCommand canceled"));
			return;
		}
	}
}
else
{
	acutPrintf(_T("\nCommand canceled"));
	return;
}

acdbGetObjectId(rectId,_entcont);
if (rectId == NULL)
	return;
// here you can do what you want with created rectangle (rectId)
//...
// for example, let's change color
AcDbObject *myobj = NULL;
if ( acdbOpenObject( myobj, rectId, AcDb::kForWrite ) == Acad::eOk )
{
	AcDbCurve *pCurve = AcDbCurve::cast( myobj );
	if ( pCurve )
	{
		pCurve->setColorIndex(1);
		pCurve->downgradeOpen();
	}
	myobj->close();
}
else 
{
	acutPrintf(_T("\nObject is blocked by Autocad"));
	return;
}
return;

 

Message 5 of 5
jason.teagle
in reply to: nick83

An interesting answer! But I will go with the jig route, since it is the preferred method 🙂

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

Post to forums  

Autodesk Design & Make Report

”Boost