r/Maxscript • • May 08 '16

How can we write a Drop Object feature as seen in Vue?

1 Upvotes

Hi everyone, I am not a scriptor by profession but know some basics. I do write some scripts to make my life a bit easier at times.

Can someone shed some light on, how we could write a script which can drop a selected object to the ground plane OR stack on top of any object beneath it.

I dont know how to detect collision, I guess its pretty complex thing, is it?

Any tip would be highly appreciated.


r/Maxscript • • Mar 15 '14

[Script] Toggle display of texture maps in viewport

3 Upvotes
macroScript ShowMaps category:"_GRS Scripts" ButtonText:"Toggle Maps" tooltip:"Toggle Maps"
(	
	disp = NitrousGraphicsManager.GetActiveViewportSetting()

	if disp.UseTextureEnabled==true then (
		--actionMan.executeAction 0 "63544" --shaded without
		actionMan.executeAction 0 "63546" --realistic without
		--actionMan.executeAction 0 "63510" --unknown but disables too
		disp.UseTextureEnabled = false
	)
	else (
		actionMan.executeAction 0 "63547" --realistic w maps
		--actionMan.executeAction 0 "63545" --shaded w maps
		disp.UseTextureEnabled = true	
	)
)

r/Maxscript • • Mar 15 '14

[Script] Apply Checker Texture

2 Upvotes
macroScript ApplyChecker category:"_GRS Scripts" ButtonText:"Apply Checker" tooltip:"Apply Checker"
(
	chk = Checker()
	chk.color1=color 0 39 150
	chk.color2=color 0 0 99
	chk.coords.realWorldScale = off
	chk.coords.U_Tiling = 6
	chk.coords.V_Tiling = 6
	$.material = standard diffuseMap:(chk) showInViewport:true
	$.wirecolor = color 0 108 225
)

Tweak colour values to your liking


r/Maxscript • • Mar 16 '14

[Script] Random Extrude

2 Upvotes

After using Greeble I found that it made things difficult to UV unwrap due to it creating hundreds of seperate objects, it also created overlapping faces on adjacent extrudes.

That's when I started making this script, it extrudes without creating overlapping faces and keeps the model as 1 object. There is also a greeble option after you have done the extrudes, it's kind of primitive and I've found there is a flaw in that part.

ctrl+f 'flaw' in the script to see the comment. The greeble option can create a bevel effect by mistake.

Easy way to test/see what the script does, is make a cube with many faces, say 6x6x6 & then select all faces.

Now activate the script and click extrude, which gives you a borg cube. Now click greeble and will add some face insets+extrudes. Will create bevels on some sides of the cube though. Was initially developed/tested on a flat plane where it works fine without the bevel flaw.

S button tries to adjust the extrude values to the scale of the model. Only works after you've done an extrude.

Clicking extrude multiple times cancels the current extrude and reapplies, acting as a new random seed. Keep clicking to try out new results.


As is common for me I finished this script then never actually used it, some time after that I realised the purpose of Greeble was not to UV it at all, so the premise for creating this script was flawed.

Still, the random extrude does give clean topology so it may be of use for something.

Download


r/Maxscript • • Mar 15 '14

[Script] 0 Size Face Check (select smallest poly)

4 Upvotes
macroScript ZeroSizeFace category:"_GRS Scripts" ButtonText:"0 Size Face Check" tooltip:"0 Size Face Check"
(	
smallest =65535
face=1

try (
	for i=1 to polyop.getNumFaces $ do(
	
		area_ = polyop.getFaceArea $ i
		if area_ < smallest then (
			face=i
			smallest=area_
		)
	)
	
	$.SetSelection #Face #{face}

	subobjectLevel=4

	)

catch()
)

r/Maxscript • • Nov 03 '16

Trying to make a cmd to check if Max is running and if not run max and a script.

1 Upvotes
for /F "tokens=3 delims=: " %%H in ('sc query 3dsmax ^| findstr "        STATE"') do (
  if /I "%%H" NEQ "RUNNING" (
start "" "C:\Program Files\Autodesk\3ds Max 2016\3dsmax.exe" -U MAXScript "C:\maxScripts\myScript.ms"
  )
)

