FS#2629 - Block content on not snappable layers is NOT ignored in pickEntity
Andrew,
In the attached file ‘ActingOnNotSnappable.dxf‘:
Both Block References are on layer 0 ... Snappable
Both red shapes are on layer 2 ......... Not snappable
Start AT, radius 15, indicate near the red circle and then a point on an arc.
Solutions to the red circle are previewed while this shape is NOT snappable.
(For the record: AT is not (yet) functional for ellipses)
Implemented as in many tools:
Typically in pickEntity it is verified that the indicated entity is snappable.
Returning nothing if not.
if (!this.isEntitySnappable(entity)) { return; }
Here ‘this’ refers to EAction.
- Checking if the given entity is not Null and derived from REntity.
Otherwise returning false ⇒ nothing.
- Retrieving the entity layer ID, its data and document.
- With a document verifying that the layer by id is snappable.
Returning false ⇒ nothing without a document.
What follows is a double test already verified for in the AND clause above:
if (isNull(entity)) { // # Duplicate # isEntitySnappable(entity) would be false return; } else { ...
After that it gets the nearest simple shape and verifies if that is supported by the tool.
For example ArcTPR, current line 145
shape = entity.getClosestSimpleShape(pos);
For a Block Reference living on a snappable layer it is not verified if the nearest simple shape also lives on a snappable layer.
I know, it gets more complicated than that ... The nearest simple shape may be a Polyline segment, a part of a Dimension, a simple shape from an explosion and so on.
These simple shapes are themselves no existent entities with the required layer to verify.
Then it is obvious that they virtually live on the same layer as the base entity.
One can test this on only the middle segment (Arc) of the Polyline.
Unless it is moved to layer 2.
Or AT to the dimension line or even the arrows, extension lines, ...
Being snappable is not always the case when shapes are part of a reference to a Block,
part of a Block Reference.
It can not be the intention that everything in a Block must share the same layer.
One could query the nearest sub entity ID with:
var subId = entity.getClosestSubEntityId(pos, Number.NaN, true);
But that is like doing things twice because it calls the same resource of REntityData.
REntity.getClosestSimpleShape(pos) calls REntity.getClosestShape(pos, range=NaN, ignoreComplex=true) What calls REntityData.getClosestShape(pos, range=NaN, ignoreComplex=true, subEntityId=NULL); Returning at least an invalid RShape. Convenience function for scripts: REntity.getClosestSubEntityId(pos, range=NaN, ignoreComplex=true) calls REntityData.getClosestSubEntityId(pos, range=NaN, ignoreComplex=true) What calls REntityData.getClosestShape(pos, range=NaN, ignoreComplex=true, subEntityId=RObject.INVALID_ID); Disregarding the shape but returning the subEntityId
Combining and querying the shape, and the entity ID at once fails so far ...
... QCAD Crashes.
Regards,
CVH