ObjectARX

ObjectARX

Reply
New Member
dr.gattaca
Posts: 1
Registered: ‎08-29-2012
Message 1 of 2 (203 Views)

looking for an example of using: AcDb3dSolid::createRevolvedSolid

203 Views, 1 Replies
08-29-2012 04:54 PM

Hi read for a long time on the help files. Just don't get a clue how to start, by any chance somebody got a sample code of it. Much appreciate.

 

Gat

ADN Support Specialist
Balaji_Ram
Posts: 735
Registered: ‎03-21-2011
Message 2 of 2 (177 Views)

Re: looking for an example of using: AcDb3dSolid::createRevolvedSolid

09-03-2012 08:59 AM in reply to: dr.gattaca

Hi Gat,

 

Here is a simplest example using createRevolvedSolid.

It creates a cylinder by revolving a line about the Z axis. Hope this provides you a starting point.

 

AcGePoint3d sp(10.0, 0.0, 0.0);
AcGePoint3d ep(10.0, 0.0, 10.0);
AcDbLine *pRevEnt = new AcDbLine(sp, ep);

Acad::ErrorStatus es;
AcDb3dSolid* pShapeSld = new AcDb3dSolid ();
AcDbRevolveOptions revolveOptions;

revolveOptions.setDraftAngle(0.0);

if((es = pShapeSld->createRevolvedSolid(
	pRevEnt, 
	AcGePoint3d::kOrigin, 
	AcGeVector3d::kZAxis, 
	6.28318530718, 
	0.0, 
	revolveOptions
	)) != Acad::eOk)
{
	acutPrintf(L"\nSolid creation failed...\n");
	delete pShapeSld;
	return;
}
pShapeSld->setColorIndex(2); 

AcDbObjectId id;
postToDb(pShapeSld, id);


Here is the postToDb method :

static Acad::ErrorStatus postToDb(AcDbEntity* ent, AcDbObjectId& objId)
{
	Acad::ErrorStatus      es;
	AcDbBlockTable*        pBlockTable;
	AcDbBlockTableRecord*  pSpaceRecord;

	if ((es = acdbHostApplicationServices()->workingDatabase()->
		   getSymbolTable(pBlockTable, AcDb::kForRead))
		   != Acad::eOk) {
		return es;
	}

	if ((es = pBlockTable->getAt(ACDB_MODEL_SPACE, 
								 pSpaceRecord,
								 AcDb::kForWrite)) != Acad::eOk) {
		return es;
	}

	if ((es = pBlockTable->close()) != Acad::eOk) {
		return es;
	}

	if ((es = pSpaceRecord->appendAcDbEntity(objId, ent)) != Acad::eOk) {
		return es;
	}

	if ((es = pSpaceRecord->close()) != Acad::eOk) {
		return es;
	}

	return ent->close();
}

 



Balaji
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!