importing freecad in python, intellisense, and code completition. How to?

Need help, or want to share a macro? Post here!
Post Reply
Posts: 6
Joined: Tue Jun 14, 2022 7:50 pm

importing freecad in python, intellisense, and code completition. How to?

Post by ryn »


I've been trying to figure out how to fix up the workflow in FreeCAD for making macros with vscode. So far, I've been able to attach vscode to the FreeCAD macro creation instance via the tutorial below:

However, it doesn't allow parameter inspection, code completion/general intellisense things. I've also tried importing FreeCAD via

Code: Select all

FREECADPATH = '/program files/FreeCAD 0.19/bin' # path to your or FreeCAD.dll file
import sys
import os
os.add_dll_directory(FREECADPATH + "/" + "python38.dll")
print(FREECADPATH + "/" + "python38.dll")


import FreeCAD
but python throws:

Code: Select all

ImportError: DLL load failed while importing FreeCAD: The parameter is incorrect.
Lastly, I've tried setting python in the .env file in my vscode folder to the below, which should link to FreeCAD's python 3.8 dll.

Code: Select all

PYTHONPATH="/program Files/FreeCAD 0.19/bin"
but that does nothing.

I've read people here have been experimenting with intellisense type things here, but I'm not sure how to progress past this point with what I've tried.

OS: Windows 10 Version 2009
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24267 +148 (Git)
Build type: Release
Branch: Branch_0.19.4
Hash: 476ecf091941bead59b14e44afa6064d5a66afa3
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.3
Locale: English/United States (en_US)
Post Reply