Edit Revit Dynamo Python in Visual studio community

The stubs export- I am missing something. I got back to the original posters stub reference here:

Cleaned up the previous posts and this is mostly working…

Revit Python in Visual Studio Revit Stubs 2022 for Python Revit Intellisense

September 01, 2022

Coding in python and fighting the #Autodesk Python basic editor with all the Case Sensitive syntax I decided to use Visual studio to code/debug. Problem is I was missing stubs. Grabbed them from the gtalarico GIT iron python stubs through a Visual studio Community 20220 CLONE in Visual Studio Community 2002:

Adding the references to Visual studio:

Tools>Options and:

Add Stubs Path to the top-level folder containing stubs(4) along with the Autodesk revit generated Stubs(5) and some GIT HUB Cloned Iron Python Stubs(6) and the general iron python stubs (7)(see below):

STUBS PATH:

C:\Users\rallen\source\repos\ironpython-stubs\release\stubs

SEARCH PATHS:

C:\Users\rallen\source\repos\ironpython-stubs\release\stubs\Autodesk

C:\Users\rallen\source\repos\ironpython-stubs\release\stubs\DSCore

C:\Users\rallen\source\repos\ironpython-stubs\release\stubs\IronPython

C:\Users\rallen\source\repos\ironpython-stubs\release\stubs\Revit

C:\Users\rallen\source\repos\ironpython-stubs\release\stubs\RevitServices

NOTE:

%userprofile% didn’t appear to work in the settings an the Semicolon “;” was easiest to separate the values. Next check the semicolons were changed to linefeed/breaks for readability.

Still have a few stragglers - bay be a stubs I need to add?

5 Likes

I use the integrated Dynamo editor for 95% of my work, any of the many online environments for 4%, and directly launching IronPython or CPython for the other 1% so I can’t really help.

Know anyone who works in VS that could help?

Unfortunately not; Everyone I know who uses it is doing C not Python. Perhaps @solamour knows someone on the Dynamo team?

Likely where I will end up - thanks!

Solved and updated in initial post!

Hi Ron, will this enable to program in Cpython3 in Visual studio?
If so which interpreter do you use?
i am able to do it in Ironpython 2 but not in Cpython 3, so i could just copy/paste to the actual dynamo node.

Also,
would it be fair to say that since the Stubs are from an old version of Revit (say 2018?)it wont update if there was change in the RevitAPI of 2022?

Yep. Wish there was a way to bring in the STUBS through the API like an Include.

1 Like

Yes I too am largely stuck in 2. CPython is still so new and the overlap with the Autodesk API makes it difficult.

2 Likes

Thanks Ron, looka like it would be better to do it straight in Dynamo then, to make sure our CP3 code is working …

1 Like

you can research this project , can generate stub for new version GitHub - BIMOpenGroup/RevitAPIStubs: Заглушки .NET библиотек для IronPython

2 Likes

and here:
https://github.com/mcneel/pythonstubs#readme

This one features Ehsan Iran-Nejad (Creator of Py Revit) as an editor which is what started this chase!

1 Like

Great search feature in the “Custom component set” in Visual studio -
C:\Program Files\Autodesk\Revit 2022\AddIns\DynamoForRevit\Revit\RevitServices.dll for our “Services” include and search.

Really wish we had this full search INSIDE the python/design script editors! This is what drives folks to the API in lieu of just Dynamo. I understand better why Mr. Konrad S. doesn’t work in Python anymore.

Example of reverse-lookup toi see what classes and imports to add: