This article describes how to add and remove elements from a geometric combination.
The OdBmFamilyGeomCombination class has an initialization function that adds a set of elements to a combination:
OdBmFamilyGeomCombination
OdResult set(const OdBmElementPtrArray& aElements);
Objects of classes derived from GenSweep and GeomCombination can be used as combinations. The initialization also checks that the total amount of elements in the collection is at least two and that the elements are combinable.
GenSweep
GeomCombination
To add a solid form to a combination, use the appropriate addSolidGeomToCombination() method:
addSolidGeomToCombination()
OdResult addSolidGeomToCombination(const OdBmObjectId& id);
Here, id is an identifier of a solid GenSweep element.
id
To add a void form to a combination, use the addVoidGeomToCombination() method:
addVoidGeomToCombination()
OdResult addVoidGeomToCombination(const OdBmObjectId& id, const OdBmObjectId& solidId);
Here, id is an identifier of a void GenSweep element, and solidId is an identifier of an existing solid GenSweep element in a combination.
solidId
To remove a solid form from a combination, use the appropriate removeSolidGeomFromCombination() method:
removeSolidGeomFromCombination()
OdResult removeSolidGeomFromCombination(const OdBmObjectId& id);
To remove a void form from a combination, use the removeVoidGeomFromCombination() method:
removeVoidGeomFromCombination()
OdResult removeVoidGeomFromCombination(const OdBmObjectId& id, const OdBmObjectId& solidId);
The following example can be found in the _BmFormsJoin_func() function, located in the Examples/TB_Commands/BmFamilyBooleanCmd.cpp file.
_BmFormsJoin_func()
Examples/TB_Commands/BmFamilyBooleanCmd.cpp
ODBM_TRANSACTION_BEGIN(t, pDb) t.start(); OdBmElementPtr pElem1 = genSweep1.safeOpenObject(); OdBmElementPtr pElem2 = genSweep2.safeOpenObject(); OdBmElementPtrArray aElements; aElements.push_back(pElem1); aElements.push_back(pElem2); OdBmFamilyGeomCombinationPtr pFamilyGeomCombination = OdBmFamilyGeomCombination::createObject(); pDb->addElement(pFamilyGeomCombination); pFamilyGeomCombination->set(aElements); t.commit(); ODBM_TRANSACTION_END()
Work with Simple Geometric Elements