Duplicating Datablocks


(Morbid) #1

I’ll try and make this the least confusing as I can…

I can’t for the life of me figure out how to grab the object data name of an object.

For instance, an object is selected:


for o in Object.GetSelected():
  c = o.getData()
  print c

Which prints:


[Curve "Curve.004"]

How can I get “Curve.004” out of that list so I can assign it to a variable so that I can use it later? Say for grabbing the data or linking another object to that data.

Sorry if that doesn’t make much sense. If it doesn’t let me know and I’ll try and clarify more.

Thanks.


(timmeh) #2

you can’t get that name at the moment because you are printing the object object’s data :slight_smile: what you want is something like :


objs = []
for obj in Blender.Object.GetSelected():
      data=obj.getData()
      name = data.getName()
      objs.append(name)


timmeh


(jms) #3

You can replace “name = data.getName()” like this :


objs = []
for obj in Blender.Object.GetSelected():
            objs.append(obj.getData(1)) 


(Morbid) #4

Thanks guys, exactly what I was looking for!


(Morbid) #5

Edit: Ack…I meant to delete this one…now editing is the only available option.

So…edited, I guess.


(Morbid) #6

Alright, I’ve hit a speed bump.

Is it possible to take the datablock information from one object and apply it to another but with a different name? Here’s the result I’m hoping for:

  1. Get datablock info from an object, i.e. curve
  2. Create a new curve and link it to the datablock info from step 1, only with a different name. So, it’ll start out with the same properties as the object from step 1, but can then be edited independently. A SHIFT+D effect.

Is this even possible?


(antont) #7

yep, use Object.link()

~Toni


(Morbid) #8

Is there a way to then make the datablock a single user after linking?


(antont) #9

dunno…