[Closed] SDK Maxscript Extention help
I’ve only just started looking into the sdk for work and i’m currently following the tutorial ‘How to write a basic MAXScript Plugin’. We use max 8 and visual studio 2005 8.0.
I’ve managed to sort out all of the many many typos in the first part of the tutorial under ‘Preparing DLLMain.cpp (Plugin Entry Point):’ and now i’m stuck with one last error in ‘sceneio.h’ that says:
error C2664: ‘DebugPrint’ : cannot convert parameter 1 from ‘const char [42]’ to ‘const TCHAR *’
class ValueLoadPLCB : public PostLoadCallback
{
public:
void proc(ILoad *iload)
{
for (int i = 0; i < value_loaders.Count(); i++)
value_loaders[i]->call_back();
value_loaders.ZeroCount();
delete this;
#ifdef _DEBUG
if (dump_load_postload_callback_order)
DebugPrint("MXS: PostLoadCallback run: ValueLoadPLCB
");
#endif
}
};
The problem is with the DebugPrint line in the above function taken from ‘sceneio.h’
I have searched the forums and discovered that it is not recommended by autodesk to use vs2005 to make plugins for max 8 however it’s what we have at work so i need a work around.
Commenting out that line is less than ideal but leads to the next problem – An error for the IntervalArray.def file…
error LNK2001: unresolved external symbol LibDescription
The same error for ‘LibInit’ was caused by a typo of ‘LibInt’, which is fixed now, but I have checked and double checked and had other people check the spelling of LibDescription and its fine so i’m not sure what would be causing the new error…
Any help on both problems would be greatly appreciated
Sorry, i have no solution for your plugin, because yesterday was the first day, i started reading in the SDK. Because i like to try to write a simple plugin for MAX – and you’re writing, that you have a good tutorial – can you give me the link please?
I’ve compiled some plugins for Max 8 with Visual Studio 2005 but never had no such error (maybe because I never compiled the plugin you try to build). Which version of Visual Studio 2005 are you using ? Express, Standard, Pro ?
OK, regarding the DebugPrint, you’re getting the error probably because you’re passing an ANSI string, but building in with UNICODE defined. You need to enclose the string literal in the _T(“Blah”) macro to have it properly expand to either L”Blah” or “Blah” depending on UNICODE being #defined.
LinInit and LibDescription should be defined as they are required DLL exports for the 3ds max plugin. They should probably be part of your DLLMain.cpp (but really can be anywhere).
EDIT: Could you post the code for the LibDescription if you say you have it defined?
Also, it shouldn’t matter in the slightest whether you are building with the Express/Std/Pro versions as the compiler is the same.
hey guys, firstly i’m using vs 2005 pro and i’ve also installed service pack 1.
[b]iLegacy:[/b] I am just following the tutorial that is in the max sdk documentation
[b]scorpion007:[/b] thanks for the info about the DebugPrint issue. I ended up figuring that one out on my own. The problem still remains though with the LibDescription. I'm home from work now and I've just tried it here with the same setup and i'm gettin the same problem. The whole DLLMain.cpp is as follows:
//DLLMain.cpp
#include "maxscrpt.h"
HINSTANCE hInstance;
extern void IntervalArrayInit ();
// ========================================================
// Grab onto this DLL's instance handle
BOOL WINAPI DllMain(HINSTANCE DLLhinst, DWORD fdwReason, LPVOID lpvReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
hInstance = DLLhinst;
break;
}
return TRUE;
}
__declspec(dllexport) void LibInit()
{
//TODO: Put any code for initializing your plugin here.
//In this case it is IntervalArrayInit(), which will be defined in IntervalArray.cpp,
//However in this example IntervalArrayInit() is empty.
IntervalArrayInit();
}
__declspec(dllexport) const TCHAR* LibDescription()
{
//TODO: Put code in here telling what your plugin does.
return _T("Interval Array Function");
}
__declspec(dllexport) ULONG LibVersion()
{
//Return the version of the Max SDK
return VERSION_3DSMAX;
}
and the module def ‘intervalarray.def’ file is like this:
LIBRARY IntervalArray
EXPORTS
LibDescription @1
LibInit @2
LibVersion @3
SECTIONS
.data READ WRITE
and so far intervalarray.cpp looks like this:
#include "MAXScrpt.h"
#include "Numbers.h" // for handling of maxscript Integers and Floats
#include "Arrays.h" // for returning a maxscript array
void IntervalArrayInit()
{
//Todo: Place initialization code here. This gets called when Maxscript goes live
//during max startup.
}
That’s the whole project so far! Hopefully you’ll be able to see something i’m missing.
ypuech: i found another thread where you posted about fixing 2 of the header files where ‘i’ is out of scope. Thanks – I have done so and that allowed me to follow and successfully complete the tutorial ‘How to Write a Geometric Object’. I had scoure the internet to find a way to get the wizard to work mind you.
For a maxscript extention plugin though, according to the tutorial, you just start with a blank dll project and dont use the wizard to set up anything.
I have posted all the code needed to replicate the error. If you guys or anyone can be of further help that would be great.
What can I say? Works for me.
I think you have some old .obj’s lying around, do a clean rebuild.
(BTW, I changed the includes to be correct, E.g.:
#include <maxscrpt/MAXScrpt.h>
#include <maxscrpt/Numbers.h> // for handling of maxscript Integers and Floats
#include <maxscrpt/Arrays.h> // for returning a maxscript array
I also added the _T(“”) in that header file (sceneio.h), bad practise, I know.
BTW, for the for loop scoping, I would suggest against hacking all the sdk headers and instead set your max8 plugin project to use the non-standard for-loop scoping (VC6 style) in C/C+±>Language->Force conformance in for loop to ‘No’.
Of course this is not standard C++, but neither is the max sdk. If/when you target max9, you don’t need to do this. But it’s better than hacking header files.
)
Thanks for the speedy reply. The includes didnt need to be changed (for me) since i added the include/maxscrpt directory aswell. I changed the header files back to the way they were and switched that option in the project settings like you suggested but nothing has changed. I’m still getting the error…
Maybe there’s something I havn’t configered that i may have overlooked in the sdk help but I seriously have read it so many times its hard to believe that would be the case.
Out of curiosity, did your type intervalarray.def as your module definition file in the project properties under linker -> input ? Because I found that i can successfully build when i take that out, but the tutorial states that I must have it there
Ah, heh. Oops. Sorry about that, I forgot to add it to the linker settings.
But still, I added it, it still works.
I can only think that you have old .obj’s lying around. Did you try a clean rebuild?