[CE U13.1 C#] How to work with Type 19 Solid in LocateSubEntityTool?

Hi,

I am working on a tool designed for 3D operations with solid, where one from possible inputs can be old solid (element type 19).

I am aware of a fact that not ISolidKernelEntity (which I guess is also type 19) has limited support, but I was not able to implement any working code that would allow me to access the solid geometry.

The tools is "read only / query tool", so IsModifyOriginal returns true. I am not sure what is a right value returned from OnPreElementModify.

I am able to select the solid and its face(s), but I failed to do anything in OnElementModify:

public override StatusInt OnElementModify(Element element)
{
    SubEntity[] subEntities = new SubEntity[0];
    this.GetAcceptedSubEntities(ref subEntities);
    // Ok, I receive accepted faces

    for (int i = 0; i < subEntities.Length; i++)
    {
        SubEntity face = subEntities[i];

        IntPtr geom = default(IntPtr);
        BentleyStatus getGeometryStatus = this.GetSubEntityGeometry(geom, face);
        // getGeometryStatus is SUCCESS, but the pointer is always zero ... no data

        SubEntity[] vertices;
        BentleyStatus getFaceVerticesStatus = SolidUtil.GetFaceVertices(out vertices, face);
        // getFaceVerticesStatus is always ERROR
    }

    // Element is not modifed
    // From C++ documentation: ERROR to reject change or if change completely handled by tool.
    return StatusInt.Error;
}

I also tried to overwrite

protected override BentleyStatus OnProcessSolidPrimitive(ref SolidPrimitive geomPtr, DisplayPath path)
{
    return BentleyStatus.Error;
}

but the results are always the same regardless Error or Success is returned. It seems the method is never called, I was not able to reach a break point in Debug or to print a message from the method :-(

I would like to know whether I do anything wrong (e.g. to override some other method?) or there is a bug in the code (maybe two bugs? ... OnProcessSolidPrimitve not called and GetSubEntityGeometry returns success but not pointer?).

Ultimately, I need to obtain:

  • geometry (and vertices), when a user selects face
  • curve (and end points), when a user selects edge
  • point, when a user selects vertex

With regards,

  Jan

Parents
  • The tools is "read only / query tool", so IsModifyOriginal returns true

    Shouldn't that return false?

    I am not sure what is a right value returned from OnPreElementModify

    Here are some comments from ...

    Just wanted to add a couple things that probably aren't obvious.

    DgnElementSetTool establishes the locate criteria in _SetLocateCriteria (which is called from _BeginPickElements for pick and _BuildAgenda for fences and selection sets). This is the place to add any tool specific locate criteria as opposed to _OnPostInstall.

    Returning false from _IsModifyOriginal allows locked/reference elements to be selected as it puts DgnElementSetTool into copy mode. For a query only tool this can have the undesirable side-effect of cloning styles, etc. from the source to the destination.

    To avoid this, a query tool should override _OnPreElementModify. If you return SUCCESS without calling super, _OnElementModify will still be called if that's where you want to have your logic to extract information from the selected elements.

     
    Regards, Jon Summers
    LA Solutions

Reply
  • The tools is "read only / query tool", so IsModifyOriginal returns true

    Shouldn't that return false?

    I am not sure what is a right value returned from OnPreElementModify

    Here are some comments from ...

    Just wanted to add a couple things that probably aren't obvious.

    DgnElementSetTool establishes the locate criteria in _SetLocateCriteria (which is called from _BeginPickElements for pick and _BuildAgenda for fences and selection sets). This is the place to add any tool specific locate criteria as opposed to _OnPostInstall.

    Returning false from _IsModifyOriginal allows locked/reference elements to be selected as it puts DgnElementSetTool into copy mode. For a query only tool this can have the undesirable side-effect of cloning styles, etc. from the source to the destination.

    To avoid this, a query tool should override _OnPreElementModify. If you return SUCCESS without calling super, _OnElementModify will still be called if that's where you want to have your logic to extract information from the selected elements.

     
    Regards, Jon Summers
    LA Solutions

Children