[Closed] SDK: Function publishing actions not working
Following my failure to create an actiontable and actionitems for a plugin I’m developing, I’m now trying to achieve the same through the function publishing interface.
This worked fine for exposing functions to maxscript, but I’m running into problems with publishing actions. I’m following the SDK Help topic Function Publishing -> Action Interfaces almost to the letter:
Header file:
#pragma once
#include"iFnPub.h"
enum {
softenEdge,
};
class EdgeSmoothActions : public FPInterfaceDesc
{
public:
virtual FPStatus SoftenEdge() = 0;
};
Implementation:
#include "EdgeSmoothActions.h"
class EdgeSmoothActionsImp : public EdgeSmoothActions
{
public:
DECLARE_DESCRIPTOR(EdgeSmoothActionsImp)
BEGIN_FUNCTION_MAP
FN_ACTION(softenEdge, SoftenEdge)
END_FUNCTION_MAP
FPStatus SoftenEdge()
{
//....
return FPS_OK;
}
};
const Interface_ID EDGESMOOTH_INTERFACE = Interface_ID(0x21b10c92, 0x34063113);
static EdgeSmoothActionsImp esai(EDGESMOOTH_INTERFACE, _T("EdgeSmoothActions"), 0, 0, FP_ACTIONS,
softenEdge, _T("SoftenEdge"), 0, 0, end, end);
Two distinct differences from the help:
-EdgeSmoothActions extends FPInterfaceDesc, not FPInterface as in the help. Using the help version does not compile because the DECLARE_DESCRIPTOR macro uses a function from FPInterfaceDesc.
-Defining the interface_ID using a #define would not compile, so I’ve done it as a const instead.
Now, when I compile my plugin with this code, I get the following error when loading the plugin:
Error in FPInterfaceDesc definition.
Illegal function ID in block “EdgeSmoothActions”, function “
So from that I gather that the problem lies with the last line in the implementation, specifically with the function id softenEdge. But I don’t have a clue on why this is incorrect…
It’s been a few days since I hit this problem, and I haven’t been able to find a solution for it yet. If there’s anyone who has some idea of what could be going wrong, I would love to hear it!
have you looked at… maxsdk\howto\functionpublishing\simplefp ?
a couple of things spring to mind though, is not having the interface_ID in the public header going to be problematic ?
from the action function call examples …
EMActions* emai = GetEMActionsInterface(edmeshCD); //...
if (emai->IsCreateEnabled()) // direct calls
emai->Create();
where GetEMActionsInterface is defined in the public header files as
#define EM_ACT_INTERFACE Interface_ID(0x65678, 0x123)
#define GetEMActionsInterface(cd) \
(EMActions*)(cd)->[GetFPInterface]( http://forums.cgsociety.org/ms-its:3dsmaxsdkref.chm::/ifnpub_8h.html#a1206)(EM_ACT_INTERFACE)
so i’d probably start looking at why it doesn’t compile as per the help example.
Yep. I should maybe clarify that publishing functions to FP_CORE is working fine. Publishing action interfaces (FP_ACTIONS) is causing the problem.
In the fp_basic howto they handle the interface id like this:
//fp_basic.h
extern const Interface_ID FP_BASIC_INTERFACE;
//fp_basic.cpp
const Interface_ID FP_BASIC_INTERFACE(0x7d0c759f, 0x7714b4b);
I’m now trying to take all the code from fp_basic and modifying that to make a new plugin, to see if that works. That’s going to keep me busy for a while though…tons and tons of junk-code to wade through. 🙁
ah, they still have it as a #define in the 2010 sdk, if it were me i would take the fp_basic example and see if it could be made to work as an Action Interface, though i am a little confused to the exact usefulness of this way of doing things (assuming that you are making a self contained system ?). I can understand publish functions to maxscript or other plugins but “These interfaces only contain UI Action Functions that provide a programmatic way of “pressing” buttons and keys in the UI for a plug-in”. has got me flummoxed.
ah, they still have it as a #define in the 2010 sdk
Ah that’s interesting, I am actually compiling for 2010, but I was looking at the 2012 howto.
I can understand publish functions to maxscript or other plugins but “These interfaces only contain UI Action Functions that provide a programmatic way of “pressing” buttons and keys in the UI for a plug-in”. has got me flummoxed.
What I basically want is to do in a plugin what I would normally do in a macroscript if I were using maxscript. I guess ActionTables are the default way of doing this, but I got stuck in there too. So I thought I’d try it this way. Moreover because I was already using this to expose some additional functions to mxs.
So, I had the following working with ‘regular’ function publishing, with a modified fp_basic code to start from. This works fine:
class IEdgeSmooth : public FPStaticInterface
{
public:
virtual void Test() = 0;
enum {
em_test,
};
};
class IEdgeSmoothImpl : public IEdgeSmooth
{
public:
void Test();
DECLARE_DESCRIPTOR_INIT(IEdgeSmoothImpl)
BEGIN_FUNCTION_MAP
VFN_0(IEdgeSmooth::em_test, Test)
END_FUNCTION_MAP
};
And the implementation:
IEdgeSmoothImpl edgesmooth_desc(
EDGESMOOTH_INTERFACE, //Interface_ID
_T("edgesmooth"), //Internal Fixed Name
IDS_CLASS_NAME, //localized string resource ID
&edgeSmoothDesc, //owning class descriptor
FP_CORE, //Flags
//Functions -------------------------
IEdgeSmooth::em_test, _T("Test"), 0, TYPE_VOID, 0, 0,
end
);
void IEdgeSmoothImpl::init() { }
void IEdgeSmoothImpl::Test() { DebugPrint(_T("Test
")); }
Then, try to make that into an actions interface:
//Changed the function mapping macro
BEGIN_FUNCTION_MAP
FN_ACTION(IEdgeSmooth::em_test, Test)
END_FUNCTION_MAP
IEdgeSmoothImpl edgesmooth_desc(
//......//
FP_ACTIONS, //Flags
//Functions -------------------------
IEdgeSmooth::em_test, _T("Test"), 0, 0,
end
}
//Changed return type to FPStatus
FPStatus IEdgeSmoothImpl::Test()
{
DebugPrint(_T("Test
"));
return FPS_OK;
}
Result: compiles ok, but when loading the plugin:
Error in FPInterfaceDesc definition. Illegal function ID in block “edgesmooth”, function “
(And it ends there, with a quote-character…)
you could try adding a resource string ID to the function desc as per the help
ema_create, _T("create"), IDS_CREATE, 0,
the IDS_CREATE in this case. and add the string to the build
Yep tried that, to no avail. Also tried doing the more elaborate stuff in there, since it might be required, but with the same result as before.
don’t know if it will help but
maxsdk\samples\gup\pluginmanager
has some Action stuff in it