I'm expecting EntityContainer.Element(ObjectId) and EntityContainer.ElementOrDefault(ObjectId) to return only Entities that are children of the container.
Current Behavior
Currently it is possible to get an Entity that is present on a PaperSpace layout via the ModelSpace (see sample code below).
Context
Linq2Acad Version: 1.0.0
AutoCAD Version: 2022
Failure Information
The failure does not produce an error in the AutoCAD API. It is just a wrong behavior of Linq2Acad.
Sample Code
using (var db = AcadDatabase.Active())
{
// We expect to have an Entity in the paper space
var paperSpaceEntity = db.PaperSpace.First().First();
var _ = db.ModelSpace.Element(paperSpaceEntity.ObjectId);
System.Diagnostics.Debug.Fail("No exception thrown");
// The above call should actually throw an exception because paperSpaceEntity is not present in the model space
var result = db.ModelSpace.ElementOrDefault(paperSpaceEntity.ObjectId);
System.Diagnostics.Debug.Assert(result == null);
// result should actually be null because paperSpaceEntity is not present in the model space
}
Checklist
[x] I am running the latest version
[x] I checked the documentation and found no answer
[x] I checked to make sure that this issue has not already been filed
[x] I have provided sufficient information for the team
Expected Behavior
I'm expecting
EntityContainer.Element(ObjectId)
andEntityContainer.ElementOrDefault(ObjectId)
to return onlyEntities
that are children of the container.Current Behavior
Currently it is possible to get an
Entity
that is present on aPaperSpace
layout via theModelSpace
(see sample code below).Context
Failure Information
The failure does not produce an error in the AutoCAD API. It is just a wrong behavior of Linq2Acad.
Sample Code
Checklist