Poll

How can i get selected circles center point

How can i get selected circles center point
0 (0%)
How can i get selected circles center point
0 (0%)

Total Members Voted: 0

Author Topic: Get Selected Circles Center point  (Read 1557 times)

0 Members and 1 Guest are viewing this topic.

gnanapaul

  • Guest
Get Selected Circles Center point
« on: December 16, 2009, 05:41:52 AM »
Hi...

I am doing an application to get selected circles center and radius.

Actually i have finished this. But the problem is It is showing the center point if i move the circles only.

It should show if i select the entity. Please help me.

and my code is

Code: [Select]

[code]void CDbModReactor::objectModified(const AcDbDatabase* pDb,
const AcDbObject* pDbObj)
{
AcAxDocLock docLock(pDbObj->ownerId(), AcAxDocLock::kNormal);

if(docLock.lockStatus() != Acad::eOk)
return;
else
objDisplay("modified", pDbObj);
}

void objDisplay(const char* pWhat, const AcDbObject* pDbObj)
{
if(!gpDlg)
return;
char hstr[20];
char idstr[20];
const char *pClsName = NULL;

double pRadius, y_value;

if(pDbObj)
{
AcDbObjectId id = pDbObj->objectId();

AcDbHandle h;
pClsName = pDbObj->isA()->name();

pDbObj->getAcDbHandle(h);

h.getIntoAsciiBuffer(hstr);

//acutPrintf("\nDbModReactor: obj %s: "
// "class %s, id %lx, handle %f.\n",
// pWhat, pClsName , id, idstr);

//sprintf(idstr, "0x%08lx", id);
}
else
{
pClsName = "";
strcpy(hstr, "");
strcpy(idstr, "");
}

ads_name ss;
if( RTNORM !=
acedSSGet("P",NULL,NULL,NULL,ss))
{
// Get Previous selection set
if( RTNORM != acedSSGet(NULL,NULL,NULL,NULL,ss))
{
acDocManager->unlockDocument(acDocManager->curDocument());
return;
}
}

long nEnts;
acedSSLength(ss,&nEnts);
AcDbObjectIdArray entities(nEnts);
//acutPrintf("\nFound %d Entities", nEnts);

CString Tot_Cir;
Tot_Cir.Format("%d",nEnts);

gpDlg->SetDlgItemText(IDC_EDIT1, Tot_Cir);

AcDbCircle* pCircle = AcDbCircle::cast(pDbObj);
if(pCircle == NULL)
return;
AcGePoint3d pCenter = pCircle->center();
y_value = pCenter.y;
pRadius = pCircle->radius();

//acutPrintf("Selected object Y value %f\n", y_value);
//acutPrintf("Selected object X value %f\n", pCenter);
Cir_Radius.Format("%f",pRadius);
Cent_X.Format("%f",pCenter);
Cent_Y.Format("%f",y_value);

m_lstCtrl.InsertItem(0,Cent_X);
m_lstCtrl.SetItemText(0,1,Cent_Y);

FILE * pFile;
pFile = fopen ("C:myfile.csv","a");
if (pFile!=NULL)
{

CString x2 = Cent_X+","+Cent_Y+"\n";
fwrite(x2, x2.GetLength(), 1, pFile);
fclose (pFile);
}

acedSSFree(ss);
}
[/code]

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: Get Selected Circles Center point
« Reply #1 on: December 16, 2009, 08:34:23 AM »
You might try opening the circle kForWrite in the selection set.

Welcome to the swamp

gnanapaul

  • Guest
Re: Get Selected Circles Center point
« Reply #2 on: December 16, 2009, 09:47:18 AM »
thanks for your reply.

i am newbie to objectARX.

please give some code syntex...