Skip to main content
Known Participant
December 23, 2023
Question

[SDK] Create hybrid plugin that includes kModelPlugin and kUIPlugIn

  • December 23, 2023
  • 3 replies
  • 550 views

I want to create a plugin that has some panel where user enters some input, according to that input model side of the plugin decides whether or not provide a service. I have one custom singleton class which provides a service for a model plugin, with UI side of the plugin I want to access that class instance and change some of its variables which serve as a flag: on/off

 

I've tried defining the PluginVersion resource in .fr file like this: (including both kModelPlugin and kUIPlugin)

resource PluginVersion (kSDKDefPluginVersionResourceID)
{
	kTargetVersion,
	kMyPluginID,
	kSDKDefPlugInMajorVersionNumber, kSDKDefPlugInMinorVersionNumber, 	
	kSDKDefHostMajorVersionNumber, kSDKDefHostMinorVersionNumber,
	kCHLCurrentMajorFormatNumber, kCHLCurrentMinorFormatNumber,
	{ kInDesignProduct, kInDesignServerProduct, kInCopyProduct },
	{ kWildFS },
	{ kModelPlugIn, kUIPlugin },
	SDK_DEF_MAKE_VERSIONSTRING(kSDKDefPlugInMajorVersionNumberForResource, kSDKDefPlugInMinorVersionNumberForResource, kSDKDefPlugInStepVersionNumberForResource, kBuildNumber)
};

 But that just resulted in syntax error.

So, I've just tried including UI component changing the PluginVersion. I just took necessary parts from some UI plugin in skdsamples and merged with my model plugin.

 

When I launcht the InDesign I got this error message to pop up: 

 

Model plugin MYTEST.SDK.PLN is attempting to use UI interface implementation kCPanelMenuDataImpl provided by plugin WIDGETS.RPLN in class kTestPanelWidgetBoss. A UI interface implementation can be added to a model boss only via the AddIn directive in a UI plugin resource, and that implementation will not be present in the boss when running in a background task.

 

From the error message, as I understood, I need to create separate plugins(?), and somehow tell the UI plugin to connect with Model plugin using the Addin directive... If I got it right, is it still possible to access my model plugin's custom service class instance from UI plugin and change value of the static variable?

 

More importanlty, how do I achieve this all to work together?? I mean how to add via Addin directive.

 

Responding with some working code example would be much appreciated! Thanks!

 

 

This topic has been closed for replies.

3 replies

Legend
December 26, 2023

Please read the SDK documentation, especially the sections called "Programming Guide".

The equivalent of 800+ pages in PDF, unfortunately converted to HTML with SDK version 10, was written and illustrated when Adobe had dedicated an entire department to it. These concepts can not sufficiently get condensed into brief forum messages.

Inspiring
December 26, 2023

Hi,

 

I can't comment much where you are going wrong, but from architectural point of view -

 

1. If you are creating a small plugin that runs only on InDesign Client then for simplicity you can always create UI Plugin. - Note this plugin won't run on InDesign Server.

 

2. A good architecture for InDesign is always to separate Model and UI.

 

a. Model Plugin - this will not be able to access any UI component. In FR file you can specify whether this is to be loaded with InDesign Server or Client or both.

 

b. UI Plugin - this should only contain UI components and business logic related to UI components. This will only work with InDesign Client and not with InDesign Server.

 

Now, the problem that you are facing is how to communicate from UI to Model Plugin -

 

You can create a layer between Model and UI Plugin. In the Model Plugin, you can add your own interface and implementations in kUtilsBoss.

 

In the UI Plugin, you will be able to access your interface from kUtilsBoss and will be able to call any functions.

 

Hope this helps.

 

Regards,

Rahul Rastogi

Adobe InDesign C++ Solution Architect 

Community Expert
December 24, 2023

I would say you can create a UIPlugin. That plugin can have all the Model and UI elements

-Manan

-Manan
Known Participant
December 24, 2023

Hello Manan, I've tried that and it says:

 

ServiceRegistryBase::Initialize - Service Provider kCHLServiceProviderImpl resides in a UI plugin but its threading policy is kMultipleThreads!


Community Expert
December 25, 2023

Then I would say that let's do it the right way. Put the service inside a model plugin and create a communication layer between the UI and Model Layer. A facade interface that can be queried by both the plugins and used for data exchange.

-Manan

-Manan