Comments (11)
So it turns out that by registering the operator, it was already accessible from the Python scripting environment in Blender automatically. You could discover this by running:
>>> dir(bpy.ops.import_mesh)
['3mf', 'ply', 'stl']
However if you try to call it that way (bpy.ops.import_mesh.3mf(filepath="/path/to/file.3mf")
), Python gives a syntax error. This is because names in Python may not start with a number.
So I've changed the operator's ID to be import_mesh.threemf
. This avoids the problem. The import operator is now in bpy.ops.import_mesh.threemf
and the export operator in bpy.ops.export_mesh.threemf
.
I've documented how to call these operators from a scripting environment here: https://github.com/Ghostkeeper/Blender3mfFormat#scripting
from blender3mfformat.
I'm not really familiar with conventions within Blender in that regard.
From my point of view, the main entry point of importing 3MF is this function:
That function reads these three attributes of the class:
Blender3mfFormat/io_mesh_3mf/import_3mf.py
Lines 60 to 62 in 6f33fb7
This was taken from the examples of the STL import and PLY import scripts. Perhaps those import scripts have some helper functions that make it easier to use them from a script that I have overlooked. If so, such helper functions should be added to this Import/Export add-on as well.
from blender3mfformat.
Thanks, am not well versed with python, but I will try and see.
Cheers
from blender3mfformat.
@Ghostkeeper
i tried to do run similar to which stl gets import? like using import_scene.3mf, am getting
SyntaxError: invalid syntax
location: :-1
Thanks!
from blender3mfformat.
I've never implemented any method to make it work from the Python command line in Blender. I hadn't considered that until you mentioned it. So most likely it's not going to work (yet).
However the SyntaxError you're getting signifies that you made a mistake in the command you typed in. Possibly a typo, unmatched brackets, etc.
from blender3mfformat.
Awesome, Thanks Works!
from blender3mfformat.
Hi,
There still seems to be an error with the python integration.
Regardles of which version of Blender, I get the following error:
bpy.ops.import_mesh.threemf(filepath="F:\Nextcloud\Deventus\3mf-test\microvred.3mf")
Traceback (most recent call last):
File "<blender_console>", line 1, in
File "C:\Program Files\Blender Foundation\Blender 2.83\2.83\scripts\modules\bpy\ops.py", line 201, in call
ret = op_call(self.idname_py(), None, kw)
AttributeError: Calling operator "bpy.ops.import_mesh.threemf" error, could not be found
from blender3mfformat.
That there is Blender calling an operator that doesn't exist. This add-on registers itself and then waits to be called. Apparently Blender kind of semi-registered it with you, where it knows that it exists but then doesn't find the operator any more, and never calls the code in this add-on. So the add-on itself could never do anything about this error.
This could be the result of something like a syntax error upon registering, but then the rest of us would have the same issue (unless you edited these files yourself). More likely it is somehow not installed correctly.
from blender3mfformat.
Hi,
Late reply and all but here we are.
I have tried redownloading and installing again on different versions of Blender and on three different computers, but the result is the same.
I've made no changes to the source.
The following pops up when i type so it's defenetly loaded, i guess "threemf" is suposed to be there as well, rigth? Or should it replace "3mf"?
>>> dir(bpy.ops.import_mesh)
['3mf', 'ply', 'stl']
Regards
Simon
from blender3mfformat.
Never mind, I now changed the bl_idname to "import_mesh.threemf" and with that it works!
I assumed this whas already in the 1.0.1 release but apparently not.
from blender3mfformat.
If anyone having the issue again, it's because the commit f4319b3 seem not updated in release package here https://github.com/Ghostkeeper/Blender3mfFormat/releases/tag/v1.0.1 Manually replacing the file in plugin directory from here https://github.com/Ghostkeeper/Blender3mfFormat/tree/master/io_mesh_3mf will fix the issue.
from blender3mfformat.
Related Issues (20)
- SUPPOPRT STRUCTURES HOT 1
- Error while Export HOT 1
- Error import/export the 3mf file HOT 1
- Import and Export object dimensions and translations scaled by changes to Unit Scale.
- AttributeError: 'NoneType' object has no attribute 'name' when object has blank Material
- Does the importing of the 3MF files keep the color and texture information in 3MF files? HOT 2
- Does not work with Blender 3.5 HOT 5
- 3MF Consortium Support HOT 1
- Texture not included in export HOT 1
- 3.6 3MF Blender Compatibility Workaround HOT 4
- Install fix HOT 2
- Changing license from AGPL to GPL for inclusion in default Blender package HOT 8
- exported file empty HOT 3
- Blender 4 support? HOT 1
- python traceback trying to import file HOT 2
- Almost nothing can open the exported 3mf file HOT 1
- Enormous memory usage HOT 1
- Imported object scale isnt correct
- Crashes if object doesn't have a material
- Possible to include color data from Bambu Slicer / Printasbles 3mf? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blender3mfformat.