diff --git a/honeybee_grasshopper_core/icon/HB Validate Model.png b/honeybee_grasshopper_core/icon/HB Validate Model.png index fc21c57..4474a8d 100644 Binary files a/honeybee_grasshopper_core/icon/HB Validate Model.png and b/honeybee_grasshopper_core/icon/HB Validate Model.png differ diff --git a/honeybee_grasshopper_core/json/HB_Validate_Model.json b/honeybee_grasshopper_core/json/HB_Validate_Model.json index 0a165fe..4de9e1a 100644 --- a/honeybee_grasshopper_core/json/HB_Validate_Model.json +++ b/honeybee_grasshopper_core/json/HB_Validate_Model.json @@ -1,5 +1,5 @@ { - "version": "1.8.0", + "version": "1.8.1", "nickname": "ValidateModel", "outputs": [ [] @@ -12,6 +12,13 @@ "type": "System.Object", "default": null }, + { + "access": "item", + "name": "x", + "description": "Optional text for the name of the honeybee extension for which\nvalidation will occur. The value input here is case-insensitive such\nthat \"radiance\" and \"Radiance\" will both result in the model being\nchecked for validity with honeybee-radiance. This value can also be\nset to \"All\" in order to run checks for all installed extensions.\nSome common honeybee extension names that can be input here if they\nare installed include:\n* Radiance\n* EnergyPlus\n* OpenStudio\n* DesignBuilder\n* DOE2\n* IES\n* IDAICE", + "type": "string", + "default": null + }, { "access": "item", "name": "_validate", @@ -21,7 +28,7 @@ } ], "subcategory": "3 :: Serialize", - "code": "\nimport os\n\ntry: # import the core honeybee dependencies\n from honeybee.config import folders\n from honeybee.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the core ladybug_{{cad}} dependencies\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, give_warning\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component) and _validate:\n # re-serialize the model if it is a HBJSON file\n if isinstance(_model, Model):\n parsed_model = _model\n elif isinstance(_model, str) and os.path.isfile(_model):\n parsed_model = Model.from_hbjson(_model)\n else:\n raise ValueError(\n 'Expected Honeybee Model object or path to a HBJSON file. '\n 'Got {}.'.format(type(_model))\n )\n\n # validate the model\n print(\n 'Validating Model using honeybee-core=={} and honeybee-schema=={}'.format(\n folders.honeybee_core_version_str, folders.honeybee_schema_version_str)\n )\n # perform several checks for geometry rules\n report = parsed_model.check_all(raise_exception=False)\n print('Model checks completed.')\n # check the report and write the summary of errors\n if report == '':\n print('Congratulations! Your Model is valid!')\n else:\n error_msg = 'Your Model is invalid for the following reasons:'\n print('\\n'.join([error_msg, report]))\n give_warning(ghenv.Component, report)\n", + "code": "\nimport os\n\ntry: # import the core honeybee dependencies\n from honeybee.config import folders\n from honeybee.model import Model\nexcept ImportError as e:\n raise ImportError('\\nFailed to import honeybee:\\n\\t{}'.format(e))\n\ntry: # import the core ladybug_{{cad}} dependencies\n from ladybug_{{cad}}.{{plugin}} import all_required_inputs, give_warning\nexcept ImportError as e:\n raise ImportError('\\nFailed to import ladybug_{{cad}}:\\n\\t{}'.format(e))\n\n\nif all_required_inputs(ghenv.Component) and _validate:\n # re-serialize the model if it is a HBJSON file\n if isinstance(_model, Model):\n parsed_model = _model\n elif isinstance(_model, str) and os.path.isfile(_model):\n parsed_model = Model.from_hbjson(_model)\n else:\n raise ValueError(\n 'Expected Honeybee Model object or path to a HBJSON file. '\n 'Got {}.'.format(type(_model))\n )\n\n # validate the model\n print(\n 'Validating Model using honeybee-core=={} and honeybee-schema=={}'.format(\n folders.honeybee_core_version_str, folders.honeybee_schema_version_str)\n )\n # perform several checks for geometry rules\n extension_ = 'All' if extension_ is None else extension_\n report = parsed_model.check_for_extension(extension_, raise_exception=False)\n print('Model checks completed.')\n # check the report and write the summary of errors\n if report == '':\n print('Congratulations! Your Model is valid!')\n else:\n error_msg = 'Your Model is invalid for the following reasons:'\n print('\\n'.join([error_msg, report]))\n give_warning(ghenv.Component, report)\n", "category": "Honeybee", "name": "HB Validate Model", "description": "Get a validation report that contains a summary of all issues with the Model.\n_\nThis includes basic properties like adjacency checks and all geometry checks.\nFurthermore, all extension attributes for Energy and Radiance will be checked\nto ensure that the model can be simulated correctly in these engines.\n-" diff --git a/honeybee_grasshopper_core/src/HB Validate Model.py b/honeybee_grasshopper_core/src/HB Validate Model.py index f409635..765b95b 100644 --- a/honeybee_grasshopper_core/src/HB Validate Model.py +++ b/honeybee_grasshopper_core/src/HB Validate Model.py @@ -19,6 +19,20 @@ Args: _model: A Honeybee Model object to be validated. This can also be the file path to a Model HBJSON that will be validated. + extension_: Optional text for the name of the honeybee extension for which + validation will occur. The value input here is case-insensitive such + that "radiance" and "Radiance" will both result in the model being + checked for validity with honeybee-radiance. This value can also be + set to "All" in order to run checks for all installed extensions. + Some common honeybee extension names that can be input here if they + are installed include: + * Radiance + * EnergyPlus + * OpenStudio + * DesignBuilder + * DOE2 + * IES + * IDAICE _validate: Set to "True" to validate the the Model and get a report of all issues with the model. @@ -32,7 +46,7 @@ ghenv.Component.Name = 'HB Validate Model' ghenv.Component.NickName = 'ValidateModel' -ghenv.Component.Message = '1.8.0' +ghenv.Component.Message = '1.8.1' ghenv.Component.Category = 'Honeybee' ghenv.Component.SubCategory = '3 :: Serialize' ghenv.Component.AdditionalHelpFromDocStrings = '0' @@ -69,7 +83,8 @@ folders.honeybee_core_version_str, folders.honeybee_schema_version_str) ) # perform several checks for geometry rules - report = parsed_model.check_all(raise_exception=False) + extension_ = 'All' if extension_ is None else extension_ + report = parsed_model.check_for_extension(extension_, raise_exception=False) print('Model checks completed.') # check the report and write the summary of errors if report == '': diff --git a/honeybee_grasshopper_core/user_objects/HB Validate Model.ghuser b/honeybee_grasshopper_core/user_objects/HB Validate Model.ghuser index 3c9c2df..f0e87d8 100644 Binary files a/honeybee_grasshopper_core/user_objects/HB Validate Model.ghuser and b/honeybee_grasshopper_core/user_objects/HB Validate Model.ghuser differ diff --git a/samples/model_serialization.gh b/samples/model_serialization.gh index 2a38c1f..b6252c9 100644 Binary files a/samples/model_serialization.gh and b/samples/model_serialization.gh differ