.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Layers and Linetypes
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
114 Views, 2 Replies
07-29-2005 09:09 AM
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?
David
Everyone has a photographic memory,
some just don't have film.
Everyone has a photographic memory,
some just don't have film.
*Jim Awe
Re: Layers and Linetypes
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
07-30-2005 08:41 PM in reply to:
davidhall
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("\nCreat ed 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?
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("\nCreat
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.
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?
Re: Layers and Linetypes
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-01-2005 11:02 AM in reply to:
davidhall
Thanks. I was close, but now I know what I was doing wrong
David
Everyone has a photographic memory,
some just don't have film.
Everyone has a photographic memory,
some just don't have film.
