<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic AddOnCommand in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282690#M2580</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;I am trying to configure a AddOnCommad AddIn by following Tibors Publish Example. Unfortunately, Tibor only demo the transfer of Strings. I need to also transfer integer (int), boolean, number (double)&lt;BR /&gt;&lt;BR /&gt;When I type code for a integer type in the function GetInputParametersSchema i get a APIERR_BADPARS error,&lt;BR /&gt;String work OK a in Tibor's example. What are the types for integer, boolean and double?&lt;BR /&gt;&lt;BR /&gt;Below is the code which fails at the integer type def.&lt;BR /&gt;
&lt;PRE&gt;GS::Optional&amp;lt;GS::UniString&amp;gt;MyAddInCommand::GetInputParametersSchema() const
{
	//ACAPI_WriteReport("inside keynotecommand getinputparamschema", true);
	return GS::UniString::Printf(R"({
	"type": "object",
	"properties": {
		"%s": {
			"type": "string",
			"description": "The name of the Library Shape",
			"minLength": 1
		 }
		"%s": {
			"type": "integer",
			"description": "Text Pen Number.",
			"minLength": 1
		},
	},

	"additionalProperties": false,
	"required": [
		"%s"
	]
})", SymbolShapeParameterField, TextPenParameterField, SymbolShapeParameterField);  

// fails at "type" : "integer" ,

&lt;/PRE&gt;
Also will need types for boolean &amp;amp; Double&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/DIV&gt;</description>
    <pubDate>Tue, 14 Sep 2021 07:27:48 GMT</pubDate>
    <dc:creator>poco2013</dc:creator>
    <dc:date>2021-09-14T07:27:48Z</dc:date>
    <item>
      <title>AddOnCommand</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282690#M2580</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I am trying to configure a AddOnCommad AddIn by following Tibors Publish Example. Unfortunately, Tibor only demo the transfer of Strings. I need to also transfer integer (int), boolean, number (double)&lt;BR /&gt;&lt;BR /&gt;When I type code for a integer type in the function GetInputParametersSchema i get a APIERR_BADPARS error,&lt;BR /&gt;String work OK a in Tibor's example. What are the types for integer, boolean and double?&lt;BR /&gt;&lt;BR /&gt;Below is the code which fails at the integer type def.&lt;BR /&gt;
&lt;PRE&gt;GS::Optional&amp;lt;GS::UniString&amp;gt;MyAddInCommand::GetInputParametersSchema() const
{
	//ACAPI_WriteReport("inside keynotecommand getinputparamschema", true);
	return GS::UniString::Printf(R"({
	"type": "object",
	"properties": {
		"%s": {
			"type": "string",
			"description": "The name of the Library Shape",
			"minLength": 1
		 }
		"%s": {
			"type": "integer",
			"description": "Text Pen Number.",
			"minLength": 1
		},
	},

	"additionalProperties": false,
	"required": [
		"%s"
	]
})", SymbolShapeParameterField, TextPenParameterField, SymbolShapeParameterField);  

// fails at "type" : "integer" ,

&lt;/PRE&gt;
Also will need types for boolean &amp;amp; Double&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 07:27:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282690#M2580</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2021-09-14T07:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: AddOnCommand</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282691#M2581</link>
      <description>Hi Gerry,&lt;BR /&gt;
&lt;BR /&gt;
JSON Schema is not Graphisoft specific. JSON Schema is a proposed IETF standard. It is a grammar language for defining the structure, content, and (to some extent) semantics of JSON objects. It lets you specify metadata (data about data) about what an object's properties mean and what values are valid for those properties.&lt;BR /&gt;
&lt;BR /&gt;
Here is the official specification of JSON Schema:&lt;BR /&gt;
&lt;A href="https://json-schema.org/understanding-json-schema/reference/type.html" target="_blank"&gt;&lt;LINK_TEXT text="https://json-schema.org/understanding-j ... /type.html"&gt;https://json-schema.org/understanding-json-schema/reference/type.html&lt;/LINK_TEXT&gt;&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
JSON Schema defines the following basic types:
&lt;UL&gt;&lt;LI&gt;&lt;S&gt;&lt;/S&gt;&lt;/LI&gt;&lt;LI&gt;string&lt;/LI&gt;
&lt;LI&gt;&lt;S&gt;&lt;/S&gt;&lt;/LI&gt;&lt;LI&gt;number&lt;/LI&gt;
&lt;LI&gt;&lt;S&gt;&lt;/S&gt;&lt;/LI&gt;&lt;LI&gt;integer&lt;/LI&gt;
&lt;LI&gt;&lt;S&gt;&lt;/S&gt;&lt;/LI&gt;&lt;LI&gt;object&lt;/LI&gt;
&lt;LI&gt;&lt;S&gt;&lt;/S&gt;&lt;/LI&gt;&lt;LI&gt;array&lt;/LI&gt;
&lt;LI&gt;&lt;S&gt;&lt;/S&gt;&lt;/LI&gt;&lt;LI&gt;boolean&lt;/LI&gt;
&lt;LI&gt;&lt;S&gt;&lt;/S&gt;&lt;/LI&gt;&lt;LI&gt;null&lt;/LI&gt;&lt;/UL&gt;
These types have analogs in most programming languages, though they may go by different names.&lt;BR /&gt;
JSON	-&amp;gt;	Python&lt;BR /&gt;
string	-&amp;gt;	string&lt;BR /&gt;
number	-&amp;gt;	int/float&lt;BR /&gt;
object	-&amp;gt;	dict&lt;BR /&gt;
array	-&amp;gt;	list&lt;BR /&gt;
boolean	-&amp;gt;	bool&lt;BR /&gt;
null	-&amp;gt;	None&lt;BR /&gt;
&lt;BR /&gt;
So JSON does not have separate types for integer and floating-point. More details: &lt;A href="https://json-schema.org/understanding-json-schema/reference/numeric.html" target="_blank"&gt;&lt;LINK_TEXT text="https://json-schema.org/understanding-j ... meric.html"&gt;https://json-schema.org/understanding-json-schema/reference/numeric.html&lt;/LINK_TEXT&gt;&lt;/A&gt;</description>
      <pubDate>Mon, 12 Jul 2021 08:35:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282691#M2581</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2021-07-12T08:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: AddOnCommand</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282692#M2582</link>
      <description>Thank for the reply Tibor. That's about what I thought but was confused when my code did not work. The problem in the above, which I did not see for the tenth time, is a misplaced comma.&lt;BR /&gt;
