Closed ghost closed 3 years ago
Hi Gernhard,
At the moment, I don't think it's possible to call any Stop Motion OBJ functions from a script outside the addon itself. However, this a planned feature for the 2.2.0 release. Unfortunately, I can't give you any sort of estimate for when the feature might be completed.
i realised it would be also possible for me to call it from a script inside from blender. I literally just need to import with your tool and then safe the imported Animation.
I found that
bpy.ops.ms.import_sequence(filepath="", importSettings={"name":"", "obj_use_edges":True, "obj_use_smooth_groups":True, "obj_use_groups_as_vgroups":False, "obj_use_image_search":True, "obj_global_clight_size":0, "stl_global_scale":1, "stl_use_scene_unit":False, "stl_use_facet_normal":False, "axis_forward":"-Z", "axis_up":"Y"}, sequenceSettings={"name":"", "fileNamePrefix":"", "perFrameMaterial":False, "cacheMode":'cached', "fileFormat":'obj', "dirPathIsRelative":True}, filter_glob="*.stl;*.obj;*.mtl;*.ply", directory="", axis_forward='-Z', axis_up='Y')
is used by blender itself. Could you explain to me how i can call this function?
Normally i would open blender and then just run this script.
I somehow struggle with the input which is between the { }.
Can you give me a example how i can modify this
importSettings={"name":"", "obj_use_edges":True, "obj_use_smooth_groups":True, "obj_use_groups_as_vgroups":False, "obj_use_image_search":True, "obj_global_clight_size":0, "stl_global_scale":1, "stl_use_scene_unit":False, "stl_use_facet_normal":False, "axis_forward":"-Z", "axis_up":"Y"}
to use my data. I thought i had too give a list with my arguments but this is not working.
It would be awesome and totaly cover my problem since i run it with a shell-script
For example, i somehow thought this would work :
bpy.ops.ms.import_sequence(filepath="C:/Users/Tom/Desktop/obj", importSettings={"name":"frame"}, sequenceSettings={"name":"frame", "fileNamePrefix":"frame"}, directory="")
but yet it gives me this errror :
Traceback (most recent call last): File "<blender_console>", line 1, in <module> File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\modules\bpy\ops.py", line 132, in __call__ ret = _op_call(self.idname_py(), None, kw) TypeError: Converting py args to operator properties: MS_OT_import_sequence.importSettings expected a MeshImporter type, not dict
Yeah, I've not tried to call that function this way, but it's expecting you to fill out all of the member variables of the ImportSequence
operator/class, some of which are classes themselves, not just simple data types. I guess it might be possible to do, but you will probably have to study the code to figure out the structure of those classes. Specifically, you'd need to fill out at least the ImportSequence
class, the MeshImporter
class, and the SequenceImportSettings
class for this to work.
alright. I will try this and if i find a solution i will write here again. (since as far as i know your work is the only one with a stop-motion for .obj or .raw files? because otherwise i am forced to bring this to work ^^)
Well i tried and failed. Creating a Instance of MeshImporter was not successfull since i always get the error that the type is not a subtype of bpy.types despite i register the class. I dont know how to do this but if you find some time to make a tutorial on that i would be so grateful for that. Otherwise still thanks!
Hello there! @TomLorenz-WebApplications @neverhood311 Did you guys figure out how to call import_sequence
in python script? Thanks!
Found a (cursed) way to call it from Python:
# We need to set a filename prefix for the plugin, however it is a property
# on a custom PropertyGroup subclass. I couldn't find a way to pass an instance
# of this subclass directly (Blender is complaining that it wants an "ID type" instead,
# whatever that is). Instead, override the property with the default value set
# to what we need.
#
# First, get the subclass instance.
seq_imp_settings = bpy.types.PropertyGroup.bl_rna_get_subclass_py("SequenceImportSettings")
# Next, override the property. The definition is the same as
# https://github.com/neverhood311/Stop-motion-OBJ/blob/4fd8bff2570f6f1c76646ffa35f6912f6cb111b3/src/panels.py#L127
# but with default set to what we need.
seq_imp_settings.fileNamePrefix = bpy.props.StringProperty(name='File Name', default='0')
# Call the plugin.
bpy.ops.ms.import_sequence(directory=dir)
# Override the property with its original unset default, just in case.
seq_imp_settings.fileNamePrefix = bpy.props.StringProperty(name='File Name')
Hello,
i want too know how i can acces your project via python. I will simply need the import which is done manually in a "script-wise" way. Something like bpy.script.Stop-Motion-Obj("blenderfilename", "saveplaceofblend") where blenderfilename is the place too find the .obj with the prefix and saveplaceofblend is the place where the generated .blend is saved. How would i do this ? Thanks.