Previous Thread  Next Thread

chat icon How to skip non mesh objects?

shagwana

Posted: Mon Oct 21, 2002 8:37 pm
Joined: 16 Oct 2002
Posts: 12
Embarassed Well, im kind of new to this python coding lark so be kind!

Im currently trying to access all selected objects from a pyhton script, like so;

Code:

from Blender import *


print "Running..."

#Pull in the selected object information...
Selected_Objects=Object.GetSelected()
Number_Of_Selected_Objects=len(Selected_Objects)

#If the user has selected some objects, get to work ....
if Number_Of_Selected_Objects>0:
   #The user has selected something!
   for Working_Object in Selected_Objects:
      #Scan through each of the objects available, grab the object in question
      #If its a usable type ...
      if Working_Object.data==None:
         print "Axis"+str(Working_Object)
         #<<< problem!?! >>>
else:
   #No work to do, exit!
   print "Nothing selected!."


Now my problem is, how can I tell a non mesh object (Mesh & empty) apart from a curve (and other blender object types)?

When trying to access .data of a curve/surface (for example), I get a python module missing error Sad

All I want to be able to so is skip non mesh objects in the selection, any pointers or ideas would be ace Razz
Reply with quote


chromit

Posted: Wed Oct 23, 2002 7:01 pm
Joined: 18 Oct 2002
Posts: 3
hope this helps, in my version (2.20) it works. dont know why i had to import Blender210. with the Blender namespace it didnt work.

Code:
from Blender import *
import Blender210
import string

print "Running..."

#Pull in the selected object information...
Selected_Objects=Object.GetSelected()
Number_Of_Selected_Objects=len(Selected_Objects)

#If the user has selected some objects, get to work ....
if Number_Of_Selected_Objects>0:
   #The user has selected something!
   for Working_Object in Selected_Objects:
      #Scan through each of the objects available, grab the object in question
      #If its a usable type ...
     
      if Blender210.isMesh(Working_Object.name):
         print "mesh"
         print "Axis"+str(Working_Object)
      else:
         print "somethingelse"
 
else:
   #No work to do, exit!
   print "Nothing selected!."
Reply with quote


chromit

Posted: Wed Oct 23, 2002 7:21 pm
Joined: 18 Oct 2002
Posts: 3
installed 2.25. here you can get the Type with the getType() method.

Code:
from Blender import *

Selected_Objects=Object.GetSelected()
Number_Of_Selected_Objects=len(Selected_Objects)

if Number_Of_Selected_Objects>0:
   for Working_Object in Selected_Objects:
      print "-- "+Working_Object.getType()
else:
   print "Nothing selected!."


Last edited by chromit on Sun Oct 27, 2002 6:51 pm; edited 1 time in total
Reply with quote


shagwana

Posted: Thu Oct 24, 2002 2:46 pm
Joined: 16 Oct 2002
Posts: 12
Thanks, the getObject() method helps tons. Smile
Reply with quote


 
Jump to:  
Powered by phpBB © 2001, 2005 phpBB Group