- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to "clone" or copy a layer in a drawing and then rename it use C#. What I am starting with is the layer name of a MLeader object that I need to create a new MLeader object on a different layer with the same properties as the layer the original MLeader object is located on.
Right now, I have the layer name of the existing MLeader and have created the new layer name. I am able to change to the new layer if it exists, but if it does not, I have to create the new layer and then change to it before creating the new MLeader object.
I am struggling with retrieving the layer color from the original MLeader object layer. The MLeader color is by layer, so I have to get the color from the layer itself.
Code so far:
[CommandMethod("SetUnitLayerSibling")]
private static void SetUnitLayerSibling(Database acCurDb, Document acDoc, string ulLayNam)
{
using (Transaction lTrans = acCurDb.TransactionManager.StartTransaction())
{
// Getting and setting MLeader layer information
String MtrLayName;
String tag;
MtrLayName = ulLayNam.Replace("_UNIT", "_MTR");
LayerTable lTbl;
lTbl = lTrans.GetObject(acCurDb.LayerTableId, OpenMode.ForRead) as LayerTable;
if (lTbl.Has(MtrLayName) == true)
{
// Set the layer
acCurDb.Clayer = lTbl[MtrLayName];
}
else
{
// Get unit layer parameters
LayerTableRecord ulRec;
// Clone unit layer and re-name
LayerTableRecord lTblRec = new LayerTableRecord();
lTblRec.Color =
}
lTrans.Commit();
}
}
Thanks in advance!
scott.sawdy@bluecoyotecad.com
Solved! Go to Solution.