Notifications
Clear all

[Closed] object instance replace

I’m pretty newbie about maxscript.
In maxscript ,there is instancereplace method.
So,I want to change to make rollout button and select objects by pushing the bottun.
I tried ,but don’t work well.
rollout MYTool01 “instancereplace”
(
button selectObj_btn “selectObj” pos:[8,5] width:60
button replaceObj_btn “replaceoObj” pos:[8,30] width:60
button replace_btn “execute” pos:[8,50] width:60
local obj=#()

on selectObj_btn pressed do
(
srcobj= $selection as array
)
on replaceObj_btn pressed do
(
dstObj = $selection as array
)
on replace_btn pressed do
(
instancereplace srcobj dstObj
)
)
createDialog MYTool01 width:600
Is there a way to find a good code,please?
Sorry about my poor English.

2 Replies

one of the possible solutions:


try(destroydialog instancereplaceDialog) catch()
rollout instancereplaceDialog "Instance Replace" width:210  
(
   group "Target:" 
   (
      pickbutton target_bt "Pick Target" width:192 autoDisplay:on align:#right offset:[4,0]
   )
   group "Tools:" 
   (
      button replace_bt "Instance Replace" width:192 align:#right offset:[4,0]
   )
   
   on replace_bt pressed do undo "Replace" on 
   (
      if isvalidobj target_bt.object and selection.count > 0 do
      (
         instancereplace selection target_bt.object
      )
   )
)
createdialog instancereplaceDialog

thanks a lot,denisT.