python set preferences values

python set preferences values

haggi
Enthusiast Enthusiast
1,711 Views
10 Replies
Message 1 of 11

python set preferences values

haggi
Enthusiast
Enthusiast

Hi,

 

I'd like to set some scene preferences with python. e.g. turing autobackup on, setting the path for autobackup (if this is possible) and the name for autobackup, turing on compress on save and so on. Is this possible and if yes, how?

 

And I need a way to list all missing external files with python.

 

I aprecciate any help. Thanks.

 

0 Likes
Accepted solutions (1)
1,712 Views
10 Replies
Replies (10)
Message 2 of 11

drew_avis
Autodesk
Autodesk
Accepted solution

Hi, it doesn't look like MaxPlus exposes this functionality directly.  You can get to the autosave settings via the MAXScript autosave interface through pymxs.  See http://help.autodesk.com/view/3DSMAX/2017/ENU/?guid=__files_GUID_B5405D51_E4D7_4448_9588_8D06B873578...

 

For example:

from pymxs import runtime as rt
autosave = rt.autosave
print "Autosave enabled? {}".format(autosave.enable)
print "Autosave filename: {}".format(autosave.filename)


Drew Avis
Content Experience Designer
0 Likes
Message 3 of 11

haggi_master
Advocate
Advocate

Very cool, thanks a lot. This will help. And a very similiar question:

 

I've tried to set the "Reference Coordinate System" in the toolbar to "World". With maxscript it works fine:

 

toolMode.coordsys #world

 

but the same in python:

 

pymxs.runtime.toolMode.coordsys("#world")

causes an error:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
RuntimeError: MAXScript exception rasied.
-- Runtime error: Illegal coordsys mode type: "#world"

 

Any ideas?

 

 

0 Likes
Message 4 of 11

drew_avis
Autodesk
Autodesk

You just need to cast the MAXScript name value as a pymxs.runtime.Name:

 

pymxs.runtime.toolMode.coordsys(pymxs.runtime.Name("world"))


Drew Avis
Content Experience Designer
0 Likes
Message 5 of 11

haggi_master
Advocate
Advocate

Great thanks a lot, I'll try it.

0 Likes
Message 6 of 11

haggi_master
Advocate
Advocate

Works fine, great. Now I can set the toolMode.coordsys, but how can I query it? A simple:

 

cs = rt.toolMode.coordsys()

 

results in an error message, it needs an argument. Any ideas?

0 Likes
Message 7 of 11

drew_avis
Autodesk
Autodesk

Try:

cs = pymxs.runtime.getRefCoordSys()

toolmode.coordsys() only sets the value.

 

Drew



Drew Avis
Content Experience Designer
0 Likes
Message 8 of 11

Anonymous
Not applicable

Is there a way through pymxs to use the coordsys on a node and apply a transform?

0 Likes
Message 9 of 11

drew_avis
Autodesk
Autodesk

Pymxs does not expose the "in coordsys" context expression, but transforms on the node should be in the node's local coordsys.  Here's a simple rotate on a box:

 

from pymxs import runtime as rt

b = rt.box()
a = rt.angleaxis(20.0, rt.Point3(0,0,1))
rt.rotate (b, a)

 This will produce the same result no matter what the toolMode setting is.

 

Does that answer your question?

 

Drew



Drew Avis
Content Experience Designer
0 Likes
Message 10 of 11

Anonymous
Not applicable

I wish that was an option the only way I can zero out the parent coodsys is using an eval. Was hoping to do achieve the same thing using pymxs.

 

MaxPlus.Core.EvalMAXScript("coordsys parent $'%s'.pos = Point3 0 0 0" % node_name)
MaxPlus.Core.EvalMAXScript("coordsys parent $'%s'.rotation = Quat 0 0 0 1" % node_name
0 Likes
Message 11 of 11

michaelsonbritt
Advocate
Advocate

In PyMXS, any MaxScript constant value, starting with a # character, is considered a pymxs.runtime.Name object, which is constructed from a string without the # character.  Specifically:

 

import pymxs
mxs = pymxs.runtime
mxs.toolMode.coordsys( mxs.Name( "world" )  )

 

 

A little late to the party here, but in case anybody else stumbles on this ...

 

Michaelson Britt

0 Likes