little ObjectSelector script

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
buschhardt
Posts: 0
Joined: Fri Jan 21, 2005 4:14 pm
Location: Cairo
Contact:

little ObjectSelector script

Post by buschhardt »

Sorry I dont find no function in Blender to select objects by type or by name. Is there are an function?

Have fun :)
Here is my script for that

Code: Select all

#!BPY

""" Registrationsinformationen fuer Blender-Menues
Name: 'ObjectSelector'
Blender: 235
Group: 'Misc'
Tip: 'Select Objects or Groups by name'
"""

__author__ = "Thomas Buschhardt"
__url__ = ["Script Site,www.buschhardt.de/objectselect"]
__version__ = "0.1 20050317"
__email__ = ["Thomas Buschhardt, thomas:buschhardt*de"]

__bpydoc__ = """\
This script implements selecting of object(s) by objectname or typename in Blender.
"""
import Blender

dicTypen={}
lstTypen=[]
allObj=[]
for i in Blender.Scene.getCurrent().getChildren():
	allObj.append(i.getName())
	if dicTypen.has_key(i.getType()):
		a=dicTypen[i.getType()]
		a.append(i.getName())
		a.sort()
		a.reverse()
		dicTypen[i.getType()]=a
	else:
		dicTypen[i.getType()]=[i.getName()]
lstTypen=dicTypen.keys()
lstTypen.sort()
lstTypen.reverse()
menu=Blender.Draw.Create(0)

def selectone(name):
	for i in Blender.Scene.getCurrent().getChildren():
		if i.getName()==name:
			i.select(1)
		else:
			i.select(0)

def selectgroup(name):
	for i in Blender.Scene.getCurrent().getChildren():
		if i.getType()==name:
			i.select(1)
		else:
			i.select(0)

def gui():
	global menu

	Blender.BGL.glColor3f(1,1,1)
	Blender.BGL.glRasterPos2i(10,40)
	Blender.Draw.Text("ObjectSelector 0.1 (by Thomas Buschhardt)")
	
	name = "ObjectSelector%t"
	for i in range(len(lstTypen)):
		for j in range(len(dicTypen[lstTypen[i]])):
			#objectnames
			name+="|"+dicTypen[lstTypen[i]][j]+" %x"+str(allObj.index(dicTypen[lstTypen[i]][j]))
		#groupnames
		name+="|=>"+lstTypen[i]+"    (select all)%x"+str(-i-1)
		
		##some bug is here
		if i<len(lstTypen)-1:name+="|%l"
	menu = Blender.Draw.Menu(name,2,10,10,400,20,menu.val,"selection menu.")

def button_event(evt):
	global menu
	if menu.val>=0:
		selectone(allObj[menu.val])
	else:
		selectgroup(lstTypen[abs(menu.val+1)])

def event(evt, val):
	if evt == Blender.Draw.ESCKEY:
		Blender.Draw.Exit()
		return
	Blender.Draw.Redraw(1)

Blender.Draw.Register(gui,event,button_event)

paleajed
Posts: 0
Joined: Fri Feb 11, 2005 1:19 pm

Post by paleajed »

Code: Select all

obj = Blender.Object.Get("i am the name of the object")
# select object
obj.sel = 1
# deselect object
obj.sel = 0
________________________________
Don't feed your ego, feed the duckies...

buschhardt
Posts: 0
Joined: Fri Jan 21, 2005 4:14 pm
Location: Cairo
Contact:

Post by buschhardt »

Hi paleajed,

I know how to select and deselect a known object :), but i looking for a list like in 3dmax.

In 3dmax you can also make selection-lists (also from objects that are not join)

i think Blender should be better userfriendly (gui) for more users (not only beginners)

Bye Thomas

iaminnocent
Posts: 0
Joined: Tue Jun 08, 2004 4:06 am

Re: little ObjectSelector script

Post by iaminnocent »

buschhardt wrote:Sorry I dont find no function in Blender to select objects by type or by name. Is there are an function?
Menu Select in the 3D > Select all by types...
For selection by names just use the Ouliner (shortcut shift-F9)

Before saying that Blender is not user-friendly, why no wait a bit, just to know it better ?

Anyways, your script is fun :).

Also, the next version will offer a mature version of the interface and some good (hopefully) tutorials will then come to ease off that oh so frightening learning curve.

Jean

buschhardt
Posts: 0
Joined: Fri Jan 21, 2005 4:14 pm
Location: Cairo
Contact:

Post by buschhardt »

Im so sorry :D about my script and I waste it officially with this message.

But (yes but :lol: )