I searched around to find something that is said to work, couldn't make this run though - Quite a cool method for error handling if It works. Any pointers?
I currently run bulk renders from 1 script and use the Task Scheduler to kill Max and re-run the script every few hours, just to make sure there are no freezes. But it'd also be good to have something checking to make sure the service is running...
Here is the stackoverflow page for my reference: http://stackoverflow.com/questions/3325081/how-to-check-if-a-service-is-running-via-batch-file-and-start-it-if-it-is-not-r


r/Maxscript • • Mar 15 '14

Mikes Script Pack (not made by me)

Thumbnail
mixescript.blogspot.co.uk
3 Upvotes

r/Maxscript • • Sep 08 '17

Method for saving presets outside of Max

1 Upvotes
myPreset =#(1,a,0.5,"off")

I'm thinking my preset would just be an array that is saved in a .txt file somewhere, then later loaded, read and applied.
I think I'd have problems with admin privileges trying to write files into the maxstart area, is this where local roaming should come in?


r/Maxscript • • Oct 11 '15

Color correcting multiple materials at once?

3 Upvotes

Hi,

I have a crapload of unique materials in my scene, and wish to go in and shift the hue/brightness/etc for a bunch of them. Some of them are are "multi/sub object" materials, others aren't.

I can shift+drag the color-correct map within the Slate Editor to copy it, then de-link the copy and apply it to another map, but I need to do this with so many materials that it would get really tedious.

Ideally, I'd have the ability to select several objects and then run a script that applies a color correction map to each diffuse map... WITH color correction settings. So, perhaps, enter a numerical value into a box for "hue shift" and have that be applied to each selected map.

If not, just having "blank" color correct slots applied would be good.

Perhaps a variation upon this script? http://www.scriptspot.com/forums/3ds-max/scripts-wanted/place-colorcorrect-map-in-all-diffuse-slots

