You just need to get the ObjectId of the LinetypeTableRecord and set it
with:
LayerTableRecord.LinetypeObjectId = myLinetypeId;
I posted a large sample called MgdDbg the other day on this forum. In there
there is sample code that loads a named Linetype from the external file,
makes a new LayerTableRecord, and assigns the linetype to that Layer.
Here is the code (from ObjTests\MakeSymTblRecTests.cs):
public void
Layer()
{
string symName = "Jimbo";
using (TransactionHelper tr = new TransactionHelper(m_db)) {
tr.Start();
if (tr.SymbolTableRecExists(typeof(LayerTableRecord), symName)) {
Utils.AcadUi.PrintToCmdLine(string.Format("\nLayer \"{0}\" already exists.",
symName));
return;
}
LayerTableRecord lyr = new LayerTableRecord();
lyr.Name = symName;
lyr.LinetypeObjectId = Utils.SymTbl.GetOrLoadLinetypeId("ZIGZAG", m_db);
//lyr.Description = "Layer created programmatically by MgdDbg"; // Can't set
until after its added to the database!
lyr.Color = Color.FromRgb(0, 130, 160);
tr.AddNewSymbolRec(lyr);
tr.Commit();
Utils.AcadUi.PrintToCmdLine(string.Format("\nCreated layer \"{0}\".",
symName));
}
}
(sorry for the whacky formatting... it will fix itself if you paste it into
Visual Studio)
See the MgdDbg sample for the full code.
Jim Awe
Autodesk, Inc.
wrote in message news:4914948@discussion.autodesk.com...
After looking through every example I can find, it seems like no one has set
a linetype to a layer with C# yet. I can get the linetype loaded into my
current drawing, but I cannot set it to a layer. Any ideas?