ObjectARX

ObjectARX

Reply
Active Contributor
varadan01
Posts: 47
Registered: ‎03-16-2012
Message 1 of 2 (207 Views)
Accepted Solution

How to get annotative scale value from dimension?

207 Views, 1 Replies
05-11-2012 02:45 AM

How to get annotative scale value from dimension?

How to get annotative property from dimension?

plz provide some sample code!!!

With Regards,
GVaradarajan
static void CheckAnnotative(void)
{
ads_name en; ads_point p;
if (acedEntSel(_T("\nSelect annotative entity: "),en,p) != RTNORM) return;
AcDbObjectId eid; acdbGetObjectId(eid,en);
AcDbEntityPointer pEnt(eid,AcDb::kForRead);
if (pEnt.openStatus() != Acad::eOk) return;
AcDbAnnotativeObjectPE *ann = ACRX_PE_PTR(pEnt, AcDbAnnotativeObjectPE);
if (ann && ann->annotative(pEnt)) {
AcDbObjectContextInterface *objInt = ACRX_PE_PTR(pEnt, AcDbObjectContextInterface);
if (objInt) {
AcDbObjectContextManager *cManager = acdbCurDwg()->objectContextManager();
if (cManager) {
AcDbObjectContextCollection *col =
cManager->contextCollection(ACDB_ANNOTATIONSCALES_COLLECTION);
if (col) {
AcDbObjectContextCollectionIterator* iter = col->newIterator();
if (iter) {
for (iter->start(); !iter->done(); iter->next()) {
AcDbObjectContext *cont = NULL; iter->getContext(cont);
if (cont) {
AcDbAnnotationScale *pScale = AcDbAnnotationScale::cast(cont);
if (pScale && objInt->hasContext(pEnt,*pScale)){
double scale = 1; pScale->getScale(scale);
double pUnits = 1; pScale->getPaperUnits(pUnits);
double dUnits = 1; pScale->getDrawingUnits(dUnits);
AcString name; pScale->getName(name);
acutPrintf(_T("\nName = <%s> Scale = %g PaperUnits = %g DrawingUnits= %g"),
name.kACharPtr(), scale, pUnits, dUnits);
}
}
}
delete iter;
}
}
}
}
} else {
acutPrintf(_T("\nNot annotative entity!"));
}
}

Minimum error checking done.

ObjectARX SDK 2008 and 2009 has sample: samples\misc\AnnotationScaling

In order to download those old versions of ObjectARX SDK and and see this sample: http://goo.gl/XtJ2x

Moderator
Alexander.Rivilis
Posts: 1,432
Registered: ‎04-09-2008
Message 2 of 2 (202 Views)

Re: How to get annotative scale value from dimension?

05-11-2012 05:25 AM in reply to: varadan01
static void CheckAnnotative(void)
{
    ads_name en; ads_point p;
    if (acedEntSel(_T("\nSelect annotative entity: "),en,p) != RTNORM) return;
    AcDbObjectId eid; acdbGetObjectId(eid,en);
    AcDbEntityPointer pEnt(eid,AcDb::kForRead);
    if (pEnt.openStatus() != Acad::eOk) return;
    AcDbAnnotativeObjectPE *ann = ACRX_PE_PTR(pEnt, AcDbAnnotativeObjectPE);
    if (ann && ann->annotative(pEnt)) {
      AcDbObjectContextInterface *objInt = ACRX_PE_PTR(pEnt, AcDbObjectContextInterface);
      if (objInt) {
          AcDbObjectContextManager *cManager = acdbCurDwg()->objectContextManager();
          if (cManager) {
              AcDbObjectContextCollection *col = 
                      cManager->contextCollection(ACDB_ANNOTATIONSCALES_COLLECTION);
              if (col) {
                    AcDbObjectContextCollectionIterator* iter = col->newIterator();
                    if (iter) {
                        for (iter->start(); !iter->done(); iter->next()) {
                            AcDbObjectContext *cont = NULL; iter->getContext(cont);
                            if (cont) {
                                AcDbAnnotationScale *pScale = AcDbAnnotationScale::cast(cont);
                                if (pScale && objInt->hasContext(pEnt,*pScale)){
                                    double scale  = 1; pScale->getScale(scale);
                                    double pUnits = 1; pScale->getPaperUnits(pUnits);
                                    double dUnits = 1; pScale->getDrawingUnits(dUnits);
                                    AcString name; pScale->getName(name);
                                    acutPrintf(_T("\nName = <%s> Scale = %g PaperUnits = %g DrawingUnits= %g"), 
                                        name.kACharPtr(), scale, pUnits, dUnits);
                                }
                            }
                        }
                        delete iter;
                    }
              }
          }
      }
    } else {
        acutPrintf(_T("\nNot annotative entity!"));
    }

}

Minimum error checking done.

ObjectARX SDK 2008 and 2009 has sample: samples\misc\AnnotationScaling

In order to download those old versions of ObjectARX SDK and and see this sample: http://goo.gl/XtJ2x


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.