Linking Script to an Object

Hi,

Suppose there are many objects (say sphere’s) on my 3d window. I want to be able to click on these objects at random and be able to trigger a python script.

Should i use Script links for this? If yes, then how to link an object to a script?

So far :
I know how to link a .blend file ( atleast i think i do ) to a script by Redraw event using Selected Scriplink i.e whenever file is redrawn Python script is triggered.
However, i am not sure whether the script is triggered because of the selected object or the .blend file that was loaded.

As u can clearly see i am confused and reading previous posts have not been of much help in this topic. PLZ HELP!!

Do you mean that you want a different thing to happen based on which sphere you click? Or that you want the same thing to happen to whatever object you happen to click on?

Do you mean that you want a different thing to happen based on which sphere you click?Or that you want the same thing to happen to whatever object you happen to click on

Let me explain: %|
When a particular object is clicked…the python script to be triggered will be the same but it shud get the name of the object that triggered the script.
So we r basically interested in passing the name of the object to the same python script…to get different output for each object.

We will use a python script to display the objects initially on the 3d window. After that the user should be able to click on any one of the displayed objects and thus run another python script.

Thanks for taking the time to reply. If i;m still not clear about my goal, kindly let me know and i will try to be more elaborate.
:slight_smile:

You could find out which object was selected by using Blender.Object.GetSelected()

Yes, once we can use Object.getSelected() to find the object that has been clicked on.

But how do we trigger a new python script for the selected object? This script should also get the name of the selected object and process it.

Thanks for the replies.