revit macros

revit macros

Mouhammad_mazzaz
Advocate Advocate
974 Views
3 Replies
Message 1 of 4

revit macros

Mouhammad_mazzaz
Advocate
Advocate

Hi 
I am trying to learn how to make a macros in revit 
and i saw some video but it was  in revit 2014 

 first qus :
what is wrong with my macros i am working on revit 2020 

public void selectElement()
        {
            UIDocument uidoc = this.ActiveUIDocument ;
            Document doc = uidoc.Document;
            
            Reference myRef = uidoc.Selection.PickObjects(ObjectType.Element);
            
            Element e = doc.GetElement(myRef);
            
            TaskDialog.Show("Element Info",e.Name + Environment.NewLine + e.Id);
            
        }

2nd ques is :
what is version of revit that has the same api lang of revit 2014  

i do not wanna work on revit 2014 so the video made on revit 2014 what other version i still can make macros like revit 2014 ?! 

thank u and sorry for my language 

0 Likes
Accepted solutions (2)
975 Views
3 Replies
Replies (3)
Message 2 of 4

so-chong
Advocate
Advocate
Accepted solution

Hi,

 

Try to change this line of code

 Reference myRef = uidoc.Selection.PickObjects(ObjectType.Element);

to this

 Reference myRef = uidoc.Selection.PickObject(ObjectType.Element);

 

Concerning you 2nd question:

 

You can still try to make macros as your revit 2014 video demonstrates, running on a revit 2020 machine.

Some macro's will work, some will give you errors.

Most likely this is due to obsolete properties or methods of some classes with each new Revit API release.

You should look at Jeremy's (The Building Coder blog) to know whats's new (or deprecated) with each new Revit API release.

 

Hope this helps.

 

Message 3 of 4

Mouhammad_mazzaz
Advocate
Advocate

Hi @so-chong  
thank u very much for the help 
it is work fine 
i don't know any programing language and the course said u do not need to be a programer or knowledge of any programing language 
so do i have to take c# course ! or what is  the easiest programing language i could learn to make macros and revit addins that's also can deals with math process ?!

0 Likes
Message 4 of 4

so-chong
Advocate
Advocate
Accepted solution

Hi Mouhammad,

 

Thank you for your appreciation.

 

Yes, it will be wise to take some C# course in general if you have no or little programming experience.
Personally i prefer C#, but i hear also a lot of beginners are starting with Python as programming language.
I have no experience with Python, hopefully there some forum members how can tell you if Python is more suitable for beginners.

There is already a topic started by jrrdm with a similar question like yours, maybe it's useful for you.

 

Thanks to @stever66  and @jeremytammik for sharing their insights on this topic.

 

Do you speak or read Arabic?

 

Revit API School 

 

I hope this video channel is useful for you.

 

Good luck and have fun!

 

Cheers,

 

So-Chong