PDA

View Full Version : problem with selection...


zortech
05-06-2007, 10:42 PM
Hi,

i'm currently working on a slight script to convert the current selection of objects into instances/references/copies of a previously selecet object. (I know that am not the first who's doing this) Now my problem is...earlier instanced geometry is also effected by beeing replaced with new geometry... is there a way to avoid this?

Edit: I'd try to make the selected objects unique first...if that works quickly. I've found the "i.MakeObjectsUnique" command by searching the forums. But it results in
-- Unknown property: "MakeObjectsUnique"


on pbtn_source picked obj do
(
pbtn_source.text = obj.name
obj_source = obj
)

a simple pickbutton to get the "source" or "master" object for further instancing...there's another button to call "replaceObj"

function replaceObj i_mode =
(
for i in selection do
(
if i_mode == 1 do
(
instanceReplace i obj_source
i.wirecolor = obj_source.wirecolor
)

if i_mode == 2 do
(
referenceReplace i obj_source
i.wirecolor = obj_source.wirecolor
)
)
clearSelection()
pbtn_source.text = "Select"
)

I've just started to work with MaxScript so please be patient. ^^

BakerCo
05-07-2007, 01:52 AM
not sure but I think it has to do with the pick button adding to the selection try printing out all the objects and see if it is included

come to think of it ... that makes no sense I just tried it myself and it does the same my next guess would be in the replacement. you could go a bit further and just make a new obj and delete the one you are replacing. dunno I don't work with objects much.

side not I like the work on your site.


-Baker

Gravey
05-09-2007, 05:21 AM
Hey dude i happen to be writing a re-instancing script myself!

EDIT! i just tested it out my theory and it was bogus - sorry

kikialex
05-09-2007, 07:55 AM
macroScript re_instance
category:"x"
toolTip:""
(
HoldMaxFile()
MessageBox "Pick source"
target = pickobject "Pick source"
if target != undefined then
(
for i in selection do
(
i.baseobject = target.baseobject
if (target.material != undefined) do
(
i.material = target.material
)
)
)
)

zortech
05-09-2007, 10:00 AM
thanks alot kikialex,
your code works pretty well.

thanks BakerCo. :)

Still not quite sure if it's the way the instanceReplace function works or a problem with my approach.

CGTalk Moderation
05-09-2007, 10:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.