Notifications
Clear all

[Closed] How to Select Object Just Made

Total Maxscript ignoramus here.

I have a simple script I’m working on where I create an instance of an object. When I run this script multiple times, I get multiple instances. So for example, the original object is named ‘objectA’ and when I run the script, I get an instance called ‘objectA01’. When I run it again, I get another instance called ‘objectA02’, etc.

I know I can select the newly created instance by being specific using:

select $objectA01

But is there a way/method to select the newly created instance without having to be specific? Like:

select $myNewInstance

Thanks!

6 Replies
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

if your function creates a new node it’s better to have an option to create and select newly created node.

but…
newly created object is the last one in objects list, so to select it you can call


select objects[objects.count]

Excellent!.. thank you!

What would be an example of create and select newly created node?

The next question for this script is:

If I already have a visibility track on the newly created object with a value of 0, what is the proper syntax to add a keyframe at the current time with a value of 1?

Thanks again.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i don’t know how do you create a new node but let’s say the function has to create new box. in this case the function might be:


fn createNewBox sel:on = 
(
  new = box isselected:sel
)


with animate on new.visibility.controller.value = 1

it creates new key if necessary or changes current key’s value to 1.0

Denis,

Thanks very much for your help!! Working great now.

Thanks again.

One more comment Mike,


b=box()
c=instance b
select c

Does that make sense? As Dennis said I don’t know how you’re creating you instance but you should be able to place it into a variable as you create it.

Josh.

Thanks for that Josh! I felt it would be possible using variables but my meager brain could not figure exactly how.

Thanks again to all!