r/Maxscript • • Mar 21 '21

Aligning objects to vertex normals

2 Upvotes

I'm trying this code that I found on twitter and using 3dsmax 2020 it doesn't make the alignment as you can see in the image, it does it in a different way, wrong.What could be happening?

faceArray = polyop.getFacesUsingVert $Box001 4
faceNormals = for f in faceArray collect polyop.getFaceNormal $Box001 f
	
theNormal = [0,0,0]
for n in faceNormals do theNormal += n
	
normalize theNormal

theMatrix = matrixFromNormal(theNormal)
theMatrix.row4 = theNormal
$Box002.transform = theMatrix

Solution Thanks to: Daniel Swahn Lindberg

(
sourceObj = $Box001
targetObj = $Box002

theVert = 4
theVertPos = polyop.getVert sourceObj theVert
faceArray = polyop.getFacesUsingVert sourceObj theVert

faceNormals = for f in faceArray collect polyop.getFaceNormal sourceObj f

theNormal = [0,0,0]
for n in faceNormals do theNormal += n

theNormal = normalize theNormal

theMatrix = matrixFromNormal theNormal
theMatrix.row4 = theVertPos
targetObj.transform = theMatrix
)


r/Maxscript • • Jan 21 '21

Vertex Painting Vert Selection

2 Upvotes

Hi!

I am struggling to write a script for painting vertices with the Vertex Paint modifier.

I would like an option to set the selected verts to absolute R, G or B.

Whenever I try to set VertColor it is not behaving.

Many thanks for your time!


r/Maxscript • • Sep 06 '20

Increasing crowd density with MaxScript

2 Upvotes

Hi all,

This might be a silly question, but for the life of me I can't figure out why this simple script isn't working.

I'm trying to increase the density of a crowd generated using the populate tools beyond the UI max of 1.0, which the documentation clearly states is possible.

However, using the code below results in the idle areas density values being clamped between 0.0 and 1.0.

p = getClassInstances IdleAreaObj
for idleArea in p do idleArea.density = 2.0

Does anyone know why this might be? It feels like I'm missing a preferences tickbox somewhere but I've no idea where to look.

Any help is very much appreciated!


r/Maxscript • • Aug 20 '20

Could someone help me get my MXSPyCOM.exe running again, it's looking for "MXSPyCOM.dll"

2 Upvotes

Hey everyone,

Im looking to get some help getting visual studio code to send my Maxscripts to Max. I did have it working after following this tutorial: http://walterlow.com/setting-up-visual-studio-code-as-an-editor-for-3ds-maxscript/

but now after a few days it's just stopped an i have no idea why.

when i run it i just get this error: The application to execute does not exist: 'C:\Users\pears\AppData\Local\Temp.net\MXSPyCOM\qyuptf3t.axp\MXSPyCOM.dll'.

and it's true there's no .dll file there but i don't know why it's looking for a .dll file there, I'm still very new to visual studio, and i have no idea what MXSPyCOM does under the hood. I would appreciate any help with this.

I also got it MXSPyCOM working through pycharm, but that's throwing up the same error.

and it's the same Error if i try run it through the command line.

:/


r/Maxscript • • Jul 21 '20

MAXScript for Architectural Visualisation

Thumbnail
curvedaxis.com
2 Upvotes

r/Maxscript • • Mar 02 '20

3dsMax 2020's intersectray failing to detect a ray (same test gives a correct ray in 3dsMax 2014 !)

2 Upvotes

What did they change in Max 2020 that made the intersectray command of Maxscript so unreliable?

the very same test of ray hit using that command on the very same mesh is giving me a correct hit position on the same model in 2014 but not in 2020 version...how can I make it work as it worked in 2014...? will they ever fix it to be as it used to be in 2014?


r/Maxscript • • Feb 20 '20

Labeling images in rendering

2 Upvotes

I have created a script that will label images with different values throughout an interval of frames. However, I don’t know where or how to use it when i render from the render frame window. Furthermore, I don’t want to change any settings in the render setting, i just need my script to run to label the images.


r/Maxscript • • Dec 02 '19

Reset Material Editor

Thumbnail
todorvankov.com
2 Upvotes

r/Maxscript • • Oct 16 '19

Controlling utilities like Resource Collector?

2 Upvotes

Is there any way to access utilities, specifically Resource Collector, through maxscript? I've can't seem to find any way to do it.


r/Maxscript • • Aug 03 '19

Help for a script

2 Upvotes

Hi, i’m tryng to make a script that will extract all the zip and rar file on a folder with the( zip or rar) name and move all the files on subfolder on the root of the main new created folder. Unfortunately i don’t know where to start because i don’t think it’s possible interact with External files only through maxscript and i’m kinda new to it.

I wrote this like a guide line if could help

" for i in "folder_path" where i.name == (".zip"; ".rar") do ( extract i to "New_zip/rar_File_Name_Folder" move i to "New_zip/rar_File_Name_Folder" Check for subfolder and move all file inside them to directory

for o in "New_Folder_Path" where o.name != newfolder.name+"*" do ( delete o "

thanks


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!


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 • • Sep 12 '18

Verbatim string in a Variable

2 Upvotes

Hey Guys!

I'm currently running into an issue with our database having an \r in the path name, and its destroying my importer paths when it attempts to reload them. Anyway to use a verbatim string @ + a variable? i don't see anything in the documentation.

thanks in advance!


r/Maxscript • • Jul 07 '18

Good methods for protecting scripts?

2 Upvotes

I'm looking to try to sell more scripts in the future, I think that I should have some way to protect them.
I haven't found a good way to create a hardware lock and it's implementation always confuses me.
I feel like ultimately a script can be mse decrypted and then distributed, but still 'you' should want to take some initial measures. Any go to's for this??
Edit: In terms of 'protecting', it sounds great if you couldn't redistribute a script, my code isn't amazing, but I'm happy with the solution created, currently searching through a few forums...


r/Maxscript • • Jun 17 '18

Is this function doing too much, or a fine amount? Please critique the method.

2 Upvotes
fn ShapeFromArray shapeName myInterpolation theKnotPositionArray theSegmentmaterialArray=
(
	-- create the shape object
	newShape = splineshape()
	--add a spline to the shape
	newSpline = addnewSpline newShape
	--add knots from array
	for myKnot in theKnotPositionArray do
	(
		addKnot newShape newSpline myInterpolation #curve myKnot
		--#corner, #smooth
	)
	--update
	updateShape newShape
	newShape.name = "tmpShape"
	for i = 1 to theSegmentmaterialArray.count do
	try(
		setMaterialID $'tmpShape' 1 i theSegmentMaterialArray[i]
	)catch()
	updateShape newShape
	newShape.name = shapeName
	select (getNodeByName shapeName)
)
--------------------------
/*
--now the function can be called like this:
myKnotArray = #([3.79589,0.0475944,-100], [3.59589,0.0475944,-100], [3.59589,0.0393065,-100], [3.79589,0.0393065,-100], [3.79589,0.0475944,-100])
mySegmentMaterialArray =#(10,1,1,1)
shapeFromArray "firstShape" #corner myKnotArray mySegmentMaterialArray

It's just a function to create a shape and assign material IDs to its segments, create 2 arrays and use the function, as shown.
When declaring the function it will fail on the setMaterial line because I think it is trying to execute that line, so I wrapped it with a try/catch and it skips over it.
I'm starting to see how I can bundle more and more into a function that I'll use multiple times in a script. This is what I should be doing with functions right?
In this example It it faster to create the shapes rather than using a merge command which is slow.


r/Maxscript • • Mar 14 '18

Finding "MAXScript Script Controller Exception" in my scene

2 Upvotes

I've opened an older scene of mine. And I get a popup saying

Maxscript Script Controller Exception. -- No ""curveLength"" function for undefined.

And a Script Controller window with this expression:

(speed*F/curveLength CL)+((100.0/instCO)instNO+(randP100.0/instCO/100))/100

I think it's from an older traffic simulation script I was using, but I can't remember. How do i find where this script is actually stored in the scene? Is it attached to an object? How would i go about tracking it down and removing it?

Thanks!


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 • • Dec 11 '17

Want to create a script to copy UV channel 1 to channel 2

2 Upvotes

Hello, i would like to create a script capable of copying channel 1 to channel 2, basically as i would want it is; I select my grouped object, apply a UV unwrap modifier, move to channel 2, select move when asked to move or abandon uv channel. Then finally collapse modifiers. When i try making it using the max script listener, it creates a script that later when trying to use it max just tells me uv unwrap modifier is unassigned, as i am a noob, i am lost. if anyone can shove me in the right way i'd be much appreciated.


r/Maxscript • • Oct 30 '17

maxscript mystery....how come?!?! i'm clueless

2 Upvotes

Hello,

I was trying to get 2 verts from a given edge the quickest way possible, so the normal way is to use this line of command code :

polyop.getVertsUsingEdge <Poly poly> <edgelist> but its not fast enough for my needs

(I'm trying hard to optimize my script as much as possible)


so I decided to put it into a multithreading script I once downloaded which was created by the guy from lonerobot site. now when I put this very same command in his multithreading script it runs much much faster than when it is not in a multithreaded environment so to speak.



when I ran this unthreaded test code below it took about 2.3 seconds to complete :

undo off

( global StartingTime=timestamp()

				for i=1 to 39800 do
				(
				global EdgeToVerts1=polyop.getVertsUsingEdge testobj1 i
				)

global EndingTime=timestamp() global TimeItTook=(EndingTime-StartingTime)/1000 as float print "seconds it took :" print TimeItTook --enableSceneRedraw() )--undo off end



but when I ran the multithreaded version of it it took only a fraction of the time even tho it was set to run only on one of the cores only (for testing/comparing purposes).

This multithreaded code below took only 0.098 seconds to run and it got the exactly same end result but much much faster how come?!




global testobj1=$sphere01 global array1=#() global array2=#()

global StartingTime=timestamp()

Global Thread1,Thread2,Thread3,Thread4,Thread5,Thread6,Thread7,Thread8

Global Thread_spnLoops_value=1

-------------- Thread 1 --------------------- Fn WorkThread1 sender e = ( for a = 1 to Thread_spnLoops_value do ( for i=1 to 39800 do ( append array1 (polyop.getVertsUsingEdge testobj1 i) ) -- INSERT CODES CONTENT TO RUN ON THREAD NUMBER 1 ----- ) )

-------------- Thread 2 --------------------- Fn WorkThread2 sender e = ( for b = 1 to Thread_spnLoops_value do ( -- INSERT CODES CONTENT TO RUN ON THREAD NUMBER 2 ----- ) )

-------------- Thread 3 ---------------------

.

.

.

-- Specify the BackgroundWorker Class

global Thread1 = dotnetobject "CSharpUtilities.SynchronizingBackgroundWorker"

Thread1.WorkerSupportsCancellation = true		
dotNet.addEventHandler Thread1 "DoWork" WorkThread1

global Thread2 = dotnetobject "CSharpUtilities.SynchronizingBackgroundWorker"

Thread2.WorkerSupportsCancellation = true
dotNet.addEventHandler Thread2  "DoWork" WorkThread2

global Thread3 = dotnetobject "CSharpUtilities.SynchronizingBackgroundWorker"

.

.

.

	try
	(
	If Thread1.IsBusy do Thread1.CancelAsync()
	)
	catch()	

---------------- RUN ALL THREADS AT ONCE HERE ------------------------ undo off ( if (not Thread1.IsBusy) and (not Thread2.IsBusy) and (not Thread3.IsBusy) and (not Thread4.IsBusy) and (not Thread5.IsBusy) and (not Thread6.IsBusy) and (not Thread7.IsBusy) and (not Thread8.IsBusy) do ( Thread1.RunWorkerAsync() Thread2.RunWorkerAsync() Thread3.RunWorkerAsync() Thread4.RunWorkerAsync() Thread5.RunWorkerAsync() Thread6.RunWorkerAsync() Thread7.RunWorkerAsync() Thread8.RunWorkerAsync() ) )

global EndingTime=timestamp()

global TimeItTook=(EndingTime-StartingTime)/1000 as float print "seconds it took :" print TimeItTook

note that I ran the same code only on one core...it shoudve take the same time to complete more or less

so what's really going on here?

thanks in advance for whoever can shed some light on this mystery


r/Maxscript • • Sep 29 '17

Need Help With Using Value Entered in EditText UI Control

2 Upvotes

Hello, I am new to MaxScripting and have been trying to make a tool that would make my workflow for a job a lot easier. So far I have been going pretty good but I have hit a little snag. I do not understand how to take the value entered in an EditText UI Control and use it elsewhere in my code. Currently I am trying as follows:

try (closeRolloutFloater TextTestFloater) catch()
rollout TextEntry "Text Entry Test"
(
    EditText TextEntry "TextEntry"
	    on TextEntry entered do
    (
	    TestString = TextEntry.text
	    print TextEntry
    )
)
TextTestFloater = newrolloutfloater "Text Entry Tool" 175 150
addrollout TextEntry TextTestFloater

This results in an argument count error on my end, its pretty obvious that I'm misunderstanding how to use EditText.text but I am unsure what the actual method to achieve what I want is. Would someone mind pointing mind pointing me in the right direction or telling me how to actually use the text in the text box (and preferably store it as a string)?

Any help is greatly appreciated.


r/Maxscript • • Aug 11 '17

Deselect Hidden or Select Only Visible

2 Upvotes

Hey Guys,

Fair warning, I can't script so go easy :)

[select $*object*]

I tried looking for a way to do this but I came up with nada. I'm using the above to select all parts that have a keyword in their name but it's also selecting hidden parts which is not quite what I'm looking for. So if there is a way to deselect parts that are not unhidden. Obviously if there is a cleaner way to do it by selecting only the visible parts with a certain keyword in the first place, that's even better.

*fixed formatting so it shows the code properly with the *'s


r/Maxscript • • May 04 '17

Configure the ALIGN of LATHE on maxscript?

2 Upvotes

Hello, is there a way to edit the ALIGN parameters from a object that has the LATHE modifier in maxscript? thanks. EDIT: Solved


r/Maxscript • • May 02 '17

Advice on selling MAXScripts?

2 Upvotes

What is a good method to sell scripts without using a middleman like scriptspot?
I hear that .mse is simple enough to get around and it's easy to share scripts, so they might need a system using a unique key to run, I've used a few of those scripts and installation was a little annoying - also maintenance from the creators pov must also be annoying.


r/Maxscript • • Apr 04 '17

Help with loading *mpl

2 Upvotes

Hi, I'm attempting to load a material layout using maxscript, and so far I've had no luck either online or using the reference. Does anyone know of a good way to load a material layout? Thanks in advance!


r/Maxscript • • Nov 27 '16

Batching: Search for file, then run import script, then export?

2 Upvotes

I havea script that takes these two file types, *.main and *.skel. Both of those files have the same name & file path, and the script works like so: Manually the *.main file, manually select the *.skel file, exporte to FBX format into the same folder where the *.main and *.skel are, and then reset the scene.

The issue is that I have +1000 of these files, and manually selecting each pair is incredibly tedious. I tried creating a Windows Batch script like so:

for %%a in (*.main) do (
    if not exist "%%~na.fbx" (
        "C:\Program Files\Autodesk\3ds Max 2012\3dsmax.exe" -silent -U MAXScript "C:\Program Files\Autodesk\3ds Max 2012\Scripts\main_skel.ms"
    )
)

It looks for any files with the .main extension, then checks if an FBX file with the same name already exists But I can't figure out a way to use the %%a variable as an input for the maxscript. I'm also not sure how to write the maxscript to do something similar to the way the bat script would've worked.

Any help would be very greatly appreciated.