Solved Help needed * .res files, dialogs etc...Plugin beginner

Help ... I don't get that with the * .res files, dialogs etc
So to internalize that:
A dialog is when I press a command for example and a window opens ... the res files belong in the dialogs folder
And with an object plugin e.g. or tag plugin, the parameters for setting, these are descriptions and these res files belong in the description folder

I'm so stupid, it really depresses me ...
I also copied the example files for the test, didn't change anything ....

I would like to create a very simple object plugin that simply creates a cube for the beginning and provides a real parameter that sets the side lengths .....
The plugin loads, the cube is displayed but my parameters and my group are not .... what am I doing wrong ..... the manuals for Python are confusing, dialogs are shown, but not for descriptions .....

This is the code for the plugin

import c4d
import os

PLUGIN_ID = 1000001  #test ID



class Cube_Maker(c4d.plugins.ObjectData):



    def Init(self, node):

        self.cube = c4d.BaseObject(c4d.Ocube)
        self.cube.SetPhong(True, True, c4d.utils.DegToRad(45))
        return True

    

    def GetVirtualObjects(self, op, hh):

        return self.cube

    def GetDimensions(self, op, mp, rad):  # I don't know just tried :-)

        mp = c4d.Vector(40)

        rad = c4d.Vector(40)
        return


    


if __name__ == "__main__":
    path, file = os.path.split(__file__)

    fn = os.path.join(path,"res","window_maker.tif")
    bmp = c4d.bitmaps.BaseBitmap()
    bmp.InitWith(fn)



    checker=c4d.plugins.RegisterObjectPlugin(id=PLUGIN_ID,
                                     str="Cube",
                                     g=Cube_Maker,
                                     description="",
                                     icon=bmp,
                                     info=c4d.OBJECT_GENERATOR)
    if checker:
        print("Window Maker Ready")


this is the code for the MYDIALOG.h file:

#ifndef _MYDIALOG_H_
#define _MYDIALOG_H_

enum
{

	SIDE      = 1001


}

#endif

this is the code for the MYDIALOG.res file:

CONTAINER MYDIALOG
{
    NAME MYDIALOG;
    INCLUDE Obase;
    INCLUDE Mpreview;


	GROUP CUBE_PROPERTIES
	{
	    REAL SIDE{ UNIT METER; MIN 0.0; }




	}
}

this is the code for the MYDIALOG.str file:

STRINGTABLE MYDIALOG
{
    MYDIALOG "Cube-Maker";
	SIDE "Side-Length";



}

and the c4d.symbols file:

enum
{
	// string table definitions


    _DUMMY_ELEMENT_
};


here is my PluginStructure:

697cb57e-85b4-4a91-9d5e-72fb64b49d99-image.png

The plugin at the moment starts, loads ..I just want to show the group and the parameter , for the start without any function...just a real value

5ca148e5-7f6f-4224-89f3-6141dc97a096-image.png

I am aware that I am sure that I am doing a lot wrong and that I have forgotten some things ... but the plugin concept is completely new to me ...:cry:

Sincerely
Tom

Cheers
Tom

So I figured it out....

  • first in the .res file the first group was named wrong, this is the group which directly comes after the basic and coords tab.....It has to be named ID_OBJECTPROPERTIES
    It costed me 2 hours to figure out, that I also have forgotten the "P" in OBJECT(P)ROPERTIES :nauseated_face:

this f....... res , header and str. files concept ....I hate it....
also you have to initialize the parameter in the plugin , too.....
double work......

so now it works

res file:

CONTAINER OCUBO
{
    NAME Cube;
    INCLUDE Obase;
    //INCLUDE Mpreview;


	GROUP ID_OBJECTPROPERTIES
	{


        REAL SIDE{ UNIT METER; MIN 0.0;}



	}

	GROUP IHATEIT
	{

	    REAL LENGTH{ UNIT METER;}

	}

}

.h-file

#ifndef _OCUBO_H_
#define _OCUBO_H_

enum
{

    //Ocubo  =  1000001,

	SIDE      = 1001, // link [just for compatibilty <V9.200]
	IHATEIT=1003,
	LENGTH    = 1002,



}

#endif

.str file

STRINGTABLE  Ocubo
{
    Cube "Settings";

	SIDE "Side-Length";
	LENGTH "Length";
	IHATEIT "Hate this";



}

Cheers
Tom

Hi,

That is correct, dialogs and descriptions must be stored in different directories.

When registering the plugin, you need to specify the description file used by the plugin. That's how the plugin is "linked" to the resource file.
See our documentation here

checker=c4d.plugins.RegisterObjectPlugin(id=PLUGIN_ID,
                                     str="Cube",
                                     g=Cube_Maker,
                                     description="MYDIALOG",
                                     icon=bmp,
                                     info=c4d.OBJECT_GENERATOR)

You can also have a look at our github repository where you will find some examples of plugins where we use dialog and description.

I didn't test your code but that is what jumped to my eye directly.

By the way, calling your description file "MYDIALOG" is not the best idea.

Also, in your code, you are creating the cube on the Init function and returning it in GetVirtualObject. That's not the right way of doing it. Everything should be done inside GetVirtualObject.

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

@m_magalhaes

OK thank you, yes I already tried that with the GetVirtualObject.....but can I do my own init function? anyways....

I changed the description now to my res filename....but he shows me now an error in line 9 in resfile, after calling the "plugin" in Cinema.

In the meanwhile I just changed the filename and the names etc.

CONTAINER CUBE_SETTINGS
{
    NAME cube_object;
    INCLUDE Obase;
    INCLUDE Mpreview;

	GROUP ID_CUBE_PROPERTIES
	{
        GROUP
        {

                REAL SIDE{ UNIT METER; MIN 0.0; }
        }


	}
}

b52bae2f-44bb-4e94-a657-10af342f32b7-image.png
Sincerely
Thomas

Cheers
Tom

So I figured it out....

  • first in the .res file the first group was named wrong, this is the group which directly comes after the basic and coords tab.....It has to be named ID_OBJECTPROPERTIES
    It costed me 2 hours to figure out, that I also have forgotten the "P" in OBJECT(P)ROPERTIES :nauseated_face:

this f....... res , header and str. files concept ....I hate it....
also you have to initialize the parameter in the plugin , too.....
double work......

so now it works

res file:

CONTAINER OCUBO
{
    NAME Cube;
    INCLUDE Obase;
    //INCLUDE Mpreview;


	GROUP ID_OBJECTPROPERTIES
	{


        REAL SIDE{ UNIT METER; MIN 0.0;}



	}

	GROUP IHATEIT
	{

	    REAL LENGTH{ UNIT METER;}

	}

}

.h-file

#ifndef _OCUBO_H_
#define _OCUBO_H_

enum
{

    //Ocubo  =  1000001,

	SIDE      = 1001, // link [just for compatibilty <V9.200]
	IHATEIT=1003,
	LENGTH    = 1002,



}

#endif

.str file

STRINGTABLE  Ocubo
{
    Cube "Settings";

	SIDE "Side-Length";
	LENGTH "Length";
	IHATEIT "Hate this";



}

Cheers
Tom

@thomasb said in Help needed * .res files, dialogs etc...Plugin beginner:

but can I do my own init function?

yes you can, specially if you want to initialize some variable. But you should not create any geometry there and return this geometry in GVO (get virtual object).

About the group, there's a note about it here. Each NodeType have a "parent" group. Glad that it is working now.

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer