Remember me

Lost Password?

Register now!
Main Menu
H3D.org Feeds

Browsing this Thread:   1 Anonymous Users

RuntimeError: UnableToCreatePythonField: fieldAsPythonObject()
Not too shy to talk
Not too shy to talk

See User information
I am trying to work out the setValue() ' routing' approach, but this error keeps coming up.
Also, when I try updating the color of an object with self.dn["MAT"].diffuseColor.setValue(RGB(1,0,0)) for instance, the object does not change color.
I suspect that this error is the reason, but I can't figure out how to solve it. Here's the X3D:

Material DEF="MAT" diffuseColor="1 0 0"/> 

PythonScript DEF="PS" url="Trials.py"/>

And the Python:

from H3DInterface import *

def __init__(self):
self.nodeself.dn createX3DNodeFromURL("Trials.x3d")
self.new_color RGB(010)
def update(self):

def changeColor(self):


def traverseSG():

Posted on: 2018/5/10 11:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong Top

Re: RuntimeError: UnableToCreatePythonField: fieldAsPythonObject()

See User information
It looks like you are mixing concepts a bit.

traverseSG is using the update function of the class Trial which kind of looks like an class that should inherit from the field types in H3DInterface and should be using the routing system.

Whichever system you are using ( traverseSG or the other setup with fields and routes) does not really matter but it was a bit confusing to me at first.

If this code is correct, then the first time traverseSG will be called the cylinder will change to the new color. Which color are you actually seeing when you start the program (maybe it changes so fast that you do not notice).

And finally, this really looks like some kind of recursive issue.
If your x3d file is called Trials.x3d then you can see that it includes the python script file Trials.py which then loads Trials.x3d which then loads Trials.py and I really do not know what to expect in this case (the module should only load once, but it is still quite weird).
You can either use the references field to give the node you are interested in to python or use getNamedNode() function in python.

Posted on: 2018/5/14 9:10
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong Top

You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create pdf.
You cannot get print page.

[Advanced Search]

(C) 2012 SenseGraphics AB    ---    Powered by XOOPS