Jump to content

ObjectARX - Selected Circles Center and radius.


Recommended Posts

Posted

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

 


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

if(docLock.lockStatus() != Acad::eOk)
return;
else
gpDlg->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);
}

Posted

gnanapaul,

 

This forum is not particularly strong with ObjectARX, so, if you don't get an adequate response here - try over at theSwamp.org.

 

Lee

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...