Locating a Transient Element

Hi,

Is it possible to locate transient elements using a C# Addin?

I have created some transient elements and added them to a transient container.

I am trying to locate elements inside the dynamics of a IPrimitiveCommandEvents.

// LocateElement looks for elements in the range specified by the LocateTolerance.  
Element element = Microstation.CommandState.LocateElement(ref cursorPosition, ViewUtilities.CurrentView, true);

I have found some previous posts indicating this can be achieved in mdl.

mdlModelRefList_add (tcb->searchModelList, TRANSIENT_MODELREF);

I have tried executing this mdl before I start my primitive command but LocateElement always returns null for transient elements.

I have also tried doing this in a ILocateCommandEvents ans setiing the LocateCriteria, but cannot find a matching MsdElementClass
or MsdElementType for transient elements.

Any ideas would be appreciated.

Thanks

Jon

  • Unknown said:
    I cannot find a matching MsdElementClass or MsdElementType for transient elements.

    Transient elements are normal elements, so they have no particular MsdElementClass. Transient elements are never saved.  They are stored in a special cache TRANSIENT_MODELREF. The cache that TRANSIENT_MODELREF references is never written to file.

    When you add an element to the transient cache you have an opportunity to tell MicroStation how that element should behave.

    CreateTransientElementContainer1 has a flags argument of type MsdTransientFlags.

    Choosing msdTransientFlagsSnappable should make your elements [edited] locatable snappable.

     
    Regards, Jon Summers
    LA Solutions

  • Locate is different than snapping. If you want to AccuSnap or Tentative to a transient you do need to set it's snappable flag. If you really want to locate a transient you do need to include TRANSIENT_MODELREF in the search list to prevent the element from being filtered out...



  • Is it possible to enable this in a C# Addin?

    I have tried using pInvoke to call mdlModelRefList_add but can't seem to find anway to get hold of the list to add the model to  (DgnModelRefListP)

    Also if enabled via mdl will the CommandState.LocateElement respect this change and find Transient elements inside a IPrimitiveCommandEvents.

    Thanks

    Jon