Notifications
Clear all

[Closed] How to create a copy of the picked object?

rollout unnamedRollout “Untitled” width:162 height:300
(
pickButton btn1 “PickButton” pos:[39,41] width:90 height:54
on btn1 picked obj do
(

[font=Verdana]~ WHAT SHOULD i eXACTLY TYPE HERE TO CREATE A COPY OF THE PICKED OBJECT? ~
[/font]
)
)
createdialog unnamedrollout

2 Replies
(
      rollout uiCopyRoll "Copy Selected" 
      (
          group "Buttons"
          (
              pickButton uiobjPick "-- Pick your Object --" Autodisplay:true
          
          )
          
          on uiObjPick picked obj do
          (
              copy obj pos:[0,0,0] name:"Hello"
          )
      )
      createdialog uiCopyRoll
  )

Of course you could always take it a few steps further


(
	newName = undefined
	newObj = undefined
	
	rollout uiCopyRoll "Copy Selected" width:135
	(
		group "Buttons"
		(
			pickButton uiobjPick "-- Pick your Object --" Autodisplay:true align:#left
			edittext uiobjName "Optional Object Name" width:100 labelontop:True align:#left
			spinner uiX "X Pos" range:[-100000,100000,0] type:#Float align:#left
			spinner uiY "Y Pos" range:[-100000,100000,0] type:#Float align:#left
			spinner uiZ "Z Pos" range:[-100000,100000,0] type:#Float align:#left
			button uiCreate "Create" enabled:false
		)		
		
		on uiObjPick picked obj do
		(
			newObj = obj				
			uiCreate.enabled = True
			newName = newObj.name
			
			--format "newobj = %
" newObj.name
			--format "newname = %
" newName
		)
		
		on uiobjName entered txt do
		(
			if uiObjName.text != "" then
			(
				newName = txt
			)
		)	
		
		on uiCreate pressed do
		(
			copy newObj pos:[uiX.value,uiY.value,uiZ.value] name:(uniquename newName)
		)
	)
	createdialog uiCopyRoll
)
 

Thanks a lot…really helpful and clear