I'm looking for a way to store selected object / curve name so that I can reference it in a script.
The idea is to select a curve (with the mouse), then copy another object to its location(with a script). I would also need to reference the original object so I can fill in some modifiers. Problems I'm having now: In order to duplicate that "other" object, I need to select it... which causes me to lose focus from the currently selected original object.
rough code is...
bpy.context.selected_objects
bpy.data.objects['OBJ1'].select = True #select an already created object
bpy.ops.object.duplicate() #duplicate OBJ1
# move duplicated object to same place as originally selected.
# figure out a way to copy location info from original selection.
bpy.data.objects.new.location
bpy.ops.object.modifier_add(type='ARRAY')
bpy.context.object.modifiers["Array"].fit_type = 'FIT_CURVE'
#curvename would be the original thing selected
bpy.context.object.modifiers["Array"].curve = bpy.data.objects[curveName]
Thank you very much for your help.
ob = obj.copy()
and then link it to scene withscene.objects.link(ob)
Oh and btw to get code formatting indent all lines of code by 4 spaces. $\endgroup$curve = context.active_object
Then after dupe or other operators that change the active objectdupe = context.active_object
after which curve will still refer to the curve that was the active object when you assigned it. To set the active context object back to curve usescene.objects.active = curve
$\endgroup$