Hi, I would play with Freecad and Blender 2,79.
I downloaded blender-2.79.0-git.53527ac10f2-windows64.
https://builder.blender.org/download/
I downloaded blender importer and I installed it from blender.
I set location of FreeCAD.pyd in the addon's preferences.
When I tried to import a Freecad file nothing happened.
Where am I wrong?
Thank you !
From Yorik guestbook:
“ You can already use the importer, it is pretty stable already, but you'll need to get your hands on (or compile yourself) a version of FreeCAD
compiled with the same Python version you use in Blender. The minor version number must match too, so if for example Blender uses 3.6.1, FreeCAD must use also 3.6 (the third digit can be different) ”
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.14315 (Git)
Build type: Release
Branch: master
Hash: 5f8f26824486b55b2bf72c579e95f0f6d4a19284
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: Italian/Italy (it_IT)
Where am I wrong with Yorik’s Addon “Blender Importer” ?
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
- markko martin
- Posts: 64
- Joined: Tue Aug 09, 2016 5:51 pm
- Location: Italy
Where am I wrong with Yorik’s Addon “Blender Importer” ?
- Attachments
-
- Blender 2.79 daily build.jpg (131.71 KiB) Viewed 2579 times
Loris
Re: Where am I wrong with Yorik’s Addon “Blender Importer” ?
Hi,
Things to try:
- in Blender's python console: import FreeCAD
- If no error message appears, everything is fine and FreeCAD is correctly detected by Blender.
- If so, and you don't have the FreeCAD option in File->Import menu, then FreeCAD is correctly installed but the Blender addon is not. MAke sure your addon (the .py file downloaded from gist is at a correct location and has been enabled in Blender's addon preferences
- If "import FreeCAD" gives an error, then either the FreeCAD.pyd file is not found by Blender, or it is a wrong python version. In the addon settings, it allows you to specify a path to FreeCAD.pyd. But that will only work for the addon, not in the blender py console. To reproduce that in the console, for testing, you can do this:
(replace C:\path\to\your\FreeCAD.pyd with your actual path, of course).
Things to try:
- in Blender's python console: import FreeCAD
- If no error message appears, everything is fine and FreeCAD is correctly detected by Blender.
- If so, and you don't have the FreeCAD option in File->Import menu, then FreeCAD is correctly installed but the Blender addon is not. MAke sure your addon (the .py file downloaded from gist is at a correct location and has been enabled in Blender's addon preferences
- If "import FreeCAD" gives an error, then either the FreeCAD.pyd file is not found by Blender, or it is a wrong python version. In the addon settings, it allows you to specify a path to FreeCAD.pyd. But that will only work for the addon, not in the blender py console. To reproduce that in the console, for testing, you can do this:
Code: Select all
import sys
sys.path.append("C:\path\to\your\FreeCAD.pyd")
import FreeCAD
- markko martin
- Posts: 64
- Joined: Tue Aug 09, 2016 5:51 pm
- Location: Italy
Re: Where am I wrong with Yorik’s Addon “Blender Importer” ?
I have the FreeCAD option in File->Import menu.
"import FreeCAD" doesn't give any error.
But Blender gives this error:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_import_fcstd.py", line 476, in execute
sharemats=self.option_sharemats)
File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_import_fcstd.py", line 398, in import_fcstd
diffshader.inputs['Color'].default_value = rgba
AttributeError: 'NoneType' object has no attribute 'inputs'
location: <unknown location>:-1
My freecad file contains 2 walls without materials.
"import FreeCAD" doesn't give any error.
But Blender gives this error:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_import_fcstd.py", line 476, in execute
sharemats=self.option_sharemats)
File "C:\Users\USER\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\io_import_fcstd.py", line 398, in import_fcstd
diffshader.inputs['Color'].default_value = rgba
AttributeError: 'NoneType' object has no attribute 'inputs'
location: <unknown location>:-1
My freecad file contains 2 walls without materials.
Loris
Re: Where am I wrong with Yorik’s Addon “Blender Importer” ?
Okay, that's much clearer. Everything works, but there is a bug in the importer code.
But it's strange, on my Blender version here, a cycles diffuse shader is automatically created for new materials, apparently in your case not (blender materials are created from freecad object color). I now updated the code on github, you won't have automatic cycles materials, but at least you won't get this error anymore. Later on I'll add some more code to create the needed cycles nodes if they are not present.
But it's strange, on my Blender version here, a cycles diffuse shader is automatically created for new materials, apparently in your case not (blender materials are created from freecad object color). I now updated the code on github, you won't have automatic cycles materials, but at least you won't get this error anymore. Later on I'll add some more code to create the needed cycles nodes if they are not present.
- markko martin
- Posts: 64
- Joined: Tue Aug 09, 2016 5:51 pm
- Location: Italy
Re: Where am I wrong with Yorik’s Addon “Blender Importer” ?
Ok I found the problem! (with the old code of the addon)
If Blender Render is set, Blender gives error.
The right steps are:
- Open Blender.
- Set Cycles as renderer.
- File - Import - FreeCAD file.
With this procedure all is working and blender automatically creates new diffuse material.
Thank you Yorik!
I'm very happy
If Blender Render is set, Blender gives error.
The right steps are:
- Open Blender.
- Set Cycles as renderer.
- File - Import - FreeCAD file.
With this procedure all is working and blender automatically creates new diffuse material.
Thank you Yorik!
I'm very happy
Loris
Re: Where am I wrong with Yorik’s Addon “Blender Importer” ?
Glad you have it working! The mystery is solved, then, cycles materials are only created if you are in Cycles render mode... Good to know.
Re: Where am I wrong with Yorik’s Addon “Blender Importer” ?
Hi
I've encountered the same problem with Freecad-daily and Blender 2.8 (normal install for xubuntu 19.10).
Python console import FreeCAD clear
Render on Cycles
bpy.context.space_data.context = 'RENDER'
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.object.hide_viewport = True
bpy.data.window_managers["WinMan"].(null) = 1
bpy.ops.import_fcstd.import_freecad(directory="/home/gwen/", files=[{"name":"hsfg.FCStd", "name":"hsfg.FCStd"}], option_scale=1)
bpy.data.window_managers["WinMan"].(null) = False
The tree in blender show the Freecad import tag, but empty
But with a trial whitout skip hidden
bpy.ops.import_fcstd.import_freecad(directory="/home/gwen/", files=[{"name":"hsfg.FCStd", "name":"hsfg.FCStd"}], option_skiphidden=False)
It appears the sketch.
A second ask is , how can we choose the mesh size ? (this is why i test this method, .obj give a very huge amount of surfaces, which gives a large file (around 10 Mo for a not complex part) ?
Cheers and thx
I've encountered the same problem with Freecad-daily and Blender 2.8 (normal install for xubuntu 19.10).
Python console import FreeCAD clear
Render on Cycles
bpy.context.space_data.context = 'RENDER'
bpy.context.scene.render.engine = 'CYCLES'
bpy.context.object.hide_viewport = True
bpy.data.window_managers["WinMan"].(null) = 1
bpy.ops.import_fcstd.import_freecad(directory="/home/gwen/", files=[{"name":"hsfg.FCStd", "name":"hsfg.FCStd"}], option_scale=1)
bpy.data.window_managers["WinMan"].(null) = False
The tree in blender show the Freecad import tag, but empty
But with a trial whitout skip hidden
bpy.ops.import_fcstd.import_freecad(directory="/home/gwen/", files=[{"name":"hsfg.FCStd", "name":"hsfg.FCStd"}], option_skiphidden=False)
It appears the sketch.
A second ask is , how can we choose the mesh size ? (this is why i test this method, .obj give a very huge amount of surfaces, which gives a large file (around 10 Mo for a not complex part) ?
Cheers and thx
AMD FX-6350 (6 core)
32 Go RAM
AMD RX 470 8 Go
Xubuntu 18.04 LTS
FreeCAD Daily (0.19)
32 Go RAM
AMD RX 470 8 Go
Xubuntu 18.04 LTS
FreeCAD Daily (0.19)