Missing BSplineCurve in 0.21

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
drmacro
Veteran
Posts: 8867
Joined: Sun Mar 02, 2014 4:35 pm

Missing BSplineCurve in 0.21

Post by drmacro »

The error is thrown when attempting to import BSplineCurve.

Code: Select all

from FreeCAD.Part import BSplineCurve
Traceback (most recent call last):
  File "<input>", line 1, in <module>
ImportError: cannot import name 'BSplineCurve' from 'FreeCAD.Part' (unknown location)
Did it get moved or completely replaced or...

Code: Select all

OS: Debian GNU/Linux 11 (bullseye) (XFCE/xfce)
Word size of FreeCAD: 64-bit
Version: 0.21.0.32634 (Git)
Build type: Release
Branch: master
Hash: 161e7aca989ce15ee3cbcbb1d4b3ff47812ac899
Python 3.9.2, Qt 5.15.2, Coin 4.0.0, Vtk 7.1.1, OCC 7.5.1
Locale: English/United States (en_US)
Installed mods: 
 ...
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Missing BSplineCurve in 0.21

Post by Chris_G »

I get same error.
But this works however :

Code: Select all

from Part import BSplineCurve
drmacro
Veteran
Posts: 8867
Joined: Sun Mar 02, 2014 4:35 pm

Re: Missing BSplineCurve in 0.21

Post by drmacro »

I found that after I hit the send.

This an external app using FreeCAD.

Code: Select all

    from FreeCAD.Part import BSplineCurve
    from FreeCAD.Part import makeCompound
Changing to this corrects the issue:

Code: Select all

    import Part
    from Part import BSplineCurve
    from Part import makeCompound
Apparently the code worked prior to 0.21
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: Missing BSplineCurve in 0.21

Post by Syres »

drmacro wrote: Wed Mar 29, 2023 5:40 pm Apparently the code worked prior to 0.21
I believe your original code worked until quite/very recently!!
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Missing BSplineCurve in 0.21

Post by onekk »

It could not be related to some Python version change?

Code: Select all

from FreeCAD.Part ....
Using point import is discouraged if I remember well, but I have to check and now I'm not near a computer.

Edit, a note at end of :
Package Relative Imports

in Python documentation could explain why in some cases it will not work if applicable. There are even reference for some PEP so maybe here there is the advice


Kind Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
drmacro
Veteran
Posts: 8867
Joined: Sun Mar 02, 2014 4:35 pm

Re: Missing BSplineCurve in 0.21

Post by drmacro »

Syres wrote: Wed Mar 29, 2023 5:56 pm
drmacro wrote: Wed Mar 29, 2023 5:40 pm Apparently the code worked prior to 0.21
I believe your original code worked until quite/very recently!!
Actually not my code. Debugging failure in another app where FC modules are being used.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Post Reply