如图想实现管道的Join和Break功能,应该使用什么接口呢?
抱歉由于最近疫情原因,我们的技术支持工程师可能在家养病,不能及时回复,请您理解。
管道连接和打断是否有相关接口呢
打断和连接可以考虑自己通过MS和OPM的接口实现
在C:\Program Files\Bentley\OpenPlant CONNECT Edition\OpenPlantModeler\Assemblies\Bentley.OpenPlant.Modeler.Api.dll中有一个未公开的接口
Bentley.OpenPlant.Modeler.Api.BMECApi.BreakDuct(BMECObject pipe, DPoint3d* compEndPoints, DPoint3d* breakEndPoints)
可以测试看一下
抱歉,晚来的回复。 我写了俩个测试函数用于实现,其中内部所调用的接口确实没有公开(都在这个dll里面 C:\Program Files\Bentley\OpenPlant CONNECT Edition\OpenPlantModeler\Assemblies\Bentley.OpenPlant.Modeler.Api.dll),不过您还是可以调用。
1.测试方法,您在opm 中沿着x 轴方向,放置一个1000mm 长度的管子,然后使用以下代码来测试连接和 断开;
2.您需要在托管c++ 中使用接口
//连接断开的管子
void TestingPlantApi::MyTestingPlantAPI::TestingJoint(System::Int64 elementRef1, System::Int64 elementRef2){ ElementRefP eleRefP1 = (ElementRefP)elementRef1; ElementRefP eleRefP2 = (ElementRefP)elementRef2;
DgnModelRefP activeModelRefP = ACTIVEMODEL;
Bentley::ECObjects::Instance::IECInstance^ ele1Ecnstance = Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->FindInstance(eleRefP1, activeModelRefP);
Bentley::ECObjects::Instance::IECInstance^ ele2Ecnstance = Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->FindInstance(eleRefP2, activeModelRefP);
System::Collections::Generic::List<Bentley::Building::Mechanical::Components::Port^>^ ports1 = Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->GetPorts(ele1Ecnstance);
System::Collections::Generic::List<Bentley::Building::Mechanical::Components::Port^>^ ports2 = Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->GetPorts(ele2Ecnstance); Bentley::OpenPlant::Modeler::Api::BMECObject^ obj = Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->CreateBMECObjectForInstance(ele1Ecnstance);
if (Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->DeferCommits) { Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->DeferCommits = false; }
obj->SetLinearPoints(ports1[0]->LocationInUors, ports2[1]->LocationInUors); obj->Create();
EditElementHandle eeh(eleRefP2); eeh.DeleteFromModel();}
//打断一根直管
void TestingPlantApi::MyTestingPlantAPI::TestingBreakDuct(System::Int64 elementRef1){ ElementRefP eleRefP1 = (ElementRefP)elementRef1; DgnModelRefP activeModelRefP = ACTIVEMODEL; Bentley::ECObjects::Instance::IECInstance^ ele1Ecnstance = Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->FindInstance(eleRefP1, activeModelRefP); //BMECObject^ CreateBMECObjectForInstance(IECInstance ^ instance); Bentley::OpenPlant::Modeler::Api::BMECObject^ obj= Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->CreateBMECObjectForInstance(ele1Ecnstance);
Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->ObjectCache->AddToCache(obj);
Bentley::DPoint3d* breakpts=new Bentley::DPoint3d[2]; breakpts[0] = DPoint3d::From(600000, 0, 0); breakpts[1] = DPoint3d::From(700000, 0, 0);
Bentley::DPoint3d* endPts=new Bentley::DPoint3d[2]; endPts[0] = DPoint3d::From(0, 0, 0); endPts[1] = DPoint3d::From(1000000, 0, 0);
System::Collections::Generic::List<Bentley::OpenPlant::Modeler::Api::BMECObject^>^ results= Bentley::OpenPlant::Modeler::Api::BMECApi::Instance->BreakDuct(obj, endPts, breakpts);
delete[] breakpts; delete[] endPts; }