//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#define _USE_MATH_DEFINES
#include <math.h>
#include "resource.h"
static Acad::ErrorStatus ObjectIdArrayFromSelSet(ads_name sset, AcDbObjectIdArray &ids) {
Acad::ErrorStatus es = Acad::eOk;
long nset = -1;
if (acedSSLength(sset, &nset) != RTNORM) return Acad::eAmbiguousInput;
ids.setLogicalLength(nset);
ads_name en;
AcDbObjectId id;
for (long i = 0; i < nset; i++) {
if (acedSSName(sset, i, en) == RTNORM) {
if ((es = acdbGetObjectId(id, en)) != Acad::eOk) return es;
ids[i] = id;
}
}
return Acad::eOk;
}
//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CTextRotateApp : public AcRxArxApp {
public:
CTextRotateApp () : AcRxArxApp () {}
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
return (retCode) ;
}
virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;
return (retCode) ;
}
virtual void RegisterServerComponents () { }
static void RivilisTransformText () {
ads_name result ;
resbuf *filter = acutBuildList(RTDXF0, L"TEXT", RTNONE);
int rc = acedSSGet (NULL, NULL, NULL, filter, result) ;
acutRelRb(filter);
if (rc == RTCAN) return;
if (rc != RTNORM) {
acutPrintf(_T("\nПримитивы TEXT не найдены."));
return;
}
AcDbObjectIdArray ids;
ObjectIdArrayFromSelSet(result, ids);
double ang = 0;
acedGetAngle(NULL,_T("\nУкажите угол, на который поворочивается каждый текст: "), &ang);
if (rc == RTCAN) return;
ACHAR prefix[256] = _T(""),
suffix[256] = _T("");
if (acedGetString(TRUE,_T("\nУкажите префикс: "), prefix) == RTCAN) return;
if (acedGetString(TRUE,_T("\nУкажите суффикс: "), suffix) == RTCAN) return;
for (int i = 0; i < ids.length(); i++)
{
AcDbObjectPointer<AcDbText> pText(ids[i], AcDb::kForWrite);
if (pText.openStatus() == Acad::eOk) {
pText->setTextString(AcString(prefix) + pText->textString() + AcString(suffix));
pText->setRotation(pText->rotation() + ang); // Поворачиваем на заданный угол.
// pText->setRotation(ang); // Устанавливаем угол поворота
}
}
}
} ;
//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CTextRotateApp)
ACED_ARXCOMMAND_ENTRY_AUTO(CTextRotateApp, Rivilis, TransformText, TFT, ACRX_CMD_MODAL | ACRX_CMD_USEPICKSET, NULL)