[Closed] Print some text with sdk
With plugin wizard, I’ve created a new utility.
Following the docs I’ve added this line, to the BeginEditParams function
ip->PushPrompt(_M("Hello World from Lesson 1. Called from BeginEditParams()"));
Vs2012 Express compiles, fires max, but I can’t see the text anywhere. Where am I supposed to see that? Am I doing something wrong?
That should work fine did you call the GetCOREInterface before
ip = GetCOREInterface();
ip->PushPrompt(_M("Hello World from Lesson 1. Called from BeginEditParams()"));
prompt stack is below the time slider, and if ip wasn’t a valid interface pointer it would crash so no need for the GetCOREInterface() call
you can output to the listener using
#include "maxscrpt/maxscrpt.h"
or
#include "maxscript/maxscript.h"
depending on version
then
mprintf(.....)
mflush();
I’ve tried each of these lines, in the BeginEditParams function:
MessageBox(NULL, _T("TEST"), _T("Test test 123"), MB_OK);
ExecuteMAXScriptScript(_T("print \"hello c++\""), 0, 0);
ip->PushPrompt(_M("Hello World from Lesson 1. Called from BeginEditParams()"));
And I’ve read step by step the learning path but still nothing happens. There must be something I’m doing wrong. I have absolutely no idea about what.
here is a basic utility plugin that will help you get started… It will give you a small ui window with one button and you can open that through the Utility panel or you can type IGeo.openDialog() in the maxscript listener to use the Function publishing to open the UI.
/////////////////////////////////////////////////////////////////////////////////
// SpringBoard.h
/////////////////////////////////////////////////////////////////////////////////
#include "resource.h"
#include <istdplug.h>
#include <iparamb2.h>
#include <iparamm2.h>
#include <maxtypes.h>
#include <utilapi.h>
#include "maxscript\maxscript.h"
#include "windowsx.h"
#define STRING2(x) #x
#define STRING(x) STRING2(x)
#define TODO(x) __FILE__ "(" STRING(__LINE__) "): TODO: "x
extern TCHAR *GetString(int id);
extern HINSTANCE hInstance;
#define Springboard_CLASS_ID Class_ID(0x5fdc1e14, 0x55039d83)
/////////////////////////////////////////////////////////////////////////////////
// SpringBoard Class
/////////////////////////////////////////////////////////////////////////////////
class Springboard : public UtilityObj, public FPStaticInterface{
public:
#define Springboard_INTERFACE Interface_ID(0x5fdc1e14, 0x55039d83)
DECLARE_DESCRIPTOR(Springboard);
enum functionID { kOpenDialog};
BEGIN_FUNCTION_MAP
VFN_0(kOpenDialog, OpenDialog)
END_FUNCTION_MAP
virtual ~Springboard() {}
virtual void DeleteThis() {}
virtual void SayHello();
virtual void BeginEditParams(Interface *ip,IUtil *iu);
virtual void EndEditParams(Interface *ip,IUtil *iu);
void OpenDialog();
static bool IsDialogShowing() { return dialogShowing; }
static void SetDialogShowing(bool val) { dialogShowing = val; GetCUIFrameMgr()->SetMacroButtonStates(false); }
static Springboard* GetInstance() { static Springboard theSpringboard; return &theSpringboard; }
private:
static bool dialogShowing;
static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
HWND hDlg;
IUtil* iu;
Interface* ip;
};
class SpringboardClassDesc : public ClassDesc2 {
public:
virtual int IsPublic() { return TRUE; }
virtual void* Create(BOOL) { return Springboard::GetInstance(); }
virtual const TCHAR * ClassName() { return GetString(IDS_CLASS_NAME); }
virtual SClass_ID SuperClassID() { return UTILITY_CLASS_ID; }
virtual Class_ID ClassID() { return Springboard_CLASS_ID; }
virtual const TCHAR* Category() { return GetString(IDS_CATEGORY); }
virtual const TCHAR* InternalName() { return _T("Make Geo"); } // returns fixed parsable name (scripter-visible name)
virtual HINSTANCE HInstance() { return hInstance; } // returns owning module handle
};
here is the .cpp file
/////////////////////////////////////////////////////////////////////////////////
// SpringBoard.cpp
/////////////////////////////////////////////////////////////////////////////////
#include "Springboard.h"
static Springboard theSpringboard(Springboard_INTERFACE, _T("IGeo"), -1, 0, FP_CORE, Springboard::kOpenDialog, _T("openDialog"), -1, TYPE_VOID, FP_NO_REDRAW, 0, ParamTags::p_end);
ClassDesc2* GetSpringboardDesc() {
static SpringboardClassDesc SpringboardDesc;
return &SpringboardDesc;
}
/////////////////////////////////////////////////////////////////////////////////
// SpringBoard Class Functions
/////////////////////////////////////////////////////////////////////////////////
void Springboard::BeginEditParams(Interface* ip,IUtil* iu) {
OpenDialog();
}
void Springboard::EndEditParams(Interface* ip,IUtil* iu){
this->iu = nullptr;
hDlg = nullptr;
}
void Springboard::OpenDialog(){
EndDialog(hDlg, FALSE);
hDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_SPRINGBOARD),GetCOREInterface()->GetMAXHWnd() , DlgProc);
}
void Springboard::SayHello(){
MessageBox(NULL, _T("Hello"), _T("Debug Message"), MB_OK); //Debuging
ExecuteMAXScriptScript(_T("print \"hello c++\""), 0, 0);
int Test = 5;
MCHAR Debug[256];
swprintf(Debug, _T(" Hello Test = %i
"), Test);
mprintf(Debug);
mflush();
}
/////////////////////////////////////////////////////////////////////////////////
// SpringBoard 3dsMax Callback
/////////////////////////////////////////////////////////////////////////////////
INT_PTR CALLBACK Springboard::DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam){
switch (msg) {
case WM_INITDIALOG:
CenterWindow(hDlg, GetParent(hDlg));
break;
case WM_DESTROY:
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDC_SAYHELLO: /// The ID of your button
theSpringboard.SayHello();
break;
case IDCANCEL:
EndDialog(hDlg, FALSE);
break;
}
break;
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MOUSEMOVE:
break;
default:
return 0;
}
return 1;
Here is the .rc file for the UI with one button
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_SPRINGBOARD DIALOGEX 0, 0, 77, 42
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Hello"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
PUSHBUTTON "Say Hello",IDC_SAYHELLO,7,19,60,13
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_SPRINGBOARD, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 69
TOPMARGIN, 7
BOTTOMMARGIN, 35
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""
"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_CATEGORY "Testing"
IDS_CLASS_NAME "Hello"
IDS_PARAMS "Parameters"
IDS_SPIN "Spin"
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (United Kingdom) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
3 TEXTINCLUDE
BEGIN
"
"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (United Kingdom) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
I hope this helps you
oh sorry here is the resource.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Springboard.rc
//
#define IDD_SPRINGBOARD 1
#define IDS_LIBDESCRIPTION 1
#define IDS_CATEGORY 2
#define IDS_CLASS_NAME 3
#define IDC_SAYHELLO 3
#define IDS_PARAMS 4
#define IDS_SPIN 5
#define IDC_MAKELINE 6
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1011
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
AngryBear,
I know this post is super old but hopefully you see this questions or someone else.
I was just looking for an example for a modelless utility dialog so your example its exactly what I need, but now I’m trying to make it work with QT, Do you have any idea if that’s possible ?
Thanks,
Guillermo