老师请问一下我C++代码创建的named boundaries 该怎么设置上面的属性(上图为界面创建的named boundary).
我在c++库中看见有一个NamedBoundaryClipDepths 类这个该怎么去用,老师这边有没有例子
pts[0].x = 30000 * g_1mu1; pts[0].y = 0; pts[1].x = 40000 * g_1mu1; pts[1].y = 0; pts[2].x = 40000 * g_1mu1; pts[2].y = 10000 * g_1mu1; pts[3].x = 30000 * g_1mu1; pts[3].y = 10000 * g_1mu1; if (SUCCESS == ShapeHandler::CreateShapeElement(eehShape, NULL, pts, 4, ACTIVEMODEL->Is3d(), *ACTIVEMODEL)) {
//eehShape
eehShape.AddToModel(); namedptr = NamedBoundary::Create(); namedptr->SetModelRef(ACTIVEMODEL); namedptr->SetName(L"testview"); namedptr->SetDrawingScale(1.0); namedptr->SetGraphicalElement(eehShape); namedptr->Save(); boundarygrop->InsertBoundary(namedptr); boundarygrop->WriteToFile();
//设置named boundary 属性(剪切深度等)
请尝试调用NamedBoundaryClipDepths::AppendToElement (EditElementHandleR graphicalEl, double frontDepth, double backDepth, bool cropFront, bool cropBack, bool flipDirection=false);
不知道怎么将这个设置与named boundary 关联起来,下面这样设置之后是不会起作用.
eehShape.AddToModel(); namedptr = NamedBoundary::Create(); namedptr->SetModelRef(ACTIVEMODEL); namedptr->SetName(L"testview"); namedptr->SetDrawingScale(1.0); NamedBoundaryClipDepths::AppendToElement(eehShape,1000000, 1000000, true,true, true); namedptr->SetGraphicalElement(eehShape); namedptr->Save(); boundarygrop->InsertBoundary(namedptr); boundarygrop->WriteToFile();
namedptr->SetGraphicalElement(eehShape);放在NamedBoundaryClipDepths::AppendToElement(eehShape,1000000, 1000000, true,true, true);之前执行试试。
我试过的,都不行,好像就是没有关联起来;不知道怎么设置才会起作用,SetGraphicalElement()设置前后我都试过.
NamedBoundry添加到文件后,即boundarygrop->WriteToFile();执行了之后,再通过NamedBoundaryClipDepths的构造函数构造其实例,然后调用其ExtractFromElement或者AppendToElement试试,最后别忘了保存的 操作。
不行没有用属性设置不成功.试了很多都没有设置成功的.
只需要在创建的graphicalElement后调用我说的这个函数即可。示例代码如下:
void createNamedBoundary(WCharCP) { DPoint3d pts[4] = { {0,0,0}, {1000,0,0}, {1000, 500,0}, {0,500,0} }; EditElementHandle eeh; ShapeHandler::CreateShapeElement(eeh, nullptr, pts, 4, ACTIVEMODEL->Is3d(), *ACTIVEMODEL); NamedBoundaryClipDepths::AppendToElement(eeh, 50, 60, true, false); eeh.AddToModel(); NamedBoundaryPtr pBoundary = NamedBoundary::Create(); pBoundary->SetModelRef(ACTIVEMODEL); pBoundary->SetName(L"MyNamedBoundary"); pBoundary->SetDrawingScale(1.0); pBoundary->SetGraphicalElement(eeh); pBoundary->Save(); }
Answer Verified By: chen chen