or at least i thought so..
you would need to rename the folder that is stored inside the zip...
now i have fixed the addon itself -
so it should work now!
(was issues/9)
and updated the readme.
sunny greetings
stefan
lol!! Worked perfectly, thank you very much!
Do you still have this problem? I think we can call realthunder to take a look at why the objects aren't created.
yes - i import with
Code: Select all
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
List Objects.
Stand-alone
"""
import sys
import os
path_to_freecad = "/usr/lib/freecad-daily-python3/lib/FreeCAD.so"
def append_freecad_path():
"""Append the FreeCAD path."""
global path_to_freecad
if os.path.exists(path_to_freecad):
if os.path.isfile(path_to_freecad):
path_to_freecad = os.path.dirname(path_to_freecad)
print("Configured FreeCAD path:", path_to_freecad)
if path_to_freecad not in sys.path:
sys.path.append(path_to_freecad)
else:
print("FreeCAD path is not correct.")
try:
try:
import FreeCAD
except ModuleNotFoundError:
append_freecad_path()
import FreeCAD # noqa
print("FreeCAD version:", FreeCAD.Version())
except ModuleNotFoundError as e:
print("FreeCAD import failed.", e)
# ******************************************
Yes, but since August last year, realthunder has been changing a lot of the core code. This could be solved by him in a matter of minutes if he identifies the problem.
I've been very lazy on this topic, which admitedly looks serious. However, your first test files and code seemed to me cumbersome. Too much information.i have some test files linked.
Code: Select all
import FreeCAD
print("FreeCAD version:", FreeCAD.Version())
objects = FreeCAD.ActiveDocument.Objects
print("doc.Objects", len(objects))
for o in objects:
print(o, o.Name)
Code: Select all
import sys
path_to_freecad = "/usr/lib/freecad-daily-python3/lib/"
sys.path.append(path_to_freecad)
import FreeCAD
print("FreeCAD version:", FreeCAD.Version())
doc = FreeCAD.open("./BodyTest_Minimal.FCStd")
docname = doc.Name
objects = FreeCAD.ActiveDocument.Objects
print("doc.Objects", len(objects))
for o in objects:
print(o, o.Name)
FreeCAD.closeDocument(docname)
Code: Select all
OS: Ubuntu 20.04.2 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.
Build type: Release
Branch: unknown
Hash: 9e3b630bbfb6807e93eeffb655e6c20f218644fc
Python version: 3.8.5
Qt version: 5.12.8
Coin version: 4.0.0
OCC version: 7.5.1
Locale: English/United States (en_US)
Code: Select all
>>> import FreeCAD
>>> print("FreeCAD version:", FreeCAD.Version())
FreeCAD version: ['0', '19', '', 'git://github.com/FreeCAD/FreeCAD.git unknown', '2021/03/01 00:28:00', 'unknown', '9e3b630bbfb6807e93eeffb655e6c20f218644fc']
>>>
>>> objects = FreeCAD.ActiveDocument.Objects
>>>
>>> print("doc.Objects", len(objects))
doc.Objects 10
>>>
>>> for o in objects:
... print(o, o.Name)
...
<body object> Body
<App::Origin object> Origin001
<GeoFeature object> X_Axis001
<GeoFeature object> Y_Axis001
<GeoFeature object> Z_Axis001
<GeoFeature object> XY_Plane001
<GeoFeature object> XZ_Plane001
<GeoFeature object> YZ_Plane001
<Sketcher::SketchObject> Sketch
<PartDesign::Pad> Pad
>>>
Code: Select all
Cstefan@stefan-Zen:~/mydata/github/blender/io_import_fcstd/dev/freecad_test_body_objects (master $)$ python3
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> path_to_freecad = "/usr/lib/freecad/lib/"
>>> sys.path.append(path_to_freecad)
>>>
>>> import FreeCAD
Sheet Metal workbench loaded
Loading Assembly4 WorkBench
Interlocking laser cut workbench loaded
>>> print("FreeCAD version:", FreeCAD.Version())
FreeCAD version: ['0', '19', '', 'git://github.com/FreeCAD/FreeCAD.git unknown', '2021/07/21 08:10:00', 'unknown', '0d9536ed3e8c7f40197b5606e1b7873625e1d6fe']
>>>
>>> doc = FreeCAD.open("./BodyTest_Minimal.FCStd")
>>> docname = doc.Name
>>> objects = FreeCAD.ActiveDocument.Objects
>>>
>>> print("doc.Objects", len(objects))
doc.Objects 8
>>>
>>> for o in objects:
... print(o, o.Name)
...
<App::Origin object> Origin001
<GeoFeature object> X_Axis001
<GeoFeature object> Y_Axis001
<GeoFeature object> Z_Axis001
<GeoFeature object> XY_Plane001
<GeoFeature object> XZ_Plane001
<GeoFeature object> YZ_Plane001
<Sketcher::SketchObject> Sketch
>>> FreeCAD.closeDocument(docname)
>>>
Code: Select all
import sys
import os
path = "/usr/lib/freecad/lib"
sys.path.append(path)
import FreeCAD
print("FreeCAD version:", FreeCAD.Version())
path_base = FreeCAD.getResourceDir()
path = os.path.join(path_base, "Mod")
sys.path.append(path)
doc = FreeCAD.open("./BodyTest_Minimal.FCStd")
docname = doc.Name
objects = FreeCAD.ActiveDocument.Objects
print("doc.Objects", len(objects))
for o in objects:
print(o, o.Name)
FreeCAD.closeDocument(docname)
Code: Select all
io_import_fcstd/dev/freecad_test_body_objects (master *$%)$ python3
Python 3.8.10 (default, Jun 2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import os
>>>
>>> path = "/usr/lib/freecad/lib"
>>> sys.path.append(path)
>>>
>>> import FreeCAD
Sheet Metal workbench loaded
Loading Assembly4 WorkBench
Interlocking laser cut workbench loaded
>>> print("FreeCAD version:", FreeCAD.Version())
FreeCAD version: ['0', '19', '', 'git://github.com/FreeCAD/FreeCAD.git unknown', '2021/07/21 08:10:00', 'unknown', '0d9536ed3e8c7f40197b5606e1b7873625e1d6fe']
>>>
>>> path_base = FreeCAD.getResourceDir()
>>> path = os.path.join(path_base, "Mod")
>>> sys.path.append(path)
>>>
>>> doc = FreeCAD.open("./BodyTest_Minimal.FCStd")
>>> docname = doc.Name
>>> objects = FreeCAD.ActiveDocument.Objects
>>>
>>> print("doc.Objects", len(objects))
doc.Objects 10
>>>
>>> for o in objects:
... print(o, o.Name)
...
<body object> Body
<App::Origin object> Origin001
<GeoFeature object> X_Axis001
<GeoFeature object> Y_Axis001
<GeoFeature object> Z_Axis001
<GeoFeature object> XY_Plane001
<GeoFeature object> XZ_Plane001
<GeoFeature object> YZ_Plane001
<Sketcher::SketchObject> Sketch
<PartDesign::Pad> Pad
>>> FreeCAD.closeDocument(docname)
>>>
>>>
Code: Select all
raceback (most recent call last):
File "/usr/share/blender/scripts/modules/addon_utils.py", line 331, in enable
mod = __import__(module_name)
File "/usr/share/blender/scripts/addons/io_import_fcstd/__init__.py", line 9, in <module>
from . import import_fcstd
File "/usr/share/blender/scripts/addons/io_import_fcstd/import_fcstd/__init__.py", line 18, in <module>
from .material import MaterialManager
File "/usr/share/blender/scripts/addons/io_import_fcstd/import_fcstd/material.py", line 7, in <module>
from bpy_extras.node_shader_utils import PrincipledBSDFWrapper
ModuleNotFoundError: No module named 'bpy_extras.node_shader_utils'
It's not the FreeCAD side that's the problem, it's your using Blender 2.79, you should be using the last official Python 3.7.x Blender build which is 2.92. @Yorik originally rewrote the importer code because to the best of my knowledge the registering of Addons changed too much between 2.79 and 2.80 that they weren't compatible, Is there something in 2.79 that you specifically need???