You'r so right about the learning curve. I looking hours through the internet to find some little pieces of information :!: - what I found is for example looking like the old homepage for blender (blender.nl), where of course all links are dead.
Find something for the Gameengine (for example "the bitmap font and its creation") is terrible - I think the documentation should much more improoved (with examples). By the way I think that I write also in the future a tutorial for "Answered Question you are waste many times in the internet" - but I'm a novice and not a expert. :wink:

Bye

iaminnocent
Posts: 0
Joined: Tue Jun 08, 2004 4:06 am

Post by iaminnocent »

buschhardt wrote:- but I'm a novice and not a expert. :wink:
Bye
And that's just fine with me.
As I said, your script was fun and for me instructive since I am teaching myself programming and python. So I'm a beginner of sorts too. 8)

Now, don't go beat yourself on the head ( and more importantly ;) don't beat *me* on the head) : have you tried the 'Help' menu inside Blender ? It leads to a Learnng path, the official doc (1000+ printed pages), the Python API, user's forums (here you are on the developpers forums, but don't worry, I am no dev myself)...

Good luck and have fun.

Jean

joeri
Posts: 96
Joined: Fri Jan 10, 2003 6:41 pm
Contact:

Post by joeri »

It's pretty much agreed on by everybody that blender gui could be more (begin) user friendly. There is alot of effort put in that right now.

The basic (dashboard) structure is almost 10 years old and was maintained by only a few men (mostly Ton alone). It was 'invented' when dos still had green characters on black screens, and for a long time there was more need for new features than for a better interface; this ofcourse all changed when blender became public.

Making comparison to other 3d apps is a bit lame to me, it took me about 2 years to master Maya after using blender for 7 years. No 3d app has an easy learning curve (IMO) , if you think some 3d does I'd say to reveice your view on your work (Then again; I'd say that anyway :) ).

Organizing learning information is though too, not only because of the ever (fast) changing features and looks of blender. But also because of the different paces and skills of the users. In my view too many help on the websites and forums assume the user is also an internet guru.

But,... I think blender and the BF do a good job (specialy with the little money resources they have, luckaly they have got good human resources). The sites need a good makeover, but as I understand that's in the making. And so is the main user website.

Happy blending!

buschhardt
Posts: 0
Joined: Fri Jan 21, 2005 4:14 pm
Location: Cairo
Contact:

Post by buschhardt »

Please dont misunderstand me. I work long time with 3DStudio R4 later Max 2.0-> 4.0 and I know that this applications are expensive (my boss payed :wink: ) in the oposite its Blender my favorite 3D App - and I love it really.

My critism was, that some informations are really hard to find (maybe especially for non-english speakers) like information about the GameEngine.

In the first time I was wondering about 3 Internetpages that asociated with Blender (www.blender3d.org, www.blender.org and elysium). The forum is on two sites (www.blender3d.org and elysium), also the resources of tuturials, scripts and ... ect. I think this is really for a first time user a lot confusion.

I admire the men behind Blender!

stiv
Posts: 0
Joined: Tue Aug 05, 2003 7:58 am
Location: 45N 86W

Post by stiv »

Minor points:

Both the user and developer forums are now listed in the navigation bar on blender.org.

You can get a list of objects by type using list comprehensions. For example:
[ x for x in Object.Get() if x.getType() == 'Mesh' ]

I *like* green text on a black background.

Leafw
Posts: 0
Joined: Sun Apr 18, 2004 10:53 pm

Post by Leafw »

A note on the "user unfriendliness" of the Blender GUI:

After about a year of doing little things here and there with Blender, never full time, I have a good grasp of it. I've been doing the same with Maya and still can't figure out how to place objects properly.

The Blender GUI is way easier than it looks. Or better, it helps you rather than getting in your way to accomplish the current task.

That all other apps GUI such as Maya's are overloaded with buttons and menus one doesn't need that moment doesn't mean they are "user friendly". They may be easier to get started with, as everything is within sight for the novice, but it all gets on your way for actually doing work.

I like the Blender GUI because it is minimal and helps you focus on what you're doing that very moment, not on what you could possibly do later on. Whoever is in charge please don't get rid of this concept. No other 3D app has it AND it is something practical and to be proud of.

Albert Cardona

ideasman
Posts: 0
Joined: Tue Feb 25, 2003 2:37 pm

Post by ideasman »

Just to be more on topic. the selector script is okay.
But theres some stuff missing.

- Menu dosent update after objects have been added, removed.
-
BTW
Whats wrong with shift+F4?

- Cam

Post Reply