Hi polycounters,
More or less my setup for 3ds max 2017 with python is:
Visual studio Code (with python, MaxScript plugins and MXSPyCOM connects to 3ds Max)
Pyside 1.2.2
Qt 4.8.5 (With QtDesigner)
Actually create a python script ( based on Drew Avis in Max Docs) with simple things, yesterday works more or less by now when I evaluate the script appear this errors:
Later I don't get to understand because inside on Def "buttonClicked" doesn't show me the QMessagebox
.
Here the code:
<div>import os, MaxPlus
from PySide import QtCore, QtGui
fname = os.path.join(os.path.abspath(os.path.curdir), "my_ui.ui")
ui_type, base_type = MaxPlus.LoadUiType(fname)
print ui_type
print base_type
def buttonClicked():
""" When you push this button, create spheres with the same name and clear and text again in TextEditor "Hellooo!!" """
print "pushButton clicked"
# create a sphere node
node_name = "my_sphere"
obj = MaxPlus.Factory.CreateGeomObject(MaxPlus.ClassIds.Sphere)
node = MaxPlus.Factory.CreateNode(obj, node_name)
MaxPlus.ViewportManager_RedrawViewportsNow(0)# after create the node or other operations its better to refresh de viewports
print node.GetName()
# create a Messagebox, with the following Title [Spehere created!]
msgbox = QtGui.QMessageBox()
msgbox.setWindowTitle(u'Spehere created!')
msgbox.exec_()
def printDate(datetime):
print datetime.toString()
class MyWidget(base_type, ui_type):
def __init__(self, parent = None):
base_type.__init__(self)
ui_type.__init__(self)
self.setupUi(self)
MaxPlus.AttachQWidgetToMax(self)
pb = self.pushButton
pb.clicked.connect(buttonClicked)
self.dateTimeEdit.dateChanged[QtCore.QDate].connect(printDate)
form = MyWidget()
form.show()</div>
thanks for all guys!
Replies
thanks!! ^^
The code you're using to build the path is probably incorrect, os.path.curdir is referring to the working directory (3ds executable Path), not the user scripts folder.
A Google search tells that the MaxPlus module has a class for getting paths, including the user scripts folder. Just append 'Espi' to it:
http://help.autodesk.com/cloudhelp/2017/ENU/Max-Python-API/py_ref/class_max_plus_1_1_path_manager.html#a186e80376821d7e5367adb98190845dd
But, it`s weird, because I've created other .py file into the same path ("C:\Users\sergio.espinosa\AppData\Local\Autodesk\3dsMax\2017 - 64bit\ENU\scripts\Espi") and execute perfectly the same .ui file. Maybe 3ds Max need to reset the "os.path.curdir" or another familiar variable of this?.
I try this because i think this way i could create the scripts ( .py and .ui files) wherever i want without to rewrite the path into the code.
Later you can revaluate all times that you want through Visual studio code or 3ds Max editor
i have some troubles with Qt Designer and 3ds Max about the icons.
In Qt Designer i got load the icon(in editor and preview modes):
Here the parameters:
But in 3ds max no:
the icon is into subfolder (UI/icons/folder-icon.png)
I tried to save the icon into 3ds max folder "usericons".
any ideas?
I just remember icons didn't work in 2017, but they work in 2018.
In either case, you should consider updating to 2018 or 2019. They removed PySide and replaced it with PySide2, and 2017 was the first version with pysideuic. So any tool you make the UI will be bound to only one version of max.
I'm trying to import a custom Python Module (CarVerifierRules.py) but when i evaluate the main.py, show me this error:
into main.py put this:
CarRules.getMissingObjects() #(here show the error)
#CODEBLOCK
#CODEBLOCK
#CODEBLOCK
This code works perfectly, the problem is when i want to import this custom module into the main.py