set layer name in creating description key set

set layer name in creating description key set

mehdi-guida
Advocate Advocate
473 Views
4 Replies
Message 1 of 5

set layer name in creating description key set

mehdi-guida
Advocate
Advocate

Hi

How can i set layer name during creating description key set by .NET ?

Thank you

0 Likes
474 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor

Your question is Civil 3D specific, while this forum is meant for vanilla AutoCAD .NET API discussion (well, I am sure many of the regulars here do use Civil3D). So if ypu post Civi3D specific question in forum for C3D, such as 

https://forums.autodesk.com/t5/civil-3d-customization/bd-p/190 

where you might get more attentions from some C3D experts.

 

With that said, here is the clue for you to achieve what you want:

 

You call PointDescriptionKeySetCollection class' static method GetPointDescriptionKeySets(), and identify the target DescriptionKetSet by its name in the collection; then you either loop through the key set to each DescriptionKey, or pick one in interest by its code. To set/change layer applied by this DescriptionKey, you change DescriptionKey.LayerId property to desired layer's ObjectId.

 

HTH

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

mehdi-guida
Advocate
Advocate

Thank you for respond but my question is about .NET

In code below i created a description key set and  code, set point style and label style for that.

now i don't know how to set a layer for that.

 

using (Transaction trans = db.TransactionManager.StartTransaction())
{
// Access the collection of all Description key sets in a document
PointDescriptionKeySetCollection pointDescKeySetColl = PointDescriptionKeySetCollection.GetPointDescriptionKeySets(db);
// Add a new Descp. Key Sets
ObjectId PointDescKeySetsId = pointDescKeySetColl.Add("ADN_Point_Desc_Key");
PointDescriptionKeySet pointDescKeySet = trans.GetObject(PointDescKeySetsId, OpenMode.ForWrite) as PointDescriptionKeySet;
// Create a new key in the set with code = "TR*"
ObjectId pointDescKeyId = pointDescKeySet.Add("TR*");
PointDescriptionKey pointDescKey = trans.GetObject(pointDescKeyId, OpenMode.ForWrite) as PointDescriptionKey;
// set a specific Style and Label style
// in the following line we are presuming a Point Style named "Tree" exists in the DWG file
pointDescKey.StyleId = civildoc.Styles.PointStyles["Tree"];
pointDescKey.ApplyStyleId = true;

// in the following line we are presuming a Point Label Style
// named "Point#-Elevation-Description" exists in the DWG file
pointDescKey.LabelStyleId = civildoc.Styles.LabelStyles.PointLabelStyles.LabelStyles["Point#-Elevation-Description"];
pointDescKey.ApplyLabelStyleId = true;
trans.Commit();
}

0 Likes
Message 4 of 5

norman.yuan
Mentor
Mentor

As I have already replied:

 

pointDescKey.LayerId=[the layerId of your choice];

 

If you only know the Layer's name, obviously, you need to open LayerTable to get the LayerTableRecord's Id by its name.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 5

Jeff_M
Consultant
Consultant

@mehdi-guida wrote:

Thank you for respond but my question is about .NET

In code below i created a description key set and  code,....


As @norman.yuan pointed out, this is a question about the customization of Civil 3D so it should be asked in the C3D Customization forum. not the plain .NET forum. I have pointed this out to you a number of times in the past. The C3D Customization forum is for all questions regarding the use of the COM & .NET APIs with most any language (lisp, VBA, VB.NET, c#, c++, etc.).

Jeff_M, also a frequent Swamper
EESignature
0 Likes