# Creación de un complemento

Un complemento es un módulo de extensión que también carga archivos DLL que muestran nuevas API de JavaScript.

### Descargar la API de FormIt

Para generar archivos DLL que admitan FormIt, se necesita la API de FormIt. La API de FormIt se puede descargar desde [Autodesk Developer Network](https://www.autodesk.com/developer-network/overview). Es necesario iniciar sesión para acceder a la descarga.

Una vez que haya iniciado sesión, la API de FormIt está disponible en SOFTWARE.

![](https://formit3d.github.io/FormItExamplePlugins/docs/images/FormItAPIDownload.jpg)

![](https://formit3d.github.io/FormItExamplePlugins/docs/images/FormItAPIMenuItem.jpg)

Un complemento tiene acceso a la [API de FormIt](https://formit3d.github.io/FormItExamplePlugins/docs/FormItCPPAPI/index.html) y la [API de C++ de núcleo de modelado de FormIt](https://formit3d.github.io/FormItExamplePlugins/docs/FormItCPPAPI/group__mod__wsm__api__ref.html).

Un complemento presenta la siguiente estructura:

```
            // FormIt looks for REGISTERAPIMETHODS to load new JS APIs
            REGISTERAPIMETHODS
            {
                // Declare new namespace for the new JS APIs
                REGISTERNAMESPACE("HelloDLL")
                // Create a JS API with no arguments
                APIMETHOD(HelloDLL, API1, "") {}
                // Create a JS API with 1 argument
                APIMETHOD(HelloDLL, API2, "arg1") {}
                // Create a JS API with 2 argument
                APIMETHOD(HelloDLL, API3, "arg1, arg2") {}
                ...
                ...
            }
```

Para obtener los argumentos en las variables de C++, utilice SCRIPTCONVERTER, como se muestra a continuación:

```
            // Create a JS API with 2 argument
            APIMETHOD(HelloDLL, API3, "arg1, arg2")
            {
                // NOTE: The arg names above ^^^^ have to match the args in the macros below.
                // arg1 expects a bool
                SCRIPTCONVERTER(bool, arg1);
                // arg2 expects an int
                SCRIPTCONVERTER(int, arg2);
                return JSON_UNDEFINED;
            }
```

Puede devolverse JSON\_UNDEFINED o cualquier objeto json. Utilice to\_json para convertir la variable C++ en json.

```
            // Create a JS API with 2 argument
            APIMETHOD(HelloDLL, API3, "arg1, arg2")
            {
                // NOTE: The arg names above ^^^^ have to match the args in the macros below.
                // arg1 expects a bool
                SCRIPTCONVERTER(bool, arg1);
                // arg2 expects an int
                SCRIPTCONVERTER(int, arg2);

                std::string myValue = "Test";
                return to_json(myValue);
            }
```

Una vez que el archivo DLL defina todas las API de JS necesarias, el módulo de extensión debe indicar a FormIt los archivos DLL que deben cargarse. Esta acción se realiza en el archivo [manifest](https://github.com/FormIt3D/HelloAddIn/blob/main/v22_0/manifest.json#L8).

```
        "DLLs" : ["PLUGINLOCATION/MyClass.dll", "PLUGINLOCATION/HelloDLL.dll"]
```

[HelloAddIn](https://github.com/FormIt3D/HelloAddIn) es un ejemplo práctico que explica cómo crear un complemento.

[HelloWSMAddIn](https://github.com/FormIt3D/HelloWSMAddIn) es un ejemplo práctico que explica cómo crear un complemento con la [API de C++ de núcleo de modelado de FormIt](https://formit3d.github.io/FormItExamplePlugins/docs/FormItCPPAPI/group__mod__wsm__api__ref.html).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://windows.help.formit.autodesk.com/es/plugins/how-to-develop-plugins/additional-development-options/creating-an-add-in.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
