Search name constant contain string

Search name constant contain string

Anonymous
Not applicable
3,653 Views
23 Replies
Message 1 of 24

Search name constant contain string

Anonymous
Not applicable

Dear all,

 

I want to search the elements that has a name constant property.

For example, 

Category: Element

Property: Phase Created

Value: Phase "New Construction", #86961

 

How can I search this element with only a keyword "New"?

 

I tried to search through below code, but nothing returns.

SearchCondition.HasPropertyByDisplayName("Element""Phase Created").DisplayStringContains("New").IgnoreStringValueCase()

 

Best Regards,

John

0 Likes
Accepted solutions (1)
3,654 Views
23 Replies
Replies (23)
Message 21 of 24

Anonymous
Not applicable

Hi XiaoDong,

 

A sample model is uploaded for you to test.

There are serveral elements with the property 'Phased Created'.

 

Hi Ulski,

 

Yes, this is the only solution I found. However, the performance is not good. Thus, I hope to find another solution from Xiaodong.

 

Best Regards,

John

0 Likes
Message 22 of 24

xiaodong_liang
Autodesk Support
Autodesk Support
Accepted solution

Hi John,

 

The value of Element >> Phase Created is a NamedConstant. My code demo in message 10 does not apply because I thought it is just a string or something that can be converted to string. The issue can be reproduced at my side. i.e. LINQ seems not working with NamedConstant. 

 

In addition, if checking by SDK sample AppInfo, it shows NamedCosntant.Value is exactly the value we saw in property panel (AppInfo uses reflection to get object attributes.)  while if checking by API, NamedCosntant.Value is 0, and the NamedCosntant.DisplayName is is exactly the value we saw in property panel. This is also strange to me.

 

I will log the issue to our engineer team. At this moment, I did not find a workaround 😞

0 Likes
Message 23 of 24

Anonymous
Not applicable

Hi Xiaodong,

 

Never mind. Thank you for investigating the problem as well as logging it.

 

Best Regards,

John

0 Likes
Message 24 of 24

xiaodong_liang
Autodesk Support
Autodesk Support

the issue that is logged NW-DID 52279