Hi all
i would like to use a fence and set the clip mode but I can't make it work. Here is my code:
virtual StatusInt _OnElementModify(EditElementHandleR eeh) override { if (eeh.GetElementType() == ELLIPSE_ELM) { FenceManagerR fenceManager = FenceManager::GetManager(); IndexedViewSetR viewSet = IViewManager::GetManager().GetActiveViewSet(); fenceManager.DefineByElement(&eeh, viewSet.GetViewport(tcb->lstvw)); FenceParamsP fenceParams = FenceParams::Create(ISessionMgr::GetActiveDgnModelP()); fenceManager.InitFromActiveFence(*fenceParams, false, true, FenceClipMode::Original); lifalib_dmsg("clipMode1 = %d", fenceManager.IsClipMode()); } }
The isClipMode method in the FenceManager returns 0 (false) but I expected it to return true while the doClip parameter of the InitFromActiveFence is set to true.
What am I doing wrong ?
Regards, Evan
Unknown said: fenceManager.InitFromActiveFence(*fenceParams, false, true, FenceClipMode::Original);
fenceManager.InitFromActiveFence(*fenceParams,
false
,
true
, FenceClipMode::Original);
The confusion may arise from the naming of that method. It doesn't initialise the fence manager, but rather populates your fenceParams. After that call, fenceParams should contain the settings you want, but fenceManager is unchanged.
fenceManager
Regards, Jon Summers LA Solutions
Thank you very much for your swift reply, Jon.
You are right that fenceParams contains the settings I want but when using these settings I don't get the expected result. When I run this code:
virtual StatusInt _OnElementModify(EditElementHandleR eeh) override { if (eeh.GetElementType() == ELLIPSE_ELM) { FenceManagerR fenceManager = FenceManager::GetManager(); IndexedViewSetR viewSet = IViewManager::GetManager().GetActiveViewSet(); fenceManager.DefineByElement(&eeh, viewSet.GetViewport(tcb->lstvw)); FenceParamsP fenceParams = FenceParams::Create(ISessionMgr::GetActiveDgnModelP()); fenceManager.InitFromActiveFence(*fenceParams, false, true, FenceClipMode::Original); // build modelreflist DgnModelRefListP modelRefList; mdlModelRefList_create(&modelRefList); mdlModelRefList_add(modelRefList, ISessionMgr::GetActiveDgnModelP()); ElementAgenda elmAgenda; lifalib_dmsg("fenceParams->GetClipMode() = %d", fenceParams->GetClipMode()); fenceManager.BuildAgenda(*fenceParams, elmAgenda, modelRefList, true, false, false); for (int elmIndex = 0; elmIndex < elmAgenda.size(); elmIndex++) { ElemAgendaEntry *elm = elmAgenda.GetEntryP(elmIndex); elm->DeleteFromModel(); } } }
not only the elementparts inside the ellipse are deleted. They are deleted completely. I only want to clip the elements and only delete the parts that are inside.
Answer Verified By: EvanH
Unknown said:I would like to use a fence ...
I found this note about the DgnElementSetTool class in MicroStationAPI help...
The DgnElementSetTool class can be used to implement a modify command. Simplifies dealing with the common element sources. Basic tool operation is to populate an ElementAgenda from the active fence, selection sets, or user locate. The tool's _OnElementModify method will then be called for each entry in the ElementAgenda
In other words, DgnElementSetTool lets us deal with a list of candidate elements in an ElementAgenda, irrespective of the source of its contents.
It also provides enum ClipResult, which seems useful in your case...
Helps determine the action ModifyAgenda will take on the agenda elements after calling DoFenceClip.