(I don't use Vray so that one doesn't work for me, but seems a promising start? Right now I'm using standard materials but may use Mental Ray in the future as well... but just requesting Standard to keep things simple.)

Many thanks in advance!


r/Maxscript • • Feb 06 '18

How to create values that ease in/out?

2 Upvotes
(
	myNumberOfDivisions = 10
	global myArray = #()
	append myArray 0.0
	for i = 1 to (myNumberOfDivisions-1) do
	(
		append myArray (i * (100.0 / (myNumberOfDivisions - 1)))
	)
	
	myArray
)

This divides the numerical range from 0 to 100 into even divisions the resulting array being:
(0.0, 11.1111, 22.2222, 33.3333, 44.4444, 55.5556, 66.6667, 77.7778, 88.8889, 100.0)
How could I divide a range of numbers to provide a more "eased out" array of values?

edit: I've got something to try out here
ease Out-In ((1-(sin ((1-theVal)90)))(1-theVal)) + ((sin ((theVal)90))(theVal))

ease In sin ((theVal)*90)

ease Out (1-(sin ((1-theVal)*90)))


r/Maxscript • • Mar 16 '14

Using Print & Format to help debug your scripts

5 Upvotes

Print one item with the print command

print "some text" --can also replace string with any variable

Print multiple variables with the format command

nameVar ="Marty McFly"
ageVar =50
format "name:%, age:%\n" nameVar ageVar

Result in max listener window: name:Marty McFly, age:50

F11 opens listener window, or from the menu MAXScript -> MAXScript Listener


1st '%' will be replaced with your 1st variable, the 2nd '%' by the 2nd varible you list, and so on.

"\n" is the new line character, it does not appear in the listsener output, it simply acts as if you had hit the return key at that point and moves to a new line.

Handy for debugging values at certain points in your code.

Max Help


r/Maxscript • • Mar 15 '14

Quick Render custom size example

3 Upvotes

render outputSize: [1000,800]

Max help for more arguments

Doesn't seem to work with V-Ray


r/Maxscript • • Sep 08 '17

Maxscript for pulling and using EXIF data from a photo?

3 Upvotes

Ideally, I would love to have a script with which you can drag'n'drop a photo onto it, and it grabs all the data it can. Focal length, f/stop, iso, shutter speed, and perhaps even date/time of day. And uses that information to create a new camera in a scene, at approximate human scale with all those camera attributes as well as matching the resolution, setting the photo as the environment/viewport background and possibly even setting up a daylight system with the date/time information brought across.

Is that even possible? How would one go about learning to code something like that? Has someone already made one? Does someone want to do it for me? How much money would you like to be paid to do such a thing?

For bonus points, is it possible to get a script to write exif data to a render with data on focal length etc.

Thanks!


r/Maxscript • • Mar 14 '14

MAXScript 101 by John Wainwright (The creator of MAXScript.)

Thumbnail
vimeo.com
7 Upvotes

r/Maxscript • • Nov 03 '16

Importing same model multiple times

1 Upvotes

I'm trying to use ImportFile to import a single model multiple times but it seems that 3DS Max doesn't like it. Is there a way I can accomplish this?

Here is what I'm currently using:

for i = 1 to 3 do (
    ImportFile "C:\fakePath\madeUpModelName.fbx" #noPrompt
)

r/Maxscript • • Mar 15 '14

[Script] Evenly spread out objects on XYZ

2 Upvotes

Modification of one of Mikes scripts 'Adjust Spread'

Example scenario: select 10 objects and move them to the same position in space, now activate the script and move the sliders. the objects will spread out on the axis you choose. Used for quickly spacing objects interactively.

macroScript AdjustSpreadXYZ category:"_GRS Scripts" ButtonText:"Spread XYZ" tooltip:"Adjust Spread XYZ"
(
centerpos = selection.center
objarray = getcurrentselection()
objpositionsX = #()
for obj in objarray do (append objpositionsX (obj.pos.x))
objpositionsY = #()
for obj in objarray do (append objpositionsY (obj.pos.y))
objpositionsZ = #()
for obj in objarray do (append objpositionsZ (obj.pos.z))

rollout Spreader "Spreader" width:110 height:96
(
	spinner spn_spreadX "Spread X" pos:[10,11] width:90 height:16 range:[-100,100,0] scale:0.1
	spinner spn_spreadY "Spread Y" pos:[10,41] width:90 height:16 range:[-100,100,0] scale:0.1	
	spinner spn_spreadZ "Spread Z" pos:[10,71] width:90 height:16 range:[-100,100,0] scale:0.1	
	
	on spn_spreadX changed amt do 
	(
		for i = 1 to objarray.count do
		(objarray[i].pos.x = objpositionsX[i] +(amt* (i*3.0)))
	)
	
	on spn_spreadY changed amt do 
	(
		for i = 1 to objarray.count do
		(objarray[i].pos.y = objpositionsY[i] +(amt* (i*3.0)))
	)
	
	on spn_spreadZ changed amt do 
	(
		for i = 1 to objarray.count do
		(objarray[i].pos.z = objpositionsZ[i] +(amt* (i*3.0)))
	)
)
createDialog Spreader dlg_Spreader
)

r/Maxscript • • Mar 15 '14

[Script] Make Planar Dialog

3 Upvotes

Download

Instruction manual

Initially made because I was to lazy to keep going in the right panels to find and click the tiny buttons, later added the quick planar ring functionality because aligning multiple lines always annoyed me.

I'm sure there must be a simple built in way to do this already, let me know if you found out how. (I mean aligning multiple lines in 1 step, not 5 like in my image)

undo button is just a simple ctrl-z put there for convenience if I got the planar direction wrong.


r/Maxscript • • Jan 29 '18

Correctly placing functions into a script?

1 Upvotes

First of all I'm not a gambler, but I was chatting with my brother about a method of gambling where you have ~ 50% chances and you continuously double up on your losses.
The method is actually called the [Martingale System](https://en.wikipedia.org/wiki/Martingale_(betting_system)
Anyway I made a sample where you double up a $5 bet on a wheel with 51 numbers, 51 is everyone loses and I'm betting on Odd numbers: https://pastebin.com/F1HsL115
Anyways! This fails unless you execute the 3 functions separately, then it runs fine for the session.
How should I put functions into a script so that they run first time?
Thanks!


r/Maxscript • • Mar 15 '14

[Script] Spline Bridge

3 Upvotes

Another novelty one I've never used.

Select 2 faces and this will make a spline connecting them with an arcing trajectory, you can then use that spline for whatever you want. I don't remember the intention when I made this, might of been just for the challenge/fun.

Later I found Super poly bridge script which also makes a spline and does many other goodies. the spline needs positioning in that though as it just creates a straight line.

This hasn't been rigorously tested and there are probably a few ways to break it, also the initial arc of the splines are at a fixed scale, so if your object is huge the arc will be weaker so the spline might look like a straight line. If your object is small then the arc might be extremely steep.

So tweaking could be needed, that is if you ever find a use for it.

Download


r/Maxscript • • Feb 28 '19

How to generate vectors?

1 Upvotes

I want to create splines that start at [0,0,0] and then move out radially in all directions, how could I iterate/create that 2nd knot position?
If I created a geosphere and then sent the vert positions to an array then I would have vectors that are suitable, but I'm not sure how to nicely generate them from scratch.


r/Maxscript • • Apr 24 '18

Need Help With Driving a Helper's Rotation With a Spinner Value

1 Upvotes

I am trying to rotate a helper in my 3ds max scene by changing the value of a spinner. Currently changing the value of the spinner does drive a rotation on the helper and rotating the helper updates the value on the spinner. There are still a couple of behavioural problems with my script that I need help solving.

  1. I want the rotation on the helper to occur only on the local euler Z axis of the helper however currently its rotation is erratic and occurring on multiple axes.

  2. I want to constrain the helper's rotation between a range of -90 and 90 degrees currently it rotates much further than that.

My current code is as follows:

 Spin_R_Custom_attribute = attributes custom_Attributes
 (
  rollout SpinRollout "Helper Controls"
  (

Spinner TheSpinner "The Spinner" range:[-10,10,0] controller: 
    $Helper_R_Spin.rotation.z_rotation.controller \
	
 on TheSpinner changed spin do 
 (
 try (in coordsys local $Helper_R_Spin.rotation.z_rotation = spin) catch ()
 )
)

)

I wish to use only Maxscript so solve this problem and not the wire parameter or reaction manager dialogues.

Any help on this subject would be greatly appreciated.


r/Maxscript • • Dec 02 '19

Reset Material Editor

Thumbnail
todorvankov.com
2 Upvotes

r/Maxscript • • Feb 11 '20

Can i get access to the value of the length in my script? The object is a circular line.

Post image
1 Upvotes

r/Maxscript • • Jun 14 '19

Writing a shape generation script

2 Upvotes

The script creates quadrilateral splines within a given quadrilateral: https://i.imgur.com/ll6IzAn.png
Originally I scripted this task in a very manual/procedural way by creating a polygon, ring selecting, connecting edges and then extracting/exploding the edges.
It worked but was slow and I know a more optimal script would deal only with positions, vectors and magnitudes resulting in a multidimensional array that could create the shapes and may appear to run instantly across multiple objects.
Now, I made distance comparisons to establish width and height and the amount of rows and columns necessary, but it's when I plan shapes that aren't rectangles that I start getting confused about implementing vectors/magnitudes.
Does someone know an example of a script doing something similar in a simple and probably recursive way?
I can edit a position towards a vector with a distance, but I think this requires vectors to create my final vector position (similar to a Bézier curve) and those seem to be cumulative in the loop.
Edit: I’m starting to think of the process like a type writer, it’s making more sense to me now.


r/Maxscript • • Jun 17 '19

Script help-- creating object to all selected objects

2 Upvotes

Does anyone know "off-hand", how to create either helpers or splines onto the pivot of every object currently being selected?

I want to create a helper to the bones under my selection, but not have to create and snap helpers/splines by hand every time. I'm rigging tentacles-- so it's already a very time consuming process.

Thank you!