Poll

Display center point

Display center point
0 (0%)
Display center point
1 (100%)

Total Members Voted: 1

Author Topic: Display center point  (Read 8433 times)

0 Members and 1 Guest are viewing this topic.

gnanapaul

  • Guest
Display center point
« on: December 16, 2009, 09:50:38 AM »
Hi...

My code is

Code: [Select]
void CSampDialog::OnShowPoints()
{
AcDbObjectId objid;
AcDbObject* pObj;
if (objid != NULL)
{
AcDbEntity* pObj = NULL;
if(acdbOpenObject(pObj,objid,AcDb::kForRead) == Acad::eOk)
{
AcDbCircle* pCirc = AcDbCircle::cast(pObj);
       if (pCirc !=NULL)
{
double dRadius = pCirc->radius();
AcGePoint3d ptCenter = pCirc->center();
acutPrintf("center %f radius %f", ptCenter, dRadius);
}
pObj->close();
}
else
acutPrintf("\nFailed to open the object.");

}
}


i need to print the center, radius of selected circles.
my above code is not working...

please can any one me?

thanks...

MickD

  • Gator
  • Posts: 3242
  • !false...it's funny 'cause it's true!
Re: Display center point
« Reply #1 on: December 16, 2009, 03:24:02 PM »
you need to break the point into it's 3 dimensional parts
eg.

acutPrintf("centre %f,%f,%f", ptCentre.X, ptCentre.Y, ptCentre.Z);

or something like that :)
A programmer's wife tells him, "Run to the store and pick up a loaf of bread. If they have eggs, get a dozen."

The programmer comes home with 12 loaves of bread.

gnanapaul

  • Guest
Re: Display center point
« Reply #2 on: December 16, 2009, 10:41:08 PM »
you need to break the point into it's 3 dimensional parts
eg.

acutPrintf("centre %f,%f,%f", ptCentre.X, ptCentre.Y, ptCentre.Z);

or something like that :)


Hi...

Thanks for your reply.
problem is in
Code: [Select]
if (objid != NULL)

how to get AcDbObjectId from db?
please tell me...

MickD

  • Gator
  • Posts: 3242
  • !false...it's funny 'cause it's true!
Re: Display center point
« Reply #3 on: December 16, 2009, 11:42:34 PM »
Try something like this -
Code: [Select]
void CSampDialog::OnShowPoints()
{
AcDbObjectId objid; // this gets assigned to in the acdbOpenObject method.
AcDbObject* pObj;

AcDbEntity* pObj = NULL;  // ----- you need to get/select an object to set this so you can open it
if(acdbOpenObject(pObj,objid,AcDb::kForRead) == Acad::eOk)
{
AcDbCircle* pCirc = AcDbCircle::cast(pObj);
        if (pCirc !=NULL)
{
double dRadius = pCirc->radius();
AcGePoint3d ptCenter = pCirc->center();
acutPrintf("center %f radius %f", ptCenter, dRadius);
}
pObj->close();
}
else
acutPrintf("\nFailed to open the object.");
}
}
A programmer's wife tells him, "Run to the store and pick up a loaf of bread. If they have eggs, get a dozen."

The programmer comes home with 12 loaves of bread.

gnanapaul

  • Guest
Re: Display center point
« Reply #4 on: December 17, 2009, 12:18:07 AM »
Hi MickD,

Thanks for your reply.

I used your code. But it shows failed to pen object.

I thing here i have to get selected object'ss objectId from object in the database.

But i don't know how to get objectid from database.

please help me.

thanks again...

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6924
  • AKA Daniel
Re: Display center point
« Reply #5 on: December 17, 2009, 12:34:53 AM »
what version of Acad are you targeting?

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6924
  • AKA Daniel
Re: Display center point
« Reply #6 on: December 17, 2009, 12:37:17 AM »
you can get an array of IDs in the current selection set by using acdbGetCurrentSelectionSet


gnanapaul

  • Guest
Re: Display center point
« Reply #7 on: December 17, 2009, 12:59:16 AM »
Hi Daniel,

