ScriptSpot

Forum topic · General Scripting

Need simple help for selecting new object made

By JasonTeoJH · 2018-05-12

Description

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 (6)

.

Swordslayer · 2018-05-15

select objects[objects.count]

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

JasonTeoJH · 2018-05-16

Thank you for the reply!

JasonTeoJH · 2018-05-15

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 · 2018-05-15


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

`

pixamoon · 2018-05-15

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

ibhurln · 2019-09-03

I have a similar thing i am trying to accomplish, but cannot get the code to work for the life of me.

Im trying to create a script that can:

1. Take a selected editablepoly with many faces>

2. detach all faces as new editablepoly's

3. select all those newly created polys from detach command

4. add a uvwmap to those individual polys im not picky on the naming, and can probably handle the adding of uvwmap, but am stuck on selecting the polys from the detach faces script im using

below is the code im going from: 

(

fn DetachAllFaces obj =

(

if classof obj == editable_poly do

(

local nf=obj.numfaces

while nf !=0 do

(

local newObjName=uniquename (obj.name+"_00")

polyop.detachFaces obj #(nf) delete:true asNode:true name:newObjName

centerpivot (getnodebyname newObjName)

nf=obj.numfaces

)

)

)

objs=for o in selection collect o

selcnt=objs.count

 

for i=1 to selcnt do

(

convertTo objs[i] Editable_Poly

DetachAllFaces objs[i].

delete objs[i]

)

)