Maxscript Made Easy: The Power of the One-liners

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 04 April 2013   #1
Maxscript Made Easy: The Power of the One-liners

http://davewortley.wordpress.com/20...-the-one-liner/

I'm inviting suggestions for simple commands you'd just like to yell at max some times, things like "select all animated objects", or "change all my turbosmooth itterations to 5".

I'll add to this blog a load of magic one-liners which save loads of time but I also have a cunning plan for something cooler in the works.
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/
 
Old 04 April 2013   #2
David, that is a great idea and you could even build something around it... take a look at this: http://www.youtube.com/watch?featur...d&v=JbQfvRgUDcA
__________________
Artur Leao | Co-Founder / Project Manager
You can do it! VFX
Porto/Lisbon - Portugal
http://www.ycdivfx.com
 
Old 04 April 2013   #3
Originally Posted by Kameleon: David, that is a great idea and you could even build something around it... take a look at this: http://www.youtube.com/watch?featur...d&v=JbQfvRgUDcA


That is kind of the idea, got an idea about sticking bubbles of text together to build a script.
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/
 
Old 04 April 2013   #4
Good idea. I often request things like this (some of those same ones) from our tech artist. Like "I want a selection of all the keyframed objects in my selection please", or "Make all the selection random colours (but not white, black, mid grey or red)".

Some others I have already that might be useful to others:

Weld, but with a tolerance of 0.001 not 0.1 because we use metres and 0.1 is stupid.

Centre Pivot of all selected objects.

Toggle material colour/ object colour mode without having to go to the display tab.

Detach all elements to objects.

UVunwrap but open in freeform transform mode and poly sub object mode because that doesn't save as a default.

Unhide all objects in current layer.

Assign current material to selection (without needing to open mat editor).

Re-instance selection using first picked as master object. (Instance-O-Matic but made into a macroscript).

Granted some might be a bit longer than one line, but they all can be expressed as a simple no interface macroscript that can be added to a button, hotkey or quad.
 
Old 04 April 2013   #5
The random wirecolor one is something I use all the time

BTW, you can just do

for o in selection do o.wirecolor = random black white

you don't need to randomize each component separately.
 
Old 04 April 2013   #6
One I use all the time is to select objects by the selected objects material/wirecolor. Very useful when working with CAD objects. Just select one object and run it.

Select all objects that have the same wirecolor as the selected object

select (for o in objects where o.wirecolor == ($.wirecolor) collect o) --select by wire


Select all objects that have the same material as the selected object


select (for o in objects where o.material == ($.material) collect o) --select by material


ps shouldn't this post be in the maxscript forum?
__________________
www.davetyner.com

Last edited by em3 : 04 April 2013 at 02:17 PM.
 
Old 04 April 2013   #7
Originally Posted by em3: ps shouldn't this post be in the maxscript forum?


Probably but I want people who aren't maxscript writers to contribute, it'll get lost in the maxscript forum. My idea is about developing something accessible in plain english that is otherwise complex for some.
__________________
Maxscript Made Easy...
http://davewortley.wordpress.com/
 
Old 04 April 2013   #8
Originally Posted by DaveWortley: Probably but I want people who aren't maxscript writers to contribute, it'll get lost in the maxscript forum. My idea is about developing something accessible in plain english that is otherwise complex for some.


Got it. Great thread, thanks for starting it!
__________________
www.davetyner.com
 
Old 04 April 2013   #9
I'll add this very simple one that dumps all texture maps from memory.

freescenebitmaps()
 
Old 04 April 2013   #10
Selection methods in Maxscript:

Select Standard Light:
select (for i in lights where i.category == #standard collect i)


Select Photometric Lights
select (for i in lights where i.category == #Photometric collect i)


Select All Lights
select (for l in lights collect l)


Select Free Cameras
select (for c in cameras where classOf c == freeCamera collect c)


Select Target Camera + Target
select (for c in cameras where classof c == targetObject or classOf c == targetCamera collect c)


Select All Cameras
select (for c in cameras collect c)


Select Helpers
select (for h in helpers where h.category == #standard collect h)


Select Splines / Shapes
select (for s in shapes where s.category == #splines collect s)


Select Spacewarps
select (for s in spacewarps collect s)


Select bone objects & biped
select (for b in objects where classof b == boneGeometry or classOf b == Biped_Object collect b)


Select opposite objects that is'nt in the selection (Hidden Objects are ignored)
select (for obj in $* where not obj.isSelected and not obj.isHidden collect obj)


Select object by same wirecolor
select (for o in objects where o.wirecolor == ($.wirecolor) collect o)


Select object by edit poly objects
select (for o in geometry where classOf o == editable_poly or classOf o == polyMeshObject collect o)


Select object by edit mesh objects
select (for o in geometry where classOf o == editable_mesh collect o)
__________________
3D Engineer at MHWirth
Aker Solutions
www.homme3d.com

Last edited by tassel : 04 April 2013 at 09:44 PM.
 
Old 04 April 2013   #11
on btn1 pressed do start working

on btn2 pressed do redo max

on btn3 pressed do make money
 
Old 04 April 2013   #12
Originally Posted by tassel: Select All Lights
select (for l in lights collect l)



select lights
 
Old 04 April 2013   #13
Rotate selected objects to random rotation around their z-axis in their local coordsys.

This is useful for randomizing rotations on things like screwheads, nuts&bolts, trees, and other objects like that.


in coordsys local (	for obj in selection do (obj.rotation.z=random 0 360 ))
__________________
The GPU revolution will not be rasterized! - http://www.jdbgraphics.nl
 
Old 04 April 2013   #14
Originally Posted by jonadb: Rotate selected objects to random rotation around their z-axis in their local coordsys.

This is useful for randomizing rotations on things like screwheads, nuts&bolts, trees, and other objects like that.


in coordsys local (	for obj in selection do (obj.rotation.z=random 0 360 ))


For trees, I like to add in a bit of random scale, too. Multiply the x, y and z scale by (random 0.8 1.2) along with the rotate, and you can trick anyone!
__________________

 
Old 04 April 2013   #15
Create and align helper to specific poly face (using sphere > edit poly as target object)


p=point size:4 pos:(polyop.getfacecenter $Sphere001 140) dir:(polyop.getfacenormal $Sphere001 140)


Create and align helpers to ALL poly faces (using sphere > edit poly as target object)


for f = 1 to $Sphere001.numfaces do p=point size:4 pos:(polyop.getfacecenter $Sphere001 f) dir:(polyop.getfacenormal $Sphere001 f)
__________________
www.davetyner.com

Last edited by em3 : 04 April 2013 at 05:57 PM. Reason: changed $ to $Sphere001
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 03:41 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.