Thanks for your reply.

I am totally newbie to arx. please give code syntax for acdbGetCurrentSelectionSet.

I am using Autocad 2000 and vc6.0

Thanks a lot....

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6924
  • AKA Daniel
Re: Display center point
« Reply #8 on: December 17, 2009, 01:17:58 AM »
something like

Code: [Select]
void CSampDialog::OnShowPoints()
{
  AcDbObjectIdArray ids;
  if(acdbGetCurrentSelectionSet(ids) == eOk)
  {
    for(size_t i = 0; i < ids.length() ; i++)
    {
      AcDbEntity* pObj = NULL;
      if(acdbOpenObject(pObj,ids[i],AcDb::kForRead) == Acad::eOk)
      {
        AcDbCircle* pCirc = AcDbCircle::cast(pObj);
        if (pCirc !=NULL)
        {
          double dRadius = pCirc->radius();
          AcGePoint3d ptCenter = pCirc->center();
          acutPrintf("center (%g,%g,%g) radius %g",
            ptCenter.x,ptCenter.y,ptCenter.z, dRadius);
        }
        pObj->close();
      }
      else
        acutPrintf("\nFailed to open the object.");
    }
  }
}

gnanapaul

  • Guest
Re: Display center point
« Reply #9 on: December 17, 2009, 01:30:39 AM »
Hi Daniel,

I used your code. But,

Code: [Select]
error C2065: 'acdbGetCurrentSelectionSet' : undeclared identifier
error C2065: 'eOk' : undeclared identifier
warning C4018: '<' : signed/unsigned mismatch

Shall i include any header file???

Thanks a lot again...

Regards,
Paul.G

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6924
  • AKA Daniel
Re: Display center point
« Reply #10 on: December 17, 2009, 01:38:51 AM »
replace eOk with Acad::eOk 
It may be that acdbGetCurrentSelectionSet did not exist in 2000,  the oldest docs I have are for 2002. it should be in  aced.h
If it's not in the 2000 SDK, you might be able to use the 2002 SDK as it is are binary compatible

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6924
  • AKA Daniel
Re: Display center point
« Reply #11 on: December 17, 2009, 01:43:00 AM »
Also, if you ever plan on using your code on versions 2007+, you should use TCHAR  &&  _T("") for all your strings i.e acutPrintf(_T("\nARX Rocks!"));

gnanapaul

  • Guest
Re: Display center point
« Reply #12 on: December 17, 2009, 01:48:40 AM »
Hi Daniel,

Code: [Select]
error C2065: 'acdbGetCurrentSelectionSet' : undeclared identifier
is continue.

Code: [Select]
you might be able to use the 2002 SDK as it is are binary compatible

How to use 2002 SDK?
I have included aced.h.


Thanks again...

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6924
  • AKA Daniel
Re: Display center point
« Reply #13 on: December 17, 2009, 01:53:43 AM »
<ftp://ftp.autodesk.com/pub/objectarx/objectarx_2002/>

gnanapaul

  • Guest
Re: Display center point
« Reply #14 on: December 17, 2009, 01:57:14 AM »
Hi Daniel,

Code: [Select]
ads_name ss;
if( RTNORM != acedSSGet("P",NULL,NULL,NULL,ss))  
{
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);

double pRadius, y_value;
int rc;
ads_name en;
AcGePoint3d pt;

rc = acedEntSel("\nSelect circles: ", en, asDblArray(pt));
if (rc != RTNORM)
{
acutPrintf("\nNo entity selected...");
return;
}
AcDbObjectId eId, eId2;
acdbGetObjectId(eId, en);

AcDbObject *pDbObj;

AcDbCircle *pcircle;
AcGePoint3d *pCenter1 = new AcGePoint3d;
acdbOpenObject(pDbObj, eId, AcDb::kForRead);
AcDbCircle* pCircle = AcDbCircle::cast(pDbObj);
if(pCircle == NULL)
return;
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);


This above code working fine. but it shows only one selected circles center. But i need to show multiple circles at a time. please help me to change the code for to show selected circles center point...

Thanks again...