Notifications
Clear all

[Closed] SDK: convert bitmap to value?

I’m trying to write a .dlx plugin that generates a bitmap and returns it in the plugin’s maxscript function.

I know how to generate the bitmap with the SDK, but I’m unable to return it in a function. Unfortunately I know very little about c++ (I’ve got the basic plugin setup and working, I’m just having a hell of a time figuring out how to get the bitmap return functionality working), and I’m stuck at trying to convert the bitmap to a value, since the maxscript function created by the .dlx seems to require a “value” to be returned in the c++ code, so all other types must be converted to values first before being returned.

I also read something about a MAXBitmap class that I should be possibly using instead? But I’m not sure…helpful tutorials and resources for the SDK are few and far between, and the SDK docs are a bit too technical for me in places.

Has anyone dealt with this before?

5 Replies

It might be worthwhile to check out the Function Publishing interface, since that handles a lot of the conversions for you. http://area.autodesk.com/blogs/chris/adding_new_functions_written_in_c_to_maxscript
I haven’t dealt with bitmaps in the SDK myself, so I’m not 100% sure this covers them too, but it’s worth a shot.

This is kind of a blindflight, because last time i worked with the SDK is 2 month ago, and it’s quirky ways of doing things fade away really quick…

Here’s my thoughts directly out of my brain, so no guarantees that this is correct

  • If you have a Bitmap already, you use the MAXBitmap – Wrapper to create a Value from it. Just look in “maxscript\maxwrapper\bitmaps.h” to see what the class does and provides
    The constructor if you have a Bitmap already looks like that:
MAXBitMap (BitmapInfo bi, Bitmap* bm);
  • the Value you created above is on the heap, thus it’s potential victim to the maxscript garbage collector. You have to protect it in your plugin code, thus you have to use the “return_value()” macro to return it back to maxscript from your plugin code. Just look under “Local Variables in MAXScript Exposed Functions” in the SDK docs

An alternative would be using the “Function Publishing” algorithm as Pier has mentioned. But that is a different beast and you would have to learn again and rewrite much of your existing code. It’s the more future proof way though. Generating *.dlx plugins seems to be discouraged by Autodesk now …

Thanks for your help spacefrog, for now I think that points me in the right direction.

As for Function Publishing, I’m using max 2011 so I don’t think I have access to that to begin with…

1 Reply
(@pjanssen)
Joined: 1 year ago

Posts: 0

I think it has been introduced in max4 or 5. A long time ago anyway.

Oh! I’ll look into it then.