You could use the Editor. GetNestedEntity() method to get the line.
The objectId is the one the line within the block definition.
using (var tr = db.TransactionManager.StartTransaction())
{
PromptNestedEntityResult result;
while (true)
{
result = ed.GetNestedEntity("\nSelect a line within a block reference: ");
// user cancelled
if (result.Status != PromptStatus.OK)
{
return;
}
// check if the selected object is a line
if (result.ObjectId.ObjectClass.DxfName == "LINE")
{
// check if the line is nested
if (result.GetContainers().Length == 0)
{
ed.WriteMessage("\nThe selected line is not nested in a block reference.");
}
else
{
break;
}
}
else
{
ed.WriteMessage("\nThe selected entity is not a line.");
}
}
// open the line of the block defintion
var line = (Line)tr.GetObject(result.ObjectId, OpenMode.ForRead);
// compute the transformation matrix from the containers
var xform = result.GetContainers()
.Select(id => (BlockReference)tr.GetObject(id, OpenMode.ForRead))
.Select(br => br.BlockTransform)
.Aggregate((m1, m2) => m2 * m1);
// transform the line start and ensd points
var startPoint = line.StartPoint.TransformBy(xform);
var endPoint = line.EndPoint.TransformBy(xform);
ed.WriteMessage($"\nStart point: {startPoint}\nEnd point: {endPoint}");
tr.Commit();
}
Feel free to contact us is need additional assistance. @anhtrung