Use the normal to correct the text when mirroring a dimension with transformBy

By Gopinath Taget

While applying the transformBy() method on a dimension entity, the dimension text also gets mirrored and does not respect the MIRRTEXT system variable. To avoid this behavior, store the normal of the dimension entity before mirroring and then apply it to the mirrored entity as shown in the sample code below:

NOTE: Error handling has been kept short for clarity.

void ASDKtest()    {     ads_name ent;     ads_point ptres;     acedEntSel( L"nSelect a dimension entity: ", ent, ptres );           AcDbObjectId objId;      acdbGetObjectId(objId, ent);           AcDbEntity * pEnt = NULL;     acdbOpenObject(pEnt, objId, AcDb::kForWrite);          AcDbDimension * pDim = NULL;     pDim = AcDbDimension::cast(pEnt);     if(!pDim)     {          acutPrintf(L"nPlease select a Dimension");      pEnt->close();      return;     }          AcGeVector3d norm;     norm = pDim->normal();          AcGeMatrix3d mat;     mat.setToIdentity();     AcGeLine3d line(AcGePoint3d(7,7,0), AcGePoint3d(7,0,0));      mat.setToMirroring(line);          pDim->transformBy(mat);     pDim->setNormal(norm);     pDim->close();    }

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading