.NET

Reply
Valued Contributor
davidhall
Posts: 71
Registered: ‎06-03-2005
Message 1 of 3 (143 Views)

Layers and Linetypes

143 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.
*Jim Awe
Message 2 of 3 (143 Views)

Re: Layers and Linetypes

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("\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?
Valued Contributor
davidhall
Posts: 71
Registered: ‎06-03-2005
Message 3 of 3 (143 Views)

Re: Layers and Linetypes

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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community