An opening is a geometric cutout on a host element. Openings are applicable to walls, floors, ceilings, roofs, etc.
Cutouts are defined by a tag of a face (faceTag
) and a set of curves that define the shape
of the cutout (pCurveLoop
).
To create an opening on a face, use the
newOpening()
method
from the OdBmOpeningHelper
class:
An example of using the described method is below. You can find the command in BimRv\Examples\TB_DevGuideCommands\BmOpeningCmd.cpp
.
First, include all libraries you will need during the creation process.
#include "TBDevGuideStdAfx.h"
#include "Database/BmDatabase.h"
#include "Database/BmTransaction.h"
#include "HostObj/Entities/BmHostObj.h"
#include "Geometry/Entities/BmGLine.h"
#include "Main/BmOpeningHelper.h"
Then, using the command context, get access to a database and input the necessary values.
OdBmCommandContextPtr pDbCmdCtx(pCmdCtx);
OdBmDatabase* pDb = pDbCmdCtx->database();
OdSmartPtr<OdEdBaseUserIO> pIO = pDbCmdCtx->userIO();
pIO->putString(OD_T("Started opening creation"));
// unitTests\BIM_3169\opening2020_gen_model_1.rfa
OdInt32 iHandle = pIO->getInt("Enter id of the host object:", OdEd::kInpDefault, -1); // 31
Next, create a curve loop by first creating points and vectors that lines will be created from. A transaction is also started here, but you can do it later on.
if (iHandle > -1)
{
ODBM_TRANSACTION_BEGIN(t, pDb)
t.start();
OdBmHostObjPtr pHostObj = pDb->getObjectId(OdDbHandle(iHandle)).safeOpenObject();
if (pHostObj.isNull()) {
pIO->putString(OD_T("Host object is not found"));
return;
}
OdBmCurveLoopPtr pCurveLoop = OdBmCurveLoop::createObject();
if (pCurveLoop.isNull()) {
pIO->putString(OD_T("Curve loop creation error"));
return;
}
OdGePoint3d aOpeningStartPoints[] = {
OdGePoint3d(4.351640307173362, -0.246062992125984, 7.705746887012612),
OdGePoint3d(4.351640307173359, -0.246062992125984, 5.671626152104476),
OdGePoint3d(0.086548443656298, -0.246062992125984, 5.671626152104489),
OdGePoint3d(0.086548443656302, -0.246062992125984, 7.705746887012619)
};
OdGeVector3d aOpeningEndVectors[] = {
OdGeVector3d(0.0, 0.0, -2.034120734908136),
OdGeVector3d(-4.265091863517061, 0.0, 0.0),
OdGeVector3d(0.0, 0.0, 2.034120734908131),
OdGeVector3d(4.265091863517060, 0.0, 0.0)
};
The second step is to form lines from the points and vectors, and create a loop made of these lines.
for (OdUInt32 i = 0; i < 4; ++i)
{
OdBmGLinePtr pGLine = OdBmGLine::createObject();
if (pGLine.isNull()) {
pIO->putString(OD_T("Line creation error"));
return;
}
pGLine->set(aOpeningStartPoints[i], aOpeningStartPoints[i] + aOpeningEndVectors[i]);
OdResult res = pCurveLoop->append(pGLine);
if (res != eOk) {
pIO->putString(OD_T("Curve loop appending error"));
return;
}
}
The final step is to call the newOpening()
method and pass the created parameters to it.
Also, don't forget to close the transaction.
OdResult res = OdBmOpeningHelper::newOpening(pHostObj, pCurveLoop);
if (res != eOk) {
pIO->putString(OD_T("Opening creation error"));
return;
}
t.commit();
ODBM_TRANSACTION_END();
}
pIO->putString(OD_T("Ended opening creation"));
The resulting output of this command can be seen in OdaBimApp
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.
|