Author Topic: How to find 1 xref layer  (Read 2017 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
How to find 1 xref layer
« 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.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Jeff H

  • Needs a day job
  • Posts: 6144
Re: How to find 1 xref layer
« Reply #1 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.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: How to find 1 xref layer
« Reply #2 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")
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)