changing dropdown box default parameters

Well, it’s been a while since I’ve done anything related to Blender, but I’ve been trying to get into it again. I’ve been using Blender for CAD type stuff, actually, and I’ve been relying on the BlenderCaliper script for dimension lines and measuring and stuff
( http://www.macouno.com/2010/03/17/caliper/ )

Anyway, every time I reopen a blender file that uses this script, it resets all its parameters and I have to go re-enter them, and it’s annoying. I want to make some things show up as the default.

BUT I don’t know anything about Python. I’ve looked, and the dropdown menus are all defined like this:
types = “Measurement output type %t|Millimeters %x1|Centimeters %x2|Meters %x3|Kilometers %x4|Inches %x5|Feet %x6|Yards %x7|Miles %x8|Blender Units %x9”

and %x1 is always the default selection, but if I change %x1 to my preferred inches (I know, I know) it still thinks millimeters are selected, and reacts accordingly.

Is there a quick way to change the default dropdown parameters to be a specific number?

I think those numbers are just the index in the enum or something like that.

Defaults get created (or not as is mostly the case currently) in the C code and since almost all of them are missing the default, err… defaults to the lowest value possible.

…unless you’re talking about 2.4x then I have no idea how that works.

YES, you can!

In 2.4x (but I believe, it works for 2.5x too), you should define a global variable called - say - menu_item, such as:

menu_item = 5  # this is in the beginning of main program (script)

Then in draw() method which is registered by a proc like Register(draw,event,bevent), you should say that it uses menu_item as a global var:

global menu_item

Use the same in event and bevent registered procs that are to deal with events of your interface an button clicks --> use it as soon as you’re planning to change it in any of these procs.

Then, in draw(), you need to “read” or maintain the value of menu_item var by assigning it to the menu like this:

menu_item = "Measurement output type %t|Millimeters %x1|Centimeters %x2|Meters  %x3|Kilometers %x4|Inches %x5|Feet %x6|Yards %x7|Miles %x8|Blender Units  %x9"

and covert it properly to an integer so that your menu reflects the changed menu item.

Soooo… in the above example, you will have the item with internal code 5 as a “default” value of your menu, i.e. inches option pre-selected at starting the script. :wink:

Regards,