GetSelected Help


(mxopivypx) #1

Does anybody know how I would get something like this to work:

select=Object.GetSelected()[0]
obj=NMesh.GetRaw(select)

I get the error “expected string block found” so my main problem is getting the name of the selected object to be returned as a string.
Hopefully there’s a way to do this.

Adam


(ectizen) #2

Try this:

obj=NMesh.GetRaw(select.name)

(theeth) #3

or better yet:


obj=Blender.Object.GetSelected()[0].data

Martin


(jms) #4

or :


select=Blender.Object.GetSelected()
if len(select)>0:
   #better if a test controls that the data are meshes
   obj=Blender.NMesh.GetRaw(select[0].data.name)

jm


(theeth) #5

or, even better



meshlist = [ob.data for ob in Blender.Object.GetSelected() if ob and ob.data.Block_Type = "NMesh"]


:wink:

Martin


(ectizen) #6

:-? … :o

That looks like fun. Maybe it’s time to actually learn Python.

(including my post above, I have written about 12 lines of Python code :wink: )


(jms) #7

Pretty!
:slight_smile:


(theeth) #8

/me likes list comprehension 8)

Martin


(mxopivypx) #9

Thanks Everyone! :smiley: