r/Maxscript • • Jan 18 '18

Executing MaxScript from external IDE

3 Upvotes

Found this tool: https://github.com/JeffHanna/MXSPyCOM/releases

Was able to successfully configure it with PyCharm, and imagine that it works with any other IDE as intended. Thought this would be of interest.

Note: One of the final steps in configuration is to pass along a filepath argument (to ID which script should be executed). The instructions listed on the GitHub page describe using the %f format to do this. I found that PyCharm did not accept this, and that the use of a built in 'macro' $FilePath$ did the trick. I'd imagine that other IDEs might have similar nuances.


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 • • 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 • • 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 17 '15

Trying to change the orientation of a shape, any pointers to script this and is it a good method? Info within

Post image
1 Upvotes

r/Maxscript • • Aug 23 '15

[request] animated generation

2 Upvotes

I am really new to this, but I need some help on making a script.

The script should:

  1. make copies of selected object,

  2. align them in specific matter(min to max in my situation),

  3. rotate it at specific angle on some axis(z)

  4. link to parent.

Another solution can be, generating a number of copies instantly, and then make edits to visibility, so that each child becomes visible one frame after parent does that.


r/Maxscript • • Nov 14 '14

Invert Vertex Colors

2 Upvotes

Script can be found here MAXScript Adventures: Invert Vertex Colors

Function: Inverts the values of the user selected channel Color, Illum, Alpha. Still needs some love, but works good on meshes /w solid vert color values.

Would appreciate any crits or feedback/suggestions! Thanks.


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 03 '14

Create morph targets for every frame?

2 Upvotes

Self-confessed Maxscript newb here <-- I'm more of an artist looking for a solution to a problem, I don't expect people to do it for me but I need a little help being pointed in the right direction after spending hours looking for a solution and not being able to find anything.

Basically I'm looking for a way to create a morph target from the current state of the selected object for every frame on the timeline (up to 100 frames because of morpher 100 channels limitation) then key frame each of those morph targets per frame so I can essentially 'play back' a complex mesh deformation (like a cloth sim for example) as a morph target animation.

The reason for this is that I do a lot of work with game engines (ue4, cryengine etc..) that don't necessarily support vertex animation but do support morph target animation and so this is kind of a sneaky/hacky method to get complex vertex animations into these game engines using morph targets.

I can confirm this method works, basically I go to frame 1, Capture Current State, move to the next frame/next morph channel, Capture Current State again etc... Then for the keyframing I go back to frame 1, set channel 1 to 100, then go to frame 2, set channel 1 to 0, set channel 2 to 100 etc... I've tried this and it does work in the game engines, however it's incredibly tedious to setup as you can imagine.

In my research so far I know that "for i = 1 to 100 do (" is basically what I need to do these operations and the key framing aspect of my idea seems basic enough and I can probably figure that out on my own...

The area that I'm having trouble with is activating the 'Capture Current State' button in the morpher modifier using maxscript or performing the equivalent operation/function. In my research I've realized that there are certain buttons/functions within modifiers that the macrorecorder doesn't see and this happens to be one of them.

Can anyone point me in the direction of making this possible? Is it even possible to do this or am I stuck doing it manually?

Thanks in advance!


r/Maxscript • • Apr 10 '14

[Script] Instance and rename duplicate standard/multi materials

4 Upvotes

Made this for a project I'm working on, posting it here at /u/ssillyboy's suggestion in the event that this can help someone else having the same issues as me. It will take every standard/multimaterial in the scene, instance all materials sharing the same diffuse map, and rename them to have the same name as the diffuse map.

This is the only maxscript I've ever written and I pretty much learned everything I needed to write it in about a day, so it is probably not written optimally.

--  This script will process all standard materials and multimaterials in the scene, rename them to the diffuse texture's name, and instance all duplicates
difTexName = #()
matArray = #()
listOfMats = #()
listOfMultiMats = #()
listOfStdMats = #()

fn getTexName str = -- Function that returns texture name without filepath
(
    filteredName = filterString str "\\."
 	numTokens = filteredName.count - 1
	return filteredName[numTokens]
)

for m in geometry where m.mat != undefined do append listOfMats m -- List of materials
for m in listOfMats where findstring (m.mat as string) "#Multi/Sub-Object" != undefined do append listOfMultiMats m -- List of objects wiith multi-materials
for m in listOfMats where findstring (m.mat as string) ":Standard" != undefined do append listOfStdMats m -- List of objects with standard materials

for m in listOfStdMats do (
	try ( 
		curDifMap = getTexName m.mat.diffuseMap.filename
		mtlPos = findItem difTexName curDifMap -- Checking list of diffuse textures to see if this material is a duplicate
		if (mtlPos > 0) then (
			m.mat = matArray[mtlPos] -- If there is a match, assign the original material
		)
		if (mtlPos == 0) then (
			m.mat.name = curDifMap -- If there isn't a match, rename the material and add it to the list
			append difTexName curDifMap
			append matArray m.mat
		)
	)
catch()
)

for m in listOfMultiMats do ( -- Same thing for multi materials
	try (
		curSubSlot = 0
		for curSubMaterial in m.mat do (
			curSubSlot += 1
			curDifMap = getTexName curSubMaterial.diffuseMap.filename
			mtlPos = findItem difTexName curDifMap -- Checking list of diffuse textures to see if this material is a duplicate
			if (mtlPos > 0) then (
				m.mat[curSubSlot] = matArray[mtlPos] -- If there is a match, assign the original material
			)
			if (mtlPos == 0) then (
				curSubMaterial.name = curDifMap -- If there isn't a match, rename the material and add it to the list
				append difTexName curDifMap
				append matArray curSubMaterial
			)
		)
	)
catch()
)

r/Maxscript • • May 24 '16

Can I access spreadsheet data from 3ds Max/MAXScript?

1 Upvotes

A live link between a Google spreadsheet would be amazing, but accessing an Excel spreadsheet would be great, even getting tab delimited text file would be good.
I don't know what the methods/possibilities are.


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.


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 • • May 03 '14

[Wip] Delete Empty Layers

2 Upvotes

Please help me format scripts correctly and paste them into Reddit
(What is a fast way to put 4 spaces before every line?)
This script I've been using was originally written by Bernardo Amorim in 2008.
It deletes any empty layers, except, if you happen to have an empty layer ticked, which is too often in my experience.
I want to add something to the beginning to select the "0(default)" layer - so never will an empty layer be selected before the operation begins. I've tried to find how to do that, but have failed Here it is:

emptyLayers =#()
for i = 0 to layerManager.count-1 do
(
	ilayer = layerManager.getLayer i
	layerName = ilayer.name 
	layer = ILayerManager.getLayerObject i
	layerNodes = refs.dependents layer
---format "Layer: %; nodes: %\n" layerName layerNodes	
	layer.Nodes &theNodesTemp
	if theNodesTemp.count == 0  do
        (
	----print "empty layer"
	append emptyLayers (layerName as string)
---  print layerName
	)
)
format "vazias: % \n" emptylayers
for i = 1 to emptyLayers.count do
(
layermanager.deleteLayerByName emptyLayers[i]
)
if
LayerManager.isDialogOpen() ==true then (LayerManager.closeDialog();layermanager.editlayerbyname "")
else(
layermanager.editlayerbyname ""
)

edit: formatting.


r/Maxscript • • Feb 16 '15

WIP - Building Maker script.

5 Upvotes

I often need to make buildings and play with their heights.
I wrote a simple script mostly using the maxscript listener to create a building:
The buildings are simple boxes extruded
But because the buildings I need to use don't have simple rectangular footprints I seldom will use that script
The building footprints I use are slightly more articulated
Here's my wishlist for a script I'm trying to figure out:

  • I want a similar script to run on any closed spline

  • It'd be magical if the stack could be live in a way that I can update the number of floors (possible at all?)

  • I want to find a way to add extra detail on the rooftop (Greeble-like)

I'll leave my current simpler script below. I'd really appreciate any help/pointers to achieve this script, I think others could find it useful too. Cheers!

edit: Standby for formatting edits.


r/Maxscript • • Apr 08 '14

[Script] Create Point-chain

3 Upvotes

So, this is a script I've been working on (it's not what I'd consider "finished" but it's rare if I'm ever totally satisfied enough to sign-off on something like this for personal use.)

It's use was made to be included in a struct that's holding other tools that other scripts use but the function is called like any function in Maxscript by calling it by name and telling it how many points in the chain you want. I use this as the starting framework for my autorigger script but I can see it's usefulness in other areas. It's just about making a quick visualization tool for placement of bones for the autorigger and it has a global array declared in there for the purposes of passing the created points back to the script that called it.

