TheSwamp

Code Red => .NET => Topic started by: waterharbin on April 13, 2015, 11:07:13 PM

Title: How to get the numeric LineWeight value of one Polyline?
Post 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:
Code: [Select]
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.
Title: Re: How to get the numeric LineWeight value of one Polyline?
Post by: n.yuan on April 14, 2015, 09:31:34 AM
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;
Title: Re: How to get the numeric LineWeight value of one Polyline?
Post by: waterharbin on April 14, 2015, 10:21:26 PM
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.
Title: Re: How to get the numeric LineWeight value of one Polyline?
Post by: kaefer on April 15, 2015, 06:39:37 AM
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?
Title: Re: How to get the numeric LineWeight value of one Polyline?
Post by: Jeff_M on April 15, 2015, 10:58:21 AM
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.