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:
With regards,
Jan
Jan Šlegr said:The tools is "read only / query tool", so IsModifyOriginal returns true
Shouldn't that return false?
false
Jan Šlegr said:I am not sure what is a right value returned from OnPreElementModify
Here are some comments from Brien Bastings...
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.
DgnElementSetTool
_SetLocateCriteria
_BeginPickElements
_BuildAgenda
_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.
_IsModifyOriginal
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.
_OnPreElementModify
_OnElementModify
Regards, Jon Summers LA Solutions
Hi Jon,
Jon Summers said:Shouldn't that return false?
Yes, of course, it's a typing error. It's false in test code and in fact it doesn't matter and the class behaves the sam in both cases.
Jon Summers said:Here are some comments from
I am aware of this discussion. After some thinking I assume this setting is not important for specifically this discussion.
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point