TheSwamp

Code Red => .NET => Topic started by: David Hall on December 09, 2011, 09:43:55 AM

Title: How to find 1 xref layer
Post by: David Hall on December 09, 2011, 09:43:55 AM
I am trying to optimize some code that searches out a single xref layer, and wanted to know if there is a better way than what I put together.  It works just fine, but I wanted to make it better.
Code: [Select]
LayerTableRecord tempLayTR;
tempLayTR = tr.GetObject(tempLayId, OpenMode.ForWrite) as LayerTableRecord;
if (tempLayTR.Name.Contains("|SITE-FNDN"))
{
if (tempLayTR.Name.Substring(tempLayTR.Name.Length - 4) == "FNDN")
{
tempLayTR.Color = Color.FromColorIndex(ColorMethod.ByAci,1);
}
}

There could be multiple layers in the xref that contain the "|SITE-FNDN"  ie XREFNAME|SITE-FNDN-TEXT as example. 
 
Thoughts, ideas, etc.
Title: Re: How to find 1 xref layer
Post by: Jeff H on December 09, 2011, 10:38:34 AM
Checking for LayerTableRecord.IsDependent = true will let you know if it is xref dependent
and might help.
Title: Re: How to find 1 xref layer
Post by: David Hall on December 09, 2011, 10:48:55 AM
or maybe combine the 2 statements into 1 like this maybe
Code: [Select]
if (tempLayTR.Name.Substring(tempLayTR.Name.Length - 10) == "|SITE-FNDN")