Community
Hi.
I think I have a trouble with my drawing (drawing template).
In this part:
ObjectIdCollection IdsampleLineGroup = alin.GetSampleLineGroupIds(); foreach (ObjectId id_slg in IdsampleLineGroup) //obtenemos todos los grupos de líneas de muestreo de dicha alineación { Autodesk.Civil.DatabaseServices.SampleLineGroup slg = default(Autodesk.Civil.DatabaseServices.SampleLineGroup); slg = trans.GetObject(id_slg, OpenMode.ForRead) as SampleLineGroup;
IdsampleLineGroup collection has 1 item (count=1)
but in this line:
slg = trans.GetObject(id_slg, OpenMode.ForRead) as SampleLineGroup;
my app throws the exception "eNullObjectid" because:
index 0 is :
IdsampleLineGroup[0]={(0)}
Why happen that and how can I avoid it?
Thanks.
Solved! Go to Solution.
Solved by Civil3DReminders. Go to Solution.
I check for objectId is not null value and then use the ObjectId in the code.
if (testObjId != ObjectId.Null)
{
}