.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Conversion layer properties

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
468 Views, 2 Replies

Conversion layer properties

Hello everyone.

Well I would like to state my question to friends who can help me, I shall be grateful.

I have a few variables, all of type string that is read from a txt file.
string name = "MyLayer";
string color = "7";
string linetype = "Continuous";
string lineweight = "ByLineWeightDefault";
string plotstyle = "Color_7";

With this data I create a new layer, but there are two variables that I'm not getting\r
make the necessary conversions.
linetype e lineweight.

Here is a snippet of code as an example.

LayerTableRecord registroLayer = new LayerTableRecord();

registroLayer.Name = name;
registroLayer.Color = Color.FromColorIndex(ColorMethod.ByAci, Convert.ToInt16(color));
registroLayer.LinetypeObjectId = Linetype;
registroLayer.LineWeight = lineweight;
registroLayer.PlotStyleName = plotstyle;
                    
tabelaLayer.Add(registroLayer);
transacao.AddNewlyCreatedDBObject(registroLayer, true);
transacao.Commit();

Regards to all
Robson (Brazil)

2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Robson,

 

Lineweight is an Autodesk.AutoCAD.DatabaseServices.Lineweight Enum. You have to convert the string to an Enum. You can do this like:

 

System.Enum.Parse(GetType(Autodesk.AutoCAD.DatabaseServices.LineWeight), plotstyle)

 The plotstyle is coming from a PlotStyle object that must exist in the drawing. If the PlotStyle does not exist or if your drawing is using CTB instead of STB, then this will not work.

 

 

HTH

 

Message 3 of 3
Anonymous
in reply to: Anonymous

Josh Modglin,

 

I am grateful for the help, the example you posted killed the riddle.
Hugs
Robson

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost