ScriptSpot

Forum topic · General Scripting

Help select object

By sonnenberg · 2013-10-28

Description

Good evening, I'm trying to put a personal selection shortly after instance to understand that the script is the selected object. How can I do this?

local objPos = (intersectRay $ground treeRay).pos,

objScale = [1,1,1] * random fromScale.value toScale.value

instance ?????????? pos:objPos scale:objScale name:"Objeto copia"

Comments (3)

sonnenberg · 2013-10-29

Staff will try to explain again.
In my intance if I leave it at $'ll be picking up my box Box I want to create an object that understands that the object I want is selected. How can I do this?

local objPos = (intersectRay $ground treeRay).pos,
objScale = [1,1,1] * random fromScale.value toScale.value
instance $box pos:objPos scale:objScale name:"Objeto copia

.

miauu · 2013-10-29

If I understand you correctly you want to create an instance of currently selected object. In this case use this:


(
	if selection.count != 0 then
	(
		selObjsArr = selection as array
		instancesArr = for o in selObjsArr collect
		(
			instance o pos:(o.pos + [100,100,100]) isSelected:true
		)
		--	select created instances
		select instancesArr
	)
	else
		messagebox "Select at least one object" title:"Empty Selection"
)

Code works with multiple objects that are selected. instancesArr holds all created instances, so you can select them with select instancesArr.

.

miauu · 2013-10-29

I don't understand exactly what you want to acheive, but
1 - if you want to create an instance of some object and you want this instance to be selected after it is created then use this


newObj = instance $teapot001 pos:[100,100,100] isSelected:true

The Teapot001 is the object that will be instanced.

isSelected:true

will select the created instance

newObj

will hold the created instance, so later you can use neObj to access any of the properties of the created instance.