Home Technical Talk

Maxscript Help with Identifying Object Creation

interpolator
Offline / Send Message
Axi5 interpolator
Hi,

I've got a script that's meant to do work on all the Geometry in the scene.
Unfortunately while it loops in creation mode it disables the chosen create tool. My current idea is to work out how to get the name/id of the object that is being created using:
isCreatingObject()
Then save it to a variable and then re-activate it after the script has completed, is this possible? I took a look at the documentation and there's a keyword called returnNewNodes but it seems to only work for startObjectCreation().

http://help.autodesk.com/view/3DSMAX/2015/ENU/index.html?guid=__files_GUID_D8CBACCF_73B3_41DF_9A2D_031CED757371_htm

Or maybe there's a better way using callbacks? I really don't want to have to write an array for every possible creation item and loop through to check if anything matches. Surely isCreatingObject() must have some way of returning the current object because it accepts arguments to check if they're true.



Alternatively, is there another variant of this loop that doesn't break the object creation?:
for OBJ in Geometry do
(
    for o in obj.modifiers do
    (
        //stuff.jpg
    )
)

Replies

  • monster
    Options
    Offline / Send Message
    monster polycounter
    Why are you looping while an object is being created? That would probably slow things down for the user. I feel like I need a large snippet of code to help you better. What are you doing to the object when it is done being created?

    You can call objects[objects.count] to get the last object created. But that's only reliable if no other scene operation has happened.

    The callbacks are pretty easy:
    callbacks.removeScripts  id:#newObjs
    
    fn printObjName obj callback =
    (
    	format "%: %\n" callback obj.name
    )
    
    callbacks.addScript #nodeCreated "printObjName (callbacks.notificationParam()) #nodeCreated" id:#newObjs
    callbacks.addScript #sceneNodeAdded "printObjName (callbacks.notificationParam()) #sceneNodeAdded" id:#newObjs
    

    #sceneNodeAdded will get merged objects and created objects, #nodeCreated will only get objects that are manually created.
  • Axi5
    Options
    Offline / Send Message
    Axi5 interpolator
    monster wrote: »
    Why are you looping while an object is being created? That would probably slow things down for the user. I feel like I need a large snippet of code to help you better. What are you doing to the object when it is done being created?

    You can call objects[objects.count] to get the last object created. But that's only reliable if no other scene operation has happened.

    The callbacks are pretty easy:
    callbacks.removeScripts  id:#newObjs
    
    fn printObjName obj callback =
    (
    	format "%: %\n" callback obj.name
    )
    
    callbacks.addScript #nodeCreated "printObjName (callbacks.notificationParam()) #nodeCreated" id:#newObjs
    callbacks.addScript #sceneNodeAdded "printObjName (callbacks.notificationParam()) #sceneNodeAdded" id:#newObjs
    

    #sceneNodeAdded will get merged objects and created objects, #nodeCreated will only get objects that are manually created.

    It's not a large script, it's just flipping off a few modifiers like turbosmooth :)

    It's just so that when it's on it hides clutter in the scene so it's easier to create the object in a necessary place. I could enable it before selecting the object to be created but I think it would be a bit more polished to get it work during the process as well.

    Other than the code I provided above, the rest of the code is just stuff like:
    if classof o == turbosmooth do o.enabled = false
    

    and switching the state of the UI button.

    Thanks for the callbacks, I know how they work I just don't know them all, I thought there might be one that can help with that niche little area haha.

    edit: As for post object creation, I'm doing nothing to the newly created object. This script is purely to aid in it's creation and editing.
Sign In or Register to comment.