Dear Ahmed,
Thank you for your query.
If you are new to the Revit API, and maybe to programming in general, I first of all welcome you to this topic and forum!
Before diving any deeper into programming more complex tasks, I would suggest that you work through the Revit API beginners material, especially the video tutorial:
https://thebuildingcoder.typepad.com/blog/about-the-author.html#2
That will explain all the important basics, deepen your understanding, and clarify many questions up front.
Also, please be aware of the importance of understanding Revit and the BIM from an end user point of view before trying to achieve anything programmatically:
https://thebuildingcoder.typepad.com/blog/2018/06/extensible-storage-and-renaming-a-family-in-a-proj...
Otherwise, you might quickly find yourself in a situation where your add-in is trying to work against the BIM system instead of making proper use of its powerful built-in functionality.
Once you have a good grasp of the basics of both the Revit API and the end user view of the BIM task you are addressing, it is time research how to solve your task programmatically:
https://thebuildingcoder.typepad.com/blog/2017/01/virtues-of-reproduction-research-mep-settings-onto...
If you run into an issue after you know what you want to achieve, have ensured that it makes sense in the BIM workflow, have ensured that it can be solved programmatically at all and have done research on how to address it, the time has probably come to ask a question about the specific problems you encounter.
When you ask a question, it is important to do so in an intelligent and intelligible manner. For instance, please ask your question in full.
I have no idea what the code snippet that you share is supposed to achieve. You need to tell me.
Please explain your goal, the context, the workflow, the expected behaviour, the actual real behaviour, and why that is a problem for you. Do all that, and at the same time keep it really brief and to the point.
I cannot guess what you are trying to achieve.
Here are some hints on how to ask a question in general:
https://www.wikihow.com/Ask-a-Question-Intelligently
https://www.lifehack.org/articles/communication/how-amazingly-good-asking-questions.html
More specifically, here are important recommendations on asking a question about solving a programming task:
https://stackoverflow.com/help/how-to-ask
This last one is a really important post, so please read it in full!
Here are a few thousand other good suggestions on asking questions well:
https://duckduckgo.com/?q=how+to+ask+a+question
I hope this helps.
Please understand that I do not want to criticise your question. I just want to help you get an effective answer.
I wish you much success getting started with the Revit API and look forward to further questions from you in the near future.
Best regards,
Jeremy