8 posts / 0 new
Last post
ForumImport
Offline
Last seen: 9 years 5 months ago
Joined: 09/22/2009 - 18:47
mug design tutorial

Trying to familiarize myself with K-3D; the kd3script tutorial mentioned in the wiki is unavailable:
http://www.k-3d.org/wiki/Mug_Tutorial
Bad link:
https://sourceforge.net/tracker/index.php?func=detail&aid=1730410&group_...

ForumImport
Offline
Last seen: 9 years 5 months ago
Joined: 09/22/2009 - 18:47
mug design tutorial

I fixed the wiki, that was out of date.
The last big push was all code development so the wiki is a bit out of date, thanks for helping to find the 'bit rot'.
This seem a bit quiet at the moment, hopefully Tim or Bart will have time to help you with your technical requests. I think that what you want is doable right now to one degree or another but Tim will need to confirm that.

ForumImport
Offline
Last seen: 9 years 5 months ago
Joined: 09/22/2009 - 18:47
mug design tutorial

Thanks for your help!
I've found another puzzler on the wiki:
http://www.k-3d.org/wiki/Scripting#.22Action.22_Scripts
This code of course complains that Document is undefined. After looking through the create_polyhedron scripts, I think the procedure should be:

access the context

create a node

create a mesh

connect the cone to the node

create a cone instance

connect the cone to the cone instance

place in the scene

Correct?
So, two questions:

Is the context object documented somewhere? I didn't see it in the API docs

How does one access/modify/create the cone parameters, such as height, radius, etc.?

ForumImport
Offline
Last seen: 9 years 5 months ago
Joined: 09/22/2009 - 18:47
mug design tutorial

Yes, that example is both out-of-date, and unrealistically simple ... I've updated it (and several others on the same page).
The contents of the "context" object vary, based on - well - context. So the context when a script is being run as an action script is different than when it is run by MeshSourceScript, etc.
We probably haven't always been consistent about documenting this, pointers always welcome.
Cheers,
Tim

ForumImport
Offline
Last seen: 9 years 5 months ago
Joined: 09/22/2009 - 18:47
mug design tutorial

Forgot to mention - all of the properties listed for a Node in its documentation are accessible directly as properties of the Python object, so
cone.height = 5
cone.radius = 0.5
etc.
Cheers,
Tim

ForumImport
Offline
Last seen: 9 years 5 months ago
Joined: 09/22/2009 - 18:47
mug design tutorial

Hi Timothy,
Thank you very much for replying, and linking to the universal storage pdf. It's very interesting and opened my eyes to K-3D's possibilities.
I've been through the storage pdf & the wiki information on Visualization Pipelines a few times, and I feel I have a basic grasp of the concepts. However, I'm unclear on execution: how to actually manipulate the pipeline or create primitives in Python code.
Thank you for the updated cone creation example. Would you mind commenting each line, describing what it does, and why it's needed?
For example, I've run the cone script in K-3D's Scripting Editor, and it works, creating a cone & instance in the viewport. However, despite reading the API docs on node.show(), I don't understand what the last line really does nor why it's needed. When I comment out this line in the script, the result in K-3D seems the same.
The colored cubes matrix in the pdf looks cool, but uses the older object creation syntax. I entered this script into K-3D's Scripting Editor to try out updating it, but K-3D's Scripting Editor just returns a terse "Error executing script" popup, which is not great for debugging.
Hoping for debugging feedback, I tried the cone example's updated plugin creation code in K-3D's Python shell, but this fails as well: I'm assuming because k3d.plugin.create() requires a specific context argument, such as context.document, which K-3D's Python Shell doesn't have:
>>> context.keys()
['__close', '__incomplete']

>>> context.values()
[False, False]
I don't know how to proceed, as the context object has no docstring and is not listed in the API documentation.
So, I feel stuck. I've read the available documentation, but still feel lost without concrete step-by-step examples.
Ultimately, I would like to accomplish the goal stated in the conclusion of your universal storage pdf, namely: as a third party, use Python to create a primitive with custom creation and validation code.
What do you think of a tutorial on using Python to write a "clone" of the cone primitive, from the ground up? I feel such a guide would go a long way to introducing a newcomer to programming with K-3D.

ForumImport
Offline
Last seen: 9 years 5 months ago
Joined: 09/22/2009 - 18:47
mug design tutorial

Where to begin ...
While fixing the autocompletion issue, I noticed that context.document wasn't being set in the interactive shell. That was a regression, and it's fixed in the repo too. I also updated the documentation for k3d.node.show() and k3d.node.hide(), which contained copy-n-paste error. A recent addition to K-3D is per-render-engine visibility for nodes. You have to call k3d.node.show() to explicitly turn-on visibility for every render engine in the document. The OpenGL preview engine hasn't been switched over to the new system, but your node won't be visible in RenderMan, LuxRender, or Yafray unless you call show().
I am adding some information on the context object to the K-3D guide now. In the meantime, the context object is just a mapping object - its contents vary based on how a script is being used. When you run a script from the command line, there's very little context - not even an open document. When you run a script from Scripting > Play, Scripting > Editor, or Scripting > Shell, the context includes the document and that's it. When you use a script with a scripted node - as is the case with custom primitive - there's lots of context: the node that's using the script, the node's inputs, it's outputs, etc.
Cheers,
Tim

ForumImport
Offline
Last seen: 9 years 5 months ago
Joined: 09/22/2009 - 18:47
mug design tutorial

Hi Timothy,
Thanks for this info, and the updated docs. It is extremely helpful!

Log in or register to post comments