Get Custom\Visibility1 property from Polyline (LWPOLYLINE)

Get Custom\Visibility1 property from Polyline (LWPOLYLINE)

lihang_wen
Explorer Explorer
882 Views
4 Replies
Message 1 of 5

Get Custom\Visibility1 property from Polyline (LWPOLYLINE)

lihang_wen
Explorer
Explorer

I have a DWG drawing, and there are lots of polylines. I want to get the polylines of a certain layer, and then group them by the Custom \ Visibility1  property ( which is actually the diameter). 

 

However, when I get the polyline entity of that layer, I can't get that Visibility1 property.   I tried to get the XData, but it is null.

ResultBuffer rb = polyline.XData;

if (rb != null) //  it's always null

{...

}

 

I'm open to get them using C# or LISP. 

 

Thanks. 

 

 

Screenshot 2023-11-10 093235.png

0 Likes
Accepted solutions (1)
883 Views
4 Replies
Replies (4)
Message 2 of 5

Norman_Yuan
Mentor
Mentor

Look at the picture you posted: the "Custom" properties in the Properties Window is for BLOCKREFERENCE (dynamic block reference, in this case), not a Polyline!

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

lihang_wen
Explorer
Explorer

Good point. But I tried the same thing to get XData from a BlockReference, and it's still null. 

0 Likes
Message 4 of 5

_gile
Consultant
Consultant
Accepted solution

Hi,

 

The dynamic properties of a 'dynamic bloc" are not stored in xdata. they are stored in the DynamicBlockReferencePropertyCollection of the block reference. You have to iterate through this collection to get the DynamicBlockReferenceProperty which name is "Visibility1" and get its Value.

foreach (DynamicBlockReferenceProperty property in br.DynamicBlockReferencePropertyCollection)
{
    if (property.PropertyName == "Visibility1")
    {
        string visibility = (string)property.Value;
        // do your stuff...
    }
}

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 5 of 5

lihang_wen
Explorer
Explorer

I used this method and it worked. 

 

Thanks a lot. 

0 Likes