Filter By Line Type (Python)

Hello All,

I am trying to write a graph that fully transforms an incoming CAD base to our CAD linework and block styles. I have almost figured out the whole thing out except for 2 hang-ups.

Problem: The base we get has a layer that contains 3 different representations of utilities pipe (as lines and polylines) on the same layer. They are differentiated by their line types.
I am trying to write a python script that takes 2 inputs:
IN[0] = A filtered list of objects, originally filtered by “All Objects On Layer.
And IN[1] = a string value that is the line type I wish to filter by. The script provides an output of only the objects from IN[0] that have the line type from IN[1].

I have been trying on my own by looking at the API and reviewing Paolo’s SetAllObjectsColorByLayer script and I can’t seem to get the script to work. Either I get an error about not calling the .LineType method to the proper object or I keep getting empty lists.

Problem: The base we get has manual definitions set for line weights. I would like to set them all ByLayer. .LineWeight method only seems to accept 0 as an acceptable value. LISP accepts -3 as Default value.
I had a look at Paolo’s SetAllObjectsColorByLayer and it get me 99% there. I had a look at the API (Autodesk.Civil.DatabaseServices.Styles> DisplayStyle Class > DisplayStyle Members > DisplayStyle.LineWeight Property) and wrote it into the script. The problem is that the script is only accepting 0 for the value, which sets the line weights to 0 mm. It won’t accept -3 for default or any of the other number values. Where do you guys find a list of acceptable values for your methods?

Thank you for any help you can give.

Upfront: I haven´t worked with the autocad or civil api. I´m commenting on the code and what i have found out by reading the api.

The BlockReference object does have LineType as an attribute. Did you try to unwrap your input at the beginning? ObjectList = UnwrapElement(IN[0])


I think you´ll need to assign an acLineWeight as value, rather than a number as -3

Try using:

...
line_weight = acLineWeight.acLnWtByLwDefault 
# OR line_weight = acLnWtByLwDefault 
obj.LineWeight = line_weight
...

I googled acLineWeight in numbers and found this document. It has on page 205 a table with enumeration and their numerical values:

You can try using the LineWeight Enum.
Lineweight.dyn (4.8 KB)