/////////////////////////////////////////////////////////////////////////////// // 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. /////////////////////////////////////////////////////////////////////////////// #pragma once #include "DbAssocActionBody.h" #include "DbSpline.h" //Example of an action body for creating a wire between points of other objects class OdAssocWireExampleActionBody : public OdDbAssocActionBody { static const int kVersion; struct WireParams { OdString m_type; double m_weight; // N/m double m_maxTension; // N }; public: ODDB_DECLARE_MEMBERS(OdAssocWireExampleActionBody); OdAssocWireExampleActionBody(); virtual ~OdAssocWireExampleActionBody(); virtual OdResult dwgInFields(OdDbDwgFiler* pFiler) override; virtual void dwgOutFields(OdDbDwgFiler* pFiler) const override; //The main function to start working with an object is the entry point when the association is changed virtual void evaluateOverride() override; //Adding additional objects when cloning an association virtual OdResult addMoreObjectsToDeepCloneOverride(OdDbIdMapping& idMap, OdDbObjectIdArray& additionalObjectsToClone) const override; //virtual void clonePersSubentNamingDataOverride(OdDbAssocPersSubentManagerCloner* apsmc) override; OdResult evaluateWire(); static int getVersion(); void setBlockRefId(OdDbObjectId blockRefId) { m_blockRefId = blockRefId; } static OdResult createBlockRef(OdDbDatabasePtr pDb, OdDbObjectId BTRId, OdDbObjectId& blockRefId, OdDbObjectId& lineId); //Static method to create the entire association (action and all internal objects) static OdResult createInstance( const OdDbFullSubentPathArray entPathArray, const OdGePoint3dArray& ptsSelected, const OdArray& snapModeArr, OdDbObjectId& blockRefId, OdDbObjectId& actionBodyId); protected: WireParams m_wireDatabase[5] = { {L"A-35", 2.71, 4000}, {L"AC-50/8", 3.82, 6000}, {L"AC-120/19", 4.57, 12000}, {L"AC-240/32", 7.64, 20000}, {L"Default", 5.0, 10000} }; WireParams getWireParams(const OdString& wireType) { for (int i = 0; i < sizeof(m_wireDatabase) / sizeof(WireParams); i++) { if (wireType.compare(m_wireDatabase[i].m_type) == 0) return m_wireDatabase[i]; } return m_wireDatabase[sizeof(m_wireDatabase) / sizeof(WireParams) - 1]; // Default } //Wire line recalculation void calcWireLine(OdGePoint3d startPnt, OdGePoint3d endPnt, OdDbSpline* pWire, OdDbAssocActionPtr pAction); OdDbObjectId m_blockRefId; }; typedef OdSmartPtr OdAssocWireExampleActionBodyPtr;