Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
H3D.org Feeds


Browsing this Thread:   1 Anonymous Users






invalid return value from update()
#1
Not too shy to talk
Not too shy to talk


See User information
I'm trying to make a standard text appear in the scene when the left mousebutton is pressed. However, I am having trouble with routing. This is my X3D code so far:

<X3D
    <
Scene
        <
Viewpoint DEF="VP" position="0 0 .6"/> 
        <
PythonScript DEF="PS" url="test.py"/> 
        
        <
Shape
            <
Text DEF="TXT" string="initial message"
                <
FontStyle justify='MIDDLE' size='0.02' /> 
            </
Text
        </
Shape
    
        <
MouseSensor DEF="MS"/> 
   
        <
ROUTE fromNode="MS" fromField="leftButton" toNode="PS" toField="showText"/> 
        <
ROUTE fromNode="PS" fromField="showText" toNode="TXT" toField="string"/> 
    </
Scene
</
X3D>


And the Python code:

from H3DInterface import 

class 
ShowText(TypedField(MFStringSFBool)): 
    
def __init__(self): 
        
MFString.__init__(self
        
self.inactive_txt 'Press left mousebutton' 
        
self.active_txt 'Hello World!' 
    
def update(selfevent): 
        if 
event.getValue() == 1
            return 
self.active_txt 
        
else: 
            return 
self.inactive_txt 

showText 
ShowText()


This is the warning I got, but could not resolve, because (as far as I know), the string field in the text node is an MFString, and I'm returning an MFString:

Warning: invalid return value from update()-function for Python defined field of type PythonScript_000000000722E320.ShowText



Posted on: 2018/4/18 9:27
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong Top


Re: invalid return value from update()
#2
Webmaster
Webmaster


See User information
From the python point of view the MFString type of a field contains a list of strings.
So you need to return

["yourstring"]

that is, including the brackets.

[EDIT] I put in a task in our internal system to make the error message better.
So some time in the future

Posted on: 2018/4/18 10:12
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong Top


Re: invalid return value from update()
#3
Not too shy to talk
Not too shy to talk


See User information
Solved. Thank you!

Posted on: 2018/4/18 10:33
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