TheSwamp
Code Red => .NET => Topic started by: waterharbin on April 13, 2015, 11:07:13 PM
-
Hello,everyone.
I ues the LineWeight property to get a Polyline's line weight. Like this line of code:
myPolyline.LineWeight.ToString()
But sometimes I get a "ByLayer", not he numeric value. How should I fix it?
I suppose other objects would have the same problem. Since I would like to get a line's LineWeight value later, I would very much like to know how to deal with this problem.
-
LineWeight is of type "enum", which can be int, short, long, byte... but by default, it is of type "int" (or Int32) and is it the case for LineWeight.
So, you directly cast int and LineWeight to each other:
int lw=(int)myEntity.LineWeight;
Or
int lw=0;
myEntity.LineWeight=(LineWeight)lw; //This is the same as: myEntity.LineWeight=LineWeight.LineWeight000;
-
Hi, yuan.
I have already try your solution. But when it is "ByLayer", the cast result is "-1". And so, when I cast "-1" back, it is "ByLayer". Still can not get the numeric value.
-
Hi, yuan.
I have already try your solution. But when it is "ByLayer", the cast result is "-1". And so, when I cast "-1" back, it is "ByLayer". Still can not get the numeric value.
That is the numeric value. May I suggest that you look at the public declaration of the enum named Autodesk.AutoCAD.DatabaseServices.LineWeight?
-
If you want to get what the resulting lineweight is when the object's lineweight = ByLayer, you will need to get the value from the Layer's lineweight property.