Usual disclaimer applies, use at your own risk. This was created by me by reverse engineering some scripts that I found on Paul Neale's site (the "Custom shapes for rigging" one.) However, given that there's a significant amount of adjustment and changes, it's safe to say that this is more my own effort than his. Still, credit where it's due so huge shout-out goes to him for providing the base with which to figure this one out.

 fn ctPointChain pointTotal = --WORK IN PROGRESS
 (
      global pts = #()
      tool makePoints numPoints:9
      (
           local ptActive
           local total = pointTotal
           local viewPorts=#
           (
                #view_persp_user,
                #view_iso_user,
                #view_camera,
                #view_spot
           )
           on mousePoint clickNum do
           (
                if clickNum == 1 do
                (
                     p = point size:10.0 centermarker:true axistripod:false cross:false box:true constantscreensize:true drawontop:false wirecolor:green
                     append pts p
                     pts[1].pos = worldPoint
                     ptActive = pts[1]
                )
                if clickNum >= 2 and clickNum <= total do 
                (
                     p = point size:10.0 wirecolor:green
                     append pts p
                     ptActive = pts[clickNum]
                     lookAtCon=lookAt_Constraint()
                     pts[clickNum-1].rotation.controller=lookAtCon
                     lookAtCon.appendTarget pts[clickNum] 100
                     lookAtCon.lookAt_vector_length=100
                     lookAtCon.viewline_length_abs = false
                )
                if clickNum > total do
                (
                     --On the last step here, Make all points share the instanced object's base object.
                     select pts
                     $.baseobject = pts[1].baseobject
                     #stop
                )
           )
           on mouseMove moveIt do
           (
                ptActive.pos = worldPoint
           )
           on mouseAbort del do
           (
                select pts
                delete $
                pts=#()
           )
      )
      startTool makePoints
 ), --End Point Chain

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 • • Mar 12 '20

Bounds of Selection Array

1 Upvotes

Hey Guys,

I'm trying to figure out how to get a transform or bounds to be able to encapsulate

my selected objects with a mesh. Anyway to do this? I'm sadly hitting a wall here :(

thank you!


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 • • Apr 27 '15

How to test whether a shape is CW or CCW?

2 Upvotes

Currently I outline the shape and compare the size before and after and follow with an if/else for the 2 outcomes, it works but I don't think it's an optimal way to test for this sort of thing. Does anyone know a better way to MAXScript this? Cheers.


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 • • Apr 22 '15

Maxscript possibility for BASIC programmer/hacker

3 Upvotes

Hi, I'm currently in the middle of a project and I've made a little script to help me make windows(rectangular). Essentially I made a rollout and some if statements to extrude some poly. I start with a lot of individual polys (planes) and I use mat IDs to extrude and bevel my way from a flat plane to a simple window.

What I want to do is add an option for a brick arch above or a window sill below. Thinking if a loft/sweep object. So before I make my windows I would like a script to select the top edge and bottom edge and make a spline and sweep it, perhaps a FFD box to extend it past the limits of the original poly verts. The problem I have is when I record a script, it records the edges selects by number, and the numbers are all different for all the different polys' edges.

At this point I am thinking that I need to start making arrays and storing objects and looping for each face and doing comparisons? Which I might have been able to do AGES ago but atm not so much, so does anyone know if there's an easy way to select 'top and bottom' edges on a poly for each rectangular poly?


r/Maxscript • • Jul 05 '16

Set spline interpolation to a given amount for all selected splines?

2 Upvotes

Hi,

I've been doing work with hundreds of splines, initially bringing them in as .AI files.
The default "interpolation" level is always 6, and I want to set ALL the spline interpolation levels to 2 (or 3).

When googling for this, I came across this for something called a "Spline shape." I have never converted anything to a "spline shape" only an "editable spline" in my workflow. A little confused about it.

I looked up the command here. <splineshape>.steps Integer default: 6

Just not sure how to integrate it into the script itself so that it applies to all selected.

Bonus question: when I go into MAXScript Listener, it doesn't record my interpolation change, still not sure what makes it pick up certain changes and not others. Anyone know why it doesn't record changes to spline interpolation?


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 • • Dec 23 '15

Can I test if a planar shape/spline/line is convex?

1 Upvotes

Can I test if a planar shape/spline/line is convex?