admin 发表于 2024-3-4 08:54:14

更改文本样式字体文件

//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
void ads采用regen();
//-----------------------------------------------------------------------------
#define szRDS 采用RXST("")

//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CChangeStyleApp : public AcRxArxApp {

public:
CChangeStyleApp() : 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 RivilisChangeStyle() {
    AcDbObjectId styleId;
    // Create a text style
    {
      AcDbObjectPointer<AcDbTextStyleTable>
      pTextStyleTable(acdbCurDwg()->textStyleTableId(), AcDb::kForWrite);
      AcDbObjectPointer<AcDbTextStyleTableRecord> pStyle;
      pStyle.create();
      pStyle->setName(L"MyStyle");
      pStyle->setFileName(L"romans.shx");
      if (pTextStyleTable->add(styleId, pStyle.object()) != Acad::eOk)
      {
      pTextStyleTable->getAt(L"MyStyle", styleId);
      }
    }

    acedAlert(L"created text style");
    AcDbObjectId idtext;
    // Create some text
    {
      AcDbObjectPointer<AcDbText> pText;
      pText.create();
      pText->setDatabaseDefaults();
      pText->setTextStyle(styleId);
      pText->setTextString(L"Some text");
      pText->setHeight(10);

      AcDbObjectPointer<AcDbBlockTableRecord>
      pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForWrite);
      pSpace->appendAcDbEntity(idtext, pText);
    }

    ads采用regen();
    acedAlert(L"created text");

    {
      // Change the font file for the text style
      AcDbObjectPointer<AcDbTextStyleTableRecord>
      pStyle(styleId, AcDb::kForWrite);
      pStyle->setFileName(L"romand.shx");
    }

    {
      AcDbObjectPointer<AcDbBlockTableRecord>
      pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForRead);
      AcDbBlockTableRecordIterator *pIter = NULL;
      pSpace->newIterator(pIter);
      AcDbObjectId id;
      for (; !pIter->done(); pIter->step())
      {
      pIter->getEntityId(id);
      AcDbEntityPointer pEnt(id, AcDb::kForWrite);
      pEnt->recordGraphicsModified();
      }
      delete pIter;
    }
    ads采用regen();
    acedAlert(L"Regen Current Space");
}
};

//-----------------------------------------------------------------------------
IMPLEMENT采用ARX采用ENTRYPOINT(CChangeStyleApp)

ACED采用ARXCOMMAND采用ENTRY采用AUTO(CChangeStyleApp, Rivilis, ChangeStyle, ChangeStyle, ACRX采用CMD采用MODAL, NULL)

admin 发表于 2024-3-4 08:54:35

---------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
void ads采用regen();
//-----------------------------------------------------------------------------
#define szRDS 采用RXST("")

//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CChangeStyleApp : public AcRxArxApp {

public:
CChangeStyleApp() : 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 RivilisChangeStyle() {
    AcDbObjectId styleId;
    // Create a text style
    {
      AcDbObjectPointer<AcDbTextStyleTable>
      pTextStyleTable(acdbCurDwg()->textStyleTableId(), AcDb::kForWrite);
      AcDbObjectPointer<AcDbTextStyleTableRecord> pStyle;
      pStyle.create();
      pStyle->setName(L"MyStyle");
      pStyle->setFileName(L"romans.shx");
      if (pTextStyleTable->add(styleId, pStyle.object()) != Acad::eOk)
      {
      pTextStyleTable->getAt(L"MyStyle", styleId);
      }
    }

    acedAlert(L"created text style");
    AcDbObjectId idtext;
    // Create some text
    {
      AcDbObjectPointer<AcDbText> pText;
      pText.create();
      pText->setDatabaseDefaults();
      pText->setTextStyle(styleId);
      pText->setTextString(L"Some text");
      pText->setHeight(10);

      AcDbObjectPointer<AcDbBlockTableRecord>
      pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForWrite);
      pSpace->appendAcDbEntity(idtext, pText);
    }

    ads采用regen();
    acedAlert(L"created text");

    {
      // Change the font file for the text style
      AcDbObjectPointer<AcDbTextStyleTableRecord>
      pStyle(styleId, AcDb::kForWrite);
      pStyle->setFileName(L"romand.shx");
    }

    {
      AcDbObjectPointer<AcDbBlockTableRecord>
      pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForRead);
      AcDbBlockTableRecordIterator *pIter = NULL;
      pSpace->newIterator(pIter);
      AcDbObjectId id;
      for (; !pIter->done(); pIter->step())
      {
      pIter->getEntityId(id);
      AcDbEntityPointer pEnt(id, AcDb::kForWrite);
      pEnt->recordGraphicsModified();
      }
      delete pIter;
    }
    ads采用regen();
    acedAlert(L"Regen Current Space");
}
};

//-----------------------------------------------------------------------------
IMPLEMENT采用ARX采用ENTRYPOINT(CChangeStyleApp)

ACED采用ARXCOMMAND采用ENTRY采用AUTO(CChangeStyleApp, Rivilis, ChangeStyle, ChangeStyle, ACRX采用CMD采用MODAL, NULL)

admin 发表于 2024-3-4 08:54:58

//-----------------------------------------------------------------------------
//----- acrxEntryPoint.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"

//-----------------------------------------------------------------------------
#define szRDS 采用RXST("")

//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CChangeStyleApp : public AcRxArxApp {

public:
CChangeStyleApp() : 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 RivilisChangeStyle() {
    AcDbObjectId styleId;
    // Create a text style
    {
      AcDbObjectPointer<AcDbTextStyleTable>
      pTextStyleTable(acdbCurDwg()->textStyleTableId(), AcDb::kForWrite);
      AcDbObjectPointer<AcDbTextStyleTableRecord> pStyle;
      pStyle.create();
      pStyle->setName(L"MyStyle");
      pStyle->setFileName(L"romans.shx");
      if (pTextStyleTable->add(styleId, pStyle.object()) != Acad::eOk)
      {
      pTextStyleTable->getAt(L"MyStyle", styleId);
      }
    }

    acedAlert(L"created text style");
    AcDbObjectId idtext;
    // Create some text
    {
      AcDbObjectPointer<AcDbText> pText;
      pText.create();
      pText->setDatabaseDefaults();
      pText->setTextStyle(styleId);
      pText->setTextString(L"Some text");
      pText->setHeight(10);

      AcDbObjectPointer<AcDbBlockTableRecord>
      pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForWrite);
      pSpace->appendAcDbEntity(idtext, pText);
    }
    acTransactionManagerPtr()->flushGraphics();
    acedUpdateDisplay();
    acedAlert(L"created text");

    {
      // Change the font file for the text style
      AcDbObjectPointer<AcDbTextStyleTableRecord>
      pStyle(styleId, AcDb::kForWrite);
      pStyle->setFileName(L"romand.shx");
    }

    {
      AcDbObjectPointer<AcDbBlockTableRecord>
      pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForRead);
      AcDbBlockTableRecordIterator *pIter = NULL;
      pSpace->newIterator(pIter);
      AcDbObjectId id;
      for (; !pIter->done(); pIter->step())
      {
      id.setNull();
      pIter->getEntityId(id);
      if (id.objectClass()->isDerivedFrom(AcDbText::desc()) ||
            id.objectClass()->isDerivedFrom(AcDbMText::desc()) ||
            id.objectClass()->isDerivedFrom(AcDbDimension::desc()) ||
            id.objectClass()->isDerivedFrom(AcDbBlockReference::desc()))
      {
          AcDbEntityPointer pEnt(id, AcDb::kForWrite);
          if (pEnt.openStatus() == Acad::eOk)
            pEnt->recordGraphicsModified();
      }
      }
      delete pIter;
    }
    acTransactionManagerPtr()->flushGraphics();
    acedUpdateDisplay();
    acedAlert(L"Custom Regen Current Space");
}
};

//-----------------------------------------------------------------------------
IMPLEMENT采用ARX采用ENTRYPOINT(CChangeStyleApp)

ACED采用ARXCOMMAND采用ENTRY采用AUTO(CChangeStyleApp, Rivilis, ChangeStyle, ChangeStyle, ACRX采用CMD采用MODAL, NULL)

admin 发表于 2024-3-4 08:55:13

{
                // Change the font file for the text style
                AcDbObjectPointer<AcDbTextStyleTableRecord> pStyle;
                pStyle.open(styleId, AcDb::kForWrite);
                pStyle->setFileName(L"romand.shx");
        }
        //run style command without doing anything
        ::acedCommandS(RTSTR,采用T("-style"),RTSTR,采用T(""),RTSTR,采用T(""),
                RTSTR,采用T(""), RTSTR, 采用T(""), RTSTR,采用T(""),RTSTR,采用T(""),
                RTSTR,采用T(""),RTSTR, 采用T(""),RTNONE);
        ads采用regen();
页: [1]
查看完整版本: 更改文本样式字体文件