setValue and setProperty?

hi there

i´ve had no luck browsing the docs (all the reference material) and forum archive so here goes,

i have a script that reads a string form outside blender (reads the Open Sound Control protocol),
i am trying to figure out how to assign an int i get from the string to a property in blender but am new to python/coding and am having trouble.

i have tried some variations (to set the property ´prop´ to 1 as a test) of:

import GameLogic

GameLogic.setProperty(int* prop)
GameLogic.setValue(int* 1)

when i try this i get an attribute error for setProperty (or setValue if i delete that line)

any advice - i´m sure itś pretty simple for someone who knows what theyŕe doing :wink:

Interesting, i’ve thought of using OSC too (am otherwise a bit of a supercollider hangaroundist). Do you read it from a socket and/or how? I’ve just made a remote controllable Blender engine using a simple non-protocol (just sending out commands as strings) but might be better off using something like OSC in the future.

The code you posted was quite nonsense :slight_smile:

What do you want to do? Set a property of some Blender object to some value, or just assign the value to some python variable/object? In Python it is simply (given you have the i already, as you say):

a=i 

That creates a new object ‘a’ with the value from ‘i’, which is int so a becomes int too – Python is not statically typed like C or Java so you never specify the types, it just figures them out itself.

Normally in Python that’s all you need, but to make things persistent in GameBlender people seem to use the GameLogic module itself as a kind of a container (a new Register module might come for this in future versions). So that way it’d be:

import GameLogic

GameLogic.a=i

I don’t do that myself, but have all my code running in external modules where it seems to work like normally with Python…

And finally, if you want put that value to a property of some Blender/gameobject, i.e. something created in Blender that may be a visible object in the game and can have property driven IPOs etc., you first need to get the reference to that object and can then set the property similarly.

https://blenderartists.org/forum/viewtopic.php?t=3245&highlight= introduces a nice way of dealing with gameobjects in Python, but I’ll paste the particular part here as well:

import GameLogic 

controller = GameLogic.getCurrentController()
owner = controller.getOwner()

owner.a=i

I actually don’t know what setProperty and setValue are for, 'cause you can set them directly/normally like this?-o Then again, this is still quite new for me too…

~Toni

hi toni

thanks for the response

sorry for the nonsense code :smiley:
i copied it pretty closely from the game engine reference pdf (python commands for property logic bricks) but am a newb to python. I have simplified a python script from the proctologic project that reads a string from an osc port.

http://galatea.stetson.edu/~ProctoLogic/

i just want to assign an int from it to a property in blender so that i can have a property sensor logic brick triggering events in blender (willl having a patch in Pure Data sending the osc info).

thanks a lot for the advice, will have a chance to suss it out this weekend. will also put the scripts/blends i’m working with up on the web if you’re interested. it’s all part of a uni assignment on open source/art so i hope it gets some use!

cheers

Rene.

do put them up :slight_smile:

i’m especially interested to see if you need threading to be able to use sockets, hopefully not (i’m using them myself based on some examples but hoping to get rid off)

oh and for what you need that latest code example should do it, ‘owner’ being the object and ‘a’ the property.

~Toni

hi again

just put the scripts up on the web

http://renechristen.net/temp.html

blends will follow later when i have some more work done on them (the blends will be open too)

will hopefully get a chance to try the advice you suggested soon (have a paper to finish writing in the meantime :frowning: )

enjoy! hope it’s useful! :slight_smile:

Have you actually ran this from Blender already? With Blender doing something, too? I’m afraid it either blocks all Blender action out or does nothing, but hopefully am wrong…

hi antont - sorry this reply is so late

it runs from command line but last time i tried to run it in blender i had issues with modules because i hadn’t set my python path correctly. will have time for another try next week

you tried it with the python path set correctly though i take it? that sucks if it won’t work, did it state any errors or did the engine just stop?

will suss it out next week and post the results

cheers.

sorry to open this thread again

just remembered that i said i’d look into it and never got around to it

i won’t get a chance to look at getting osc running in blender until another project is out of the way - although I will definately do it eventually :slight_smile:

in the meantime just thought i’d post this link to an osc dev mail list archive

http://www.create.ucsb.edu/pipermail/osc_dev.mbox/osc_dev.mbox

the guys at the proctologic project mention that they did play around with blender, here is a link to a file where it seems they did some blender stuff:

http://galatea.stetson.edu/cgi-bin/viewcvs.cgi/ProctoLogic/demo/playControl.py

will get onto their mail list when i get a chance and ask about it (should have done that ages ago!)

later.

no need to be sorry from my part at least :slight_smile:

thanks for the link, seemed interesting - i actually just last week sketched some ideas about using one other opengl-engine to visualize osc controls, kind of forgot about Blender then, but might try out that work sometime

~Toni

what other opengl engine are you playing with?