/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #include "StdAfx.h" #include "DbDatabaseReactor.h" #include "StaticRxObject.h" #include "ExStringIO.h" #include "ExDbCommandContext.h" #include "Ed/EdCommandStack.h" class OdEx_boundaryDbReactor : public OdStaticRxObject { ODRX_NO_HEAP_OPERATORS(); OdDbCommandContext* m_pCmdCtx; public: OdDbEntityPtrArray m_entArr; OdEx_boundaryDbReactor(OdDbCommandContext* pCmdCtx) : m_pCmdCtx(pCmdCtx) { ODA_ASSERT(m_pCmdCtx); m_pCmdCtx->database()->addReactor(this); } ~OdEx_boundaryDbReactor() { m_pCmdCtx->database()->removeReactor(this); } virtual void objectAppended(const OdDbDatabase*, const OdDbObject* pDbObj) { // New object. if (pDbObj->isKindOf(OdDbEntity::desc())) { m_entArr.append(pDbObj); } } }; void _boundaryExArgs_func(OdEdCommandContext* pCmdCtx) { OdRxModulePtr pCommandModule = ::odrxDynamicLinker()->loadModule(OdDbCommandsModuleName, false); OdDbCommandContextPtr pDbCmdCtx(pCmdCtx); OdDbDatabase* pDb = pDbCmdCtx->database(); OdSmartPtr pIO = pDbCmdCtx->userIO(); const OdGePoint3d pnt = pIO->getPoint("Ex Pick point:"); OdString x; x.format(L"%f", pnt.x); OdString y; y.format(L"%f", pnt.y); OdString z; z.format(L"%f", pnt.z); const OdString islandDetection = pIO->getInt(L"Detect Island: 0 - no; 1 - yes") == 0 ? "0" : "1"; const OdString boundaryType = pIO->getInt("Ex boundary type: region = 0 ; polyline = 1") == 0 ? "0" : "1"; OdString sIO; sIO.format(L"%ls,%ls,%ls\n%ls\n%ls\n", x.c_str(), y.c_str(), z.c_str(), islandDetection.c_str(), boundaryType.c_str()); OdSmartPtr pStringIO2 = ExStringIO::create(sIO); OdDbCommandContextPtr pDbCmdCtx2 = ExDbCommandContext::createObject(pStringIO2, pDb); { OdEx_boundaryDbReactor react(pDbCmdCtx2); ::odedRegCmds()->executeCommand(L"boundary", pDbCmdCtx2); for (auto& ent : react.m_entArr) { ent->upgradeOpen(); ent->setColorIndex(6); } } }