Yes, but probably not with the quality of life features you’re used to. Intellisense or a language server protocol need to index what packages or .NET assemblies you’re importing, and the default paths in Dynamo are probably not how you have VSCode configured. I’ve never tried to do that myself because, personally, I find the .NET API for C3D requires far too much effort on otherwise billable time to justify its use. Also, as far as I know, you can’t just open up a Python script into the Dynamo editor. You can copy-paste, of course, which is inconvenient. You can also make a module and import it with the Python Script editor Dynamo comes with. Get ready for a long tangent about that:
First, I’m using C3D 2022, and Dynamo supports a CPython3 interpreter, which probably has more of the functionality you actually want (IronPython is not a MSFT priority and it’s far behind CPython). CPython can still use pythonnet to interact with .NET assemblies (if you’re using the CPython3 interpreter in the Dynamo editor, this is what the clr
import is)
The Python interpreter is embedded into the AutoCAD executable, so it does not behave like a normal Python installation. For starters, it’s, as of today, Python3.8, which means it doesn’t support newer features like the dictionary union operator or structural pattern matching. Also, if you want to use any downloaded packages (or your own), you have to add the file path to those packages at the top of your script (ie sys.path.append('C:\\Users\\you\\long-file-path\\site-packages')
. To my knowledge, there isn’t a way to use something simple like pip
for managing your packages in a way that ‘just works’ with Dynamo’s Python interpreter.
Appending a path to normally installed packages has worked for me for some python-only packages, like networkx, but anything with c-extensions, like numpy and friends I’ve had filepath problems.
All that said, so far I’ve made a point to only use C3D-specific APIs using the visual editor or DesignScript, which, aside from the implicit flatmapping and zipping, isn’t that different than other scripting languages.