Python + MXS


#295

Hi,
I am trying the Py3dsMax python tool.
I took this max script exemple and try to convert it in python.


        macroScript QuickPreview category:"HowTo"
    
    (
     preview_name = (getDir #preview)+"/quickpreview.avi"
     view_size = getViewSize()
     anim_bmp = bitmap view_size.x view_size.y filename:preview_name
      for t = animationrange.start to animationrange.end do
     (
      sliderTime = t
      dib = gw.getViewportDib()
      copy dib anim_bmp
      save anim_bmp
     )
     close anim_bmp
     gc()
     ramplayer preview_name ""
     )
        

I can’t translate these commands

 anim_bmp = bitmap view_size.x view_size.y filename:preview_name
copy dib anim_bmp
save anim_bmp

in a pythonic syntax.

Does anybody have an idea or some code example for Py3dsMax?

Thanks lucas


#296

Most things are accessible via the mxs module, so you should be able to write that code as:

Maxscript:

anim_bmp = bitmap view_size.x view_size.y filename:preview_name
copy dib anim_bmp
save anim_bmp

Python:

anim_bmp = mxs.bitmap( view_size.x, view_size.y, filename = preview_name )
mxs.copy( anim_bmp )
mxs.save( anim_bmp )

I haven’t actually tested that, but that SHOULD work.


#297

My question is basically as it reads in the title. I’m switching from just Maxscript to Python and Maxscript since I understand Python much more. My question is whether or not the built in object sets and arrays like “objects” or “geometry” are still accessible, and if so, what changes in how they are called? Thanks. You guys are very helpful with trying to figure out MaxScript.


#298

Hi all! There is little question:
I need rotate in XForm gizmo. But I can not do that, tell me what the problem is and how to rotate it? Thank you for your attention.

from Py3dsMax import mxs

for obj in mxs.objects:
     XForm = mxs.pyhelper.namify('XForm') #  set flag
     obj.modifiers[XForm].gizmo.rotation += mxs.quat(0.707107, 0, 0, 0.707107) #  rotate 90"

#299

I solved the problem though not completely in Python. I would like to make it completely in Python.

mxs.addModifier(obj, mxs.XForm())
XForm = mxs.pyhelper.namify('XForm') #  set flag
mxs.execute('max modify mode')
mxs.modPanel.setCurrentObject(obj.modifiers[XForm])
mxs.execute('mod_obj = modPanel.getCurrentObject();gizmo_rotation = mod_obj.gizmo.rotation;mod_obj.gizmo.rotation += quat 0.707107 0 0 0.707107') #  rotate 90"



#300

Thanks for the great work Eric. :beer:

Any news on a max 2013 compile?


#301

Hi, i found a bug inside Py3dsMax, when i hide a Dialog/Window or Max Window the Dialog disapears and I can’t call it back as if it had been closed.

Here is an exemple of a code wich gives me problems:

class window(blurdev.gui.Window):
def init( self, parent = None ):
super(window, self).init(parent)
self.setWindowTitle(‘Windowtest’)
win = window()
win.show()

Could you please help me solving this problem ? :slight_smile:


#302

Hi, i found a bug inside Py3dsMax, when i hide a Dialog/Window or Max Window the Dialog disapears and I can’t call it back as if it had been closed.

Here is an exemple of a code wich gives me problems:

class window(blurdev.gui.Window):
def init( self, parent = None ):
super(window, self).init(parent)
self.setWindowTitle(‘Windowtest’)
win = window()
win.show()

Could you please help me solving this problem ? :slight_smile:


#303

Is it possible to get a 2013 build up there?


#304

Same problem as col-one. The dialog disappears when 3ds Max is minimized.
This is some sample code from the blur help pages (http://code.google.com/p/blur-dev/wiki/PyQt):


  from blurdev.gui import Dialog
  
  class HelloWorldDialog(Dialog):
      def __init__( self, parent = None ):
          Dialog.__init__( self, parent )
          
          self.setWindowTitle('Hello, World')
  
  import blurdev
  blurdev.launch(HelloWorldDialog)
  

How do I prevent the dialog from disappearing? Please anyone…


#305

What is the current state of python in 3ds max?

judging form this thread and others it looks like interest has waned , and blur has stopped supporting py3dsmax for more recent version of max.

Is anyone using python in 3dsmax 2013 or 2014?
Or has python died in 3dsmax?


#306

http://labs.autodesk.com/utilities/sciviz

Project Sci-Viz provides a Python engine and API for 3ds Max that enable Max users to run ePMV and autoPack from within 3ds Max 2013. The Sci-Viz plug-in is available only for 3ds Max 2013 64-bit and requires a 64-bit version of Python 2.6.6.


#307

Hi there !

     For reply to my post and solve the probleme about disapear qt window, we found the solution.
     
     After spent lot of time to read the already existing blur script, we found something:
     
     We must use our own migrate Qt max window, for do this we need import QtWinMigrate from classic PyQt and GetWindowHandle from Py3dsMax. Here an example:

  from PyQt4 import QtGui, QtCore, QtWinMigrate
  from Py3dsMax import GetWindowHandle
  
  class window(QtGui.QMainWindow):
  	def __init__ (self, parent= QtWinMigrate.QWinWidget(GetWindowHandle())):
  		super(window, self).__init__(parent)
  		self.setWindowIcon(QtGui.QIcon(iconPath))
  		self.setWindowTitle( 'maxWindow' )
 
 class testWin(window):
 	def __init__(self, parent = None):
 		super(testWin, self).__init__(parent)
 		self.setWindowTitle('testQtmaxWindow')
 
 win = testWin()
 win.show()
    

#308

thanks for your post col-one, it is working for me. However there are other solutions, which confuse me. It seems that simply adding this:


  self.setAttribute(QtCore.Qt.WA_DeleteOnClose, False)
  

somewhere in the constructor of my Dialog/Window/Whatever prevents it from disappearing when 3ds Max is minimized. I found this comment in the treegruntdialog.py that states the same:


 # protect the memory
  from PyQt4.QtCore import Qt
  inst.setAttribute(Qt.WA_DeleteOnClose, False)
  

Can anyone try and verify?


#309

I’ve compiled PyZmq and P4Python for Max and Maya 2015.

You can get them here: https://github.com/arturleao/YCDIVFX_MaxPlus in the Externals folder.


#310

hi am new for python and its integration into max
am just trying to deal with
I started with binding sip for max and installing PYQT
but its seam that am doing something wrong because i get a fetal error massage in my command prompt
so i want to ask

  • do s i have to change the python version from 2.7 to 3 ?
  • dos it effect the max bridge if i installed other version of the python on same machine ?
  • installing the pyqt must be in the max python folder or into the main folder (( C:\python27 for example)) ?
    thanks in advance

#311

You shouldn’t have to do any of this.

For example, 3dsmax 2015 is provided with python 2.7 (c:\program files\autodesk\3dsmax 2015\python).

Then for using Qt, it would start with :

from PySide import QtGui

Check the help file, section “using pyside”

You speak about a command line prompt error, be more precise on what you’re trying to do.


#312

ok
I did installed PYQT 4.8.6 64 bit
to the python folder site package
with insuring that i had the right registry keys as christopher said at this :
https://area.autodesk.com/blogs/chris/pyqt-ui-in-3ds-max-2014-extension
and when I executed the demoPyVersionTool.py
I get this result

3ds Max 2014 path environment variable C:\Program Files\Autodesk\3ds Max 2014;C:\Program Files\Autodesk\3ds Max 2014\python\Lib\site-packages;C:\Program Files\Python;C:\Program Files\Python\Lib\site-packages;C:\Program Files\Python\Lib\site-packages\PyQt5;
MaxPlus module False
PyQt QT version 4.8.6
PyQt module True
PyQt version 4.11.2
PySide module False
Python prefix C:\Program Files\Autodesk\3ds Max 2014\python
Python version 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)]
os module True
sys module True
#success

thanks MrPingouin ur pointing was helpfull


#313

Hey,

Im new at 3dsmax but i have several python projects running.
I think about to get the camera position and export it with python.

I would like to get something like this:
30,30,30
25,30,30
20,30,30

Each line on frame.

I read a lot at the APi-Page and looked into pythondemos, but I
only find demos that are creating objects.

the camera is in the scene and this is moving.

Starting python with the mxscript is working, but
how to I get the camera and how do I get the position
of it to write it down into a file.

for loop:

  • Get Camera.Position
  • Set next frame

Thanks a lot!


#314

Hi everyone

I was wondering if one could access the rollout control or an equivalent within pyside in max 2017 ?

Thanks