SOLVED!
AddOnCommand

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-07-11
08:58 PM
- last edited on
‎2021-09-14
09:27 AM
by
Noemi Balogh
‎2021-07-11
08:58 PM
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)
When I type code for a integer type in the function GetInputParametersSchema i get a APIERR_BADPARS error,
String work OK a in Tibor's example. What are the types for integer, boolean and double?
Below is the code which fails at the integer type def.
Thanks
When I type code for a integer type in the function GetInputParametersSchema i get a APIERR_BADPARS error,
String work OK a in Tibor's example. What are the types for integer, boolean and double?
Below is the code which fails at the integer type def.
GS::Optional<GS::UniString>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" ,Also will need types for boolean & Double
Thanks
Gerry
Windows 11 - Visual Studio 2022; ArchiCAD 27
Windows 11 - Visual Studio 2022; ArchiCAD 27
Solved! Go to Solution.
Labels:
- Labels:
-
Add-On (C++)
1 ACCEPTED SOLUTION
Accepted Solutions
Solution

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-07-12 01:19 PM
‎2021-07-12
01:19 PM
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.
A thousand apologizes!!
BTW -- I'm still trying to get my interface working -- so may have more dumb questions.
A thousand apologizes!!
BTW -- I'm still trying to get my interface working -- so may have more dumb questions.
Gerry
Windows 11 - Visual Studio 2022; ArchiCAD 27
Windows 11 - Visual Studio 2022; ArchiCAD 27
4 REPLIES 4

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-07-12 10:35 AM
‎2021-07-12
10:35 AM
Hi Gerry,
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.
Here is the official specification of JSON Schema:
https://json-schema.org/understanding-json-schema/reference/type.html
JSON Schema defines the following basic types:
JSON -> Python
string -> string
number -> int/float
object -> dict
array -> list
boolean -> bool
null -> None
So JSON does not have separate types for integer and floating-point. More details:https://json-schema.org/understanding-json-schema/reference/numeric.html
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.
Here is the official specification of JSON Schema:
JSON Schema defines the following basic types:
- string
- number
- integer
- object
- array
- boolean
- null
JSON -> Python
string -> string
number -> int/float
object -> dict
array -> list
boolean -> bool
null -> None
So JSON does not have separate types for integer and floating-point. More details:
Solution

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-07-12 01:19 PM
‎2021-07-12
01:19 PM
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.
A thousand apologizes!!
BTW -- I'm still trying to get my interface working -- so may have more dumb questions.
A thousand apologizes!!
BTW -- I'm still trying to get my interface working -- so may have more dumb questions.
Gerry
Windows 11 - Visual Studio 2022; ArchiCAD 27
Windows 11 - Visual Studio 2022; ArchiCAD 27

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-07-13 03:27 PM
‎2021-07-13
03:27 PM
poco2013 wrote:I'm happy that you managed to solve the issue.
The problem in the above, which I did not see for the tenth time, is a misplaced comma.
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.
To do that you have to make a JSON file like this (JSONSchemas.json):
{ "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": [] } }Add it as a DATA resource into your GRC file:
'DATA' 1000 "JSON file containing the JSON schemas of commands" { "JSONSchemas.json" }Finally read the JSON resource from your C++ code:
GS::Optional<GS::UniString> MyJSONCommand::GetSchemaDefinitions () const { GSHandle myJSONFileContent = RSLoadResource ('DATA', ACAPI_GetOwnResModule (), 1000); return GS::UniString (*myJSONFileContent); } GS::Optional<GS::UniString> MyJSONCommand::GetInputParametersSchema () const { return GS::UniString (R"({ "$ref": "#/MyInputParametersSchema" })"); } GS::Optional<GS::UniString> MyJSONCommand::GetResponseSchema () const { return GS::UniString (R"({ "$ref": "#/MyResponseSchema" })"); }

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎2021-07-13 05:25 PM
‎2021-07-13
05:25 PM
Thanks Tibor - What a GREAT tip.
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.
At any rate, this simplifies things for the most complicated part of the Command handler.
Thanks again
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.
At any rate, this simplifies things for the most complicated part of the Command handler.
Thanks again
Gerry
Windows 11 - Visual Studio 2022; ArchiCAD 27
Windows 11 - Visual Studio 2022; ArchiCAD 27