55 lines
2.0 KiB
C++
55 lines
2.0 KiB
C++
|
|
#include "../pch.h"
|
||
|
|
#include "CElementHelper.h"
|
||
|
|
#include <Mstn/MdlApi/MdlApi.h>
|
||
|
|
#include <DgnPlatform/DgnPlatformApi.h>
|
||
|
|
#include <Mstn/ISessionMgr.h>
|
||
|
|
#include <PSolid/PSolidCoreAPI.h>
|
||
|
|
#include <cassert>
|
||
|
|
|
||
|
|
USING_NAMESPACE_BENTLEY_DGNPLATFORM
|
||
|
|
USING_NAMESPACE_BENTLEY_MSTNPLATFORM
|
||
|
|
USING_NAMESPACE_BENTLEY_MSTNPLATFORM_ELEMENT
|
||
|
|
|
||
|
|
void CElementHelper::CreateLineElement(DPoint3dCP pStartPoint, DPoint3dCP pEndPoint)
|
||
|
|
{
|
||
|
|
DgnModelRefP pActiveModel = ISessionMgr::GetActiveDgnModelRefP();
|
||
|
|
DSegment3d segment = DSegment3d::From(*pStartPoint, *pEndPoint);
|
||
|
|
EditElementHandle eeh;
|
||
|
|
LineHandler::CreateLineElement(eeh, nullptr, segment, pActiveModel->Is3d(), *pActiveModel);
|
||
|
|
eeh.AddToModel();
|
||
|
|
}
|
||
|
|
|
||
|
|
void CElementHelper::CreateLineStringElement(DPoint3dCP pPoints, int pointCount)
|
||
|
|
{
|
||
|
|
assert(pPoints != nullptr && pointCount >= 2);
|
||
|
|
DgnModelRefP pActiveModel = ISessionMgr::GetActiveDgnModelRefP();
|
||
|
|
EditElementHandle eeh;
|
||
|
|
LineStringHandler::CreateLineStringElement(eeh, nullptr, pPoints, pointCount, pActiveModel->Is3d(), *pActiveModel);
|
||
|
|
eeh.AddToModel();
|
||
|
|
}
|
||
|
|
|
||
|
|
void CElementHelper::CreateCurveElement(CurveVectorCP pCurveVector)
|
||
|
|
{
|
||
|
|
assert(pCurveVector != nullptr);
|
||
|
|
DgnModelRefP pActiveModel = ISessionMgr::GetActiveDgnModelRefP();
|
||
|
|
EditElementHandle eeh;
|
||
|
|
DraftingElementSchema::ToElement(eeh, *pCurveVector, nullptr, pActiveModel->Is3d(), *pActiveModel);
|
||
|
|
eeh.AddToModel();
|
||
|
|
}
|
||
|
|
|
||
|
|
void CElementHelper::BodyFromLoft(CurveVectorPtr* pCurveVectorPtr, int profileCount, DgnModelRefP pDgnModelRef)
|
||
|
|
{
|
||
|
|
assert(pCurveVectorPtr != nullptr && profileCount >= 2);
|
||
|
|
ISolidKernelEntityPtr solidPtr;
|
||
|
|
BentleyStatus status = SolidUtil::Create::BodyFromLoft(solidPtr, pCurveVectorPtr, profileCount, nullptr, 0, *pDgnModelRef);
|
||
|
|
assert(status == SUCCESS && solidPtr.IsValid());
|
||
|
|
|
||
|
|
EditElementHandle eeh;
|
||
|
|
DraftingElementSchema::ToElement(eeh, *solidPtr, nullptr, *pDgnModelRef);
|
||
|
|
eeh.AddToModel();
|
||
|
|
}
|
||
|
|
|
||
|
|
void CElementHelper::ShowMessage(WCharCP message)
|
||
|
|
{
|
||
|
|
mdlDialog_dmsgsPrint(message);
|
||
|
|
}
|