4 posts / 0 new
Last post
ForumImport
Offline
Last seen: 9 years 11 months ago
Joined: 09/22/2009 - 18:47
Application Plugins in Python

This message was originally posted by Kenton McHenry on 10/20/2008 13:19:41
I have the following python script which converts a file \"tmp.obj\" to \"tmp.k3d\":
#python
import k3d
doc = k3d.application.new_document();
source = doc.new_node(\"OBJMeshInput\");
source.file = \"tmp.obj\";
target = doc.new_node(\"K3DMeshOutput\");
target.file = \"tmp.k3d\";
doc.set_dependency(target.get_property(\"input_mesh\"), source.get_property(\"output_mesh\"));
This script uses the two \"document plugins\", OBJMeshInput and K3DMeshOutput to perform the conversion.
I notice there are other format import/export plugins:
GTSReader
GTSWriter
RAWReader
RAWWriter
RIBReader
MFXReader
OFFReader
These are however identified as \"Application plugins\" as opposed to \"Document plugins\".
From the documentation it seems that an application plugin is instantiated as follows:
source = k3d.create_plugin(\"RAWReader\");
This doesn’t crash the script so I assume it works. My problem is that from here I do not
know how to use this plugin to actually load the file. I can’t seem to find any documentation
on these plugins. I have tried something like this:
source.file = \"tmp.raw\"
but file is not a valid member of RAWReader. Any help or pointers to documentation would be appreciated.

ForumImport
Offline
Last seen: 9 years 11 months ago
Joined: 09/22/2009 - 18:47
Application Plugins in Python

This message was originally posted by joa on 10/20/2008 19:44:41
Hi Kenton!
Which version of K-3D are you using? Which platform?
Here is an example on K-3D 0.7
#python
import k3d
obj_mesh_writer = Document.new_node(\"OBJMeshWriter\")
cube = Document.new_node(\"PolyCube\")
Document.set_dependency(obj_mesh_writer.get_property(\"input_mesh\"), cube.get_property(\"output_mesh\"))
obj_mesh_writer.file = k3d.generic_path(\"/home/user/output.obj\")
Cheers!
Joaquín

ForumImport
Offline
Last seen: 9 years 11 months ago
Joined: 09/22/2009 - 18:47
Application Plugins in Python

This message was originally posted by joa on 10/20/2008 19:45:32
By the way, you should check this site for support
http://www.k-3d.com/docs/epydoc/
Cheers!
Joaquín

ForumImport
Offline
Last seen: 9 years 11 months ago
Joined: 09/22/2009 - 18:47
Application Plugins in Python

This message was originally posted by Kenton McHenry on 10/21/2008 10:31:34
Hi Joaquin,
I’m using 0.6.7 (stable). If possible could you put up an example which uses one of the \"application plugins\" such as RAWWriter?

Log in or register to post comments