moving nurbs


(DAK) #1

If I have a nurbs object is there a simple way I can just change the position of it when I have it selected?


(DAK) #2

I finaly found out the problem and got it to work with a nurbs. Now it seems I have a different problem. I can get many buttons to display and work, but when I try and get the value from a slider button, I get an error. What is the proper way to print the value from a Slider button when touched?


(Schlops) #3
print sli.val

if sli is your Sliderbutton. Please post the error-message next time, so it is easier to determine your error.


(DAK) #4

Yes, that fixed it. Thank you!


(DAK) #5

Yes, it works. But this message board seems to keep getting rid of my posts!! :frowning: :frowning: :frowning:
The only other problem now, is that the toggle buttons dont change their state when I click them. I am using 7 arguements instead of the 6 in my tutorial becuase the compiler is asking for 7. I also found out that adding a 1 or 0 at the end changes the state. But why does it not change when I click on it? And how do I determine the state after?


(Schlops) #6

First of all, create your Togglebutton (usually as a global variable):

tb = Create(1)

This togglebutton is initally true(pressed), use Create(0) otherwise.
In your gui-function you draw the togglebutton. The trick is to assign the button to itself:

tb = Toggle("Toggle"   , 1, 10,  10, 100, 25, tb.val)

You determine the state with tb.val.
To get an explanation for all the Togglebutton-arguments execute the following script inside blender:

import Blender
 
print Blender.Draw.Toggle.__doc__


(DAK) #7

I must have bad version of python as these dont work. I will re-install tonight and try again.


(DAK) #8

I have played a bit. I finaly got the documenation to print out. And some things working, but when I use tb.val in the togglebutton I get this:

UnboundLocalError: Local variable ‘tb’ referenced before assignment. But if I try to print tb.val, it works. Strange.


(Schlops) #9

Ah, that’s an easy one :smiley:
Put the following line in your gui-function:

global tb

(DAK) #10

Thankyou Shlops! Thanks to you I have got these buttons working. Now, I have another problem though lol, I can do anything with my active object, but I want to do the same to all selected objects at once. Do I have to send them to a kind of buffer and then make objects of all the items in a kind of loop?


(Schlops) #11

Hey DAK, here is your personal python trainer again! :wink:
theeth has anwsered this before: http://www.elysiun.com/board/viewtopic.php?t=1118
And map and/or apply might be your friends, see the python-documentation over at http://web.pydoc.org/. Otherwise use a loop