Toggling the "3D" button in python

Hello Everyone.

I have what I hope is a quick and easy question. I am writing a script that will read in a CSV file and create a curve in python. I am also toggling the .setFlagU(1) to make the curve cyclical. I am then wanting to apply a bevel object in order “thicken” my curve. But for some reason when I do this Blender eats up all my memory before it ever renders the output picture. I have a feeling this might be because Blender is attempting to apply the bevel object to a surface as opposed to the outline that the curve draws. I think my problem would be solved if I could (through python) set the “3D” button to be on. Is there any way to do this in Blender 2.49B?

Thanks
Bleiner

3D button? if you’re looking to get a visualization of what’s happening, try linking the objects to the scene and then redrawing the window.

sample code:

import blender

#gets scene and links objects
scn = Blender.Scene.GetCurrent()
scn.link(object)

#redraws windows
Blender.Window.RedrawAll()

That will redraw all 3D windows and should make your curve appear

Humm, well… I think the issue raised is not related to redrawing the 3D windows. Rather than that it is about how to control the buttons in the “Curve and Surfaces” panel… this panel appears ONLY if your selected object is a CURVE!!! Sooo… look at it and you will see the 3D button setting ON/OFF the 3D-property of the selected curve. Now… how to control via Python this setting? And the other properties, too (other buttons at this panel)??? The simple answer is by setting appropriate values for the flag. It is partially shown at the posting #1 above… More on that is at the following example:

from Blender import *

cu = Curve.Get("Curve")
flag_val = 11  # = 8+2+1
cu.setFlag(flag_val)
Window.RedrawAll()

The last command is to enable you see the changed state in the panel’s buttons. If your code (script) is relatively simple (as the above one) you may use RedrawAll() as above… But if your code is more dynamic and action related, you may wish to only redraw the panels’ area (i.e. w/o a complicated interface, for example, cause RedrawAll() really redraws ALL and it may cost you a lot of time at some cases). Redrawing issue is a subject for another thread though… All that’s been made in the example code above is to set ON curve properties as being “3D”, “Front” and “CurvePath”. Other curve properties are set OFF. For more info on different values, pls see the API here.

Regards,

Thanks Abidos!

I think that is the solutions to my problem. I also appreciate the link you attached as it will likely solve some of the other issues I am having. Thanks everyone for your help.

Bleiner