Need simple help for selecting new object made

I just recently started trying out maxscript, and tried to make my own tools for everyday work. I am really really new to this so pardon me if the question is stupid t.t

This is a clone detach alternative since the original EditablePoly.detachToElement do not work like when you pressed it in max and create a new object not in element.

How do i select the new created object without using its actual name like $.Top002

on DetachClone pressed do
(

a = uniquename "Top"
selectedFaces = polyop.getFaceSelection $
polyOp.detachFaces $ selectedFaces asnode:true node:$ delete:false name:(a)

subobjectlevel = 0

)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Swordslayer's picture

.

select objects[objects.count]

This will select last created object, i.e. the detached part.

Deathvision's picture

Thank you for the reply!

Thank you for the reply!

Deathvision's picture

Thanks for the replies jahman

Thanks for the replies jahman and pixamoon !!

Waited quite a few days for the post to be approved by a moderator, and in that time i i managed to get it to work by do this:

on DetachClone pressed do
(
a = uniquename "Top"
selectedFaces = polyop.getFaceSelection $
polyOp.detachFaces $ selectedFaces asnode:true node:$ delete:false name:(a)
subobjectlevel = 0
b = $.name a
select b
)

Although it works, i do not know if its is good coding practice to do so

jahman's picture

.

newname = uniqueName "part"
polyop.detachFaces $ #{1..20} delete:false asNode:true name:newname
select (getNodeByName newname)
pixamoon's picture

`

Hi,

It should be enough to use:

SelectByName a

or if you want to get it as new variable without selecting

b = getNodeByName a

Best,
Pixamooon

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.