[MS Connect Edition C++] mdlClip_element() crashes with non persistant element

Hi everybody,

I use the function mdlClip_element with a non persistant element for the inputEdP and the function crashes.
In the follwing code, DynAccroElmDscrP is non persistant.


if (mdlClip_getFence(clipP) == SUCCESS)
{
// DynAccroElmDscrP is a correct linestring element
// the following line crashes
mdlClip_element(InsideElmDynDscrPP, OutElmDynDscrPP,DynAccroElmDscrP, ACTIVEMODEL, clipP.get(), vue);
}

With the following code, everythink is ok

      if (mdlClip_getFence(clipP) == SUCCESS)
      {
        mdlElmdscr_addByModelRef(DynAccroElmDscrP, ACTIVEMODEL);
        mdlClip_element(InsideElmDynDscrPP, OutElmDynDscrPP,
          DynAccroElmDscrP, ACTIVEMODEL, clipP.get(), vue);
      }

But the problem is that I don't want to add this ElementDescr immediatly.

Thank's for your help!

Regards,

Hervé

Parents
  • Herve,

    Did you ever come up with a solution to this problem. I am having the same problem.

  • I am having the same problem

    In which version of MicroStation?

    DgnPlatform::EditElementHandle ehh(DynAccroElmDscrP, false,true);

    I find the bools in the ElementHandle constructor hard to remember, and prefer to document them like this...

    const bool Owner = true;
    const bool IsUnmodified = true;
    DgnPlatform::EditElementHandle ehh(DynAccroElmDscrP, !Owner, IsUnmodified);
    ehh.GetElementDescrP()
    
    

    A comment in the MicroStationAPI tells us: This call should only be used where necessary, and should be avoided in readonly. Use PeekElementDescrCP to see whether this ElementHandle already has an MSElementDescr.

    mdlClip_element(InsideElmDynDscrPP, OutElmDynDscrPP,
        ehh.PeekElementDescrCP(), ACTIVEMODEL, clipP.get(), view);

    Without seeing your code it's hard to comment further.

     
    Regards, Jon Summers
    LA Solutions

  • MicroStation V10.14.0.109 This is legacy v8i code that we are just trying to get to work in V10. mdlClip_isElemInside works perfectly when the element is a persistent element. It only crashes on elements that have not yet been added to the design file. I will try using EditElementHandle, but I thought Herve said that crashed too.

  • mdlClip_isElemInside works perfectly when the element is a persistent element. It only crashes on elements that have not yet been added to the design file

    As  commented, a persistent element has a DGN model associated with it.  A newly-created element in memory does not have a DGN model assigned. 

    One reason for suggesting use of an ElementHandle is that the DGN model can be specified in its constructor, or assigned later.  An ElementHandle with a DGN model reference should behave in the same way as one obtained from a persistent element.

    If you're using a raw MSElementDescr then you can assign a DGN model reference to its dgnModelRef member...

    MSElementDescrP inputElement = ...
    inputElement->h.dgnModelRef = ACTIVEMODEL;

    Please post your code for further analysis.

     
    Regards, Jon Summers
    LA Solutions

    Answer Verified By: Robert Hook 

Reply
  • mdlClip_isElemInside works perfectly when the element is a persistent element. It only crashes on elements that have not yet been added to the design file

    As  commented, a persistent element has a DGN model associated with it.  A newly-created element in memory does not have a DGN model assigned. 

    One reason for suggesting use of an ElementHandle is that the DGN model can be specified in its constructor, or assigned later.  An ElementHandle with a DGN model reference should behave in the same way as one obtained from a persistent element.

    If you're using a raw MSElementDescr then you can assign a DGN model reference to its dgnModelRef member...

    MSElementDescrP inputElement = ...
    inputElement->h.dgnModelRef = ACTIVEMODEL;

    Please post your code for further analysis.

     
    Regards, Jon Summers
    LA Solutions

    Answer Verified By: Robert Hook 

Children