&lt;BR /&gt;
A thousand apologizes!! &lt;BR /&gt;
&lt;BR /&gt;
BTW -- I'm still trying to get my interface working -- so may have more dumb questions.</description>
      <pubDate>Mon, 12 Jul 2021 11:19:14 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282692#M2582</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2021-07-12T11:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: AddOnCommand</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282693#M2583</link>
      <description>&lt;BLOCKQUOTE&gt;poco2013 wrote:&lt;BR /&gt;The problem in the above, which I did not see for the tenth time, is a misplaced comma.&lt;/BLOCKQUOTE&gt;
I'm happy that you managed to solve the issue.&lt;BR /&gt;
&lt;BR /&gt;
You can store your JSON schemas in separate JSON files if you like. That way the editor applications (IDE like Visual Studio Code) will warn you that there are mistakes in your JSON file and underline your code where the comma is missing.&lt;BR /&gt;
To do that you have to make a JSON file like this (JSONSchemas.json):
&lt;PRE&gt;{
    "MyInputParametersSchema": {
        "type": "object",
        "properties": {
            "shapeName": {
                "type": "string",
                "description": "The name of the Library Shape",
                "minLength": 1
            },
            "pen": {
                "type": "integer",
                "description": "Text Pen Number.",
                "minLength": 1
            }
        },
        "additionalProperties": false,
        "required": [
            "shapeName",
            "pen"
        ]
    },
    "MyResponseSchema": {
        "type": "object",
        "properties": {
            "error": {
                "$ref": "APITypes.json#/definitions/Error"
            }
        },
        "additionalProperties": false,
        "required": []
    }
}&lt;/PRE&gt;
Add it as a DATA resource into your GRC file:
&lt;PRE&gt;'DATA' 1000 "JSON file containing the JSON schemas of commands" {
	"JSONSchemas.json"
}&lt;/PRE&gt;
Finally read the JSON resource from your C++ code:
&lt;PRE&gt;GS::Optional&amp;lt;GS::UniString&amp;gt; MyJSONCommand::GetSchemaDefinitions () const
{
	GSHandle myJSONFileContent = RSLoadResource ('DATA', ACAPI_GetOwnResModule (), 1000);
	return GS::UniString (*myJSONFileContent);
}


GS::Optional&amp;lt;GS::UniString&amp;gt; MyJSONCommand::GetInputParametersSchema () const
{
	return GS::UniString (R"({
	"$ref": "#/MyInputParametersSchema"
})");
}


GS::Optional&amp;lt;GS::UniString&amp;gt; MyJSONCommand::GetResponseSchema () const
{
	return GS::UniString (R"({
	"$ref": "#/MyResponseSchema"
})");
}&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Jul 2021 13:27:42 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282693#M2583</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2021-07-13T13:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: AddOnCommand</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282694#M2584</link>
      <description>Thanks Tibor -  What a GREAT tip.&lt;BR /&gt;
&lt;BR /&gt;
I have a Json editor and could have used it, if i understood what i was doing rather than just trying to follow a pattern.&lt;BR /&gt;
At any rate, this simplifies things for the most complicated part of the Command handler.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again</description>
      <pubDate>Tue, 13 Jul 2021 15:25:39 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AddOnCommand/m-p/282694#M2584</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2021-07-13T15:25:39Z</dc:date>
    </item>
  </channel>
</rss>

