String to Element generic models

Hi all, I am in process of creating a script.

Purpose of the script:
I have to select a particular family by instance and filter by an opening ID. Later I have to change a couple of values for a particular family instance.

But, i need suggestions for converting strings to elements.

Hello …could something help…