diff --git a/choco/blenderbim/blenderbim.nuspec b/choco/blenderbim/blenderbim.nuspec
new file mode 100644
index 0000000000..16c878bc12
--- /dev/null
+++ b/choco/blenderbim/blenderbim.nuspec
@@ -0,0 +1,34 @@
+
+
+
+
+ blenderbim-nightly
+ blenderbim_build_version
+ https://github.com/IfcOpenShell/IfcOpenShell
+ fbpyr
+
+ BlenderBIM install nightly
+ Dion Moult and many more, see: https://github.com/IfcOpenShell/IfcOpenShell/graphs/contributors
+ https://github.com/IfcOpenShell/IfcOpenShell
+ https://rawcdn.githack.com/fbpyr/IfcOpenShell/9662598ad4a7e4b6cd8980e430d07263835d0eda/choco/blenderbim/blenderbim.png
+
+ https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/COPYING
+ true
+ https://github.com/IfcOpenShell/IfcOpenShell
+ https://blenderbim.org/docs/
+
+ https://github.com/IfcOpenShell/IfcOpenShell/issues
+ blender bim blenderbim python opensource foss
+ opensource bim
+ opensource bim addon for blender
+
+
+
+
+
+
+
+
+
+
+
diff --git a/choco/blenderbim/blenderbim.png b/choco/blenderbim/blenderbim.png
new file mode 100644
index 0000000000..3df402d817
Binary files /dev/null and b/choco/blenderbim/blenderbim.png differ
diff --git a/choco/blenderbim/check_repo_infos.py b/choco/blenderbim/check_repo_infos.py
new file mode 100644
index 0000000000..d3865c87d3
--- /dev/null
+++ b/choco/blenderbim/check_repo_infos.py
@@ -0,0 +1,78 @@
+import sys
+import re
+import datetime
+from urllib import request
+
+
+def request_repo_info(url: str):
+ req = request.Request(url)
+ resp = request.urlopen(req)
+ if not resp.status == 200:
+ print(f"[ERROR] could not contact server: {url}")
+ quit(1)
+ return resp
+
+
+if sys.argv[1] == "--do_choco_release?":
+ now = datetime.datetime.now()
+ blenderbim_date = now.strftime("%y%m%d")
+ url = "https://github.com/IfcOpenShell/IfcOpenShell/releases/latest"
+ resp = request_repo_info(url)
+ if blenderbim_date in resp.url:
+ print("do_choco_release", end="")
+
+
+elif sys.argv[1] == "--latest_blender_release_min_maj_pat?":
+ re_blender_version_min_maj_pat = r"Latest Version.+Blender (\d+\.\d+\.\d+)"
+ url = "https://community.chocolatey.org/packages/blender"
+ resp = request_repo_info(url)
+ html_txt = str(resp.read())
+ found = re.findall(re_blender_version_min_maj_pat, html_txt)
+ if found:
+ print(found[0], end="")
+
+
+elif sys.argv[1] == "--latest_blender_release_min_maj?":
+ re_blender_version_min_maj = r"Latest Version.+Blender (\d+\.\d+)\..+"
+ url = "https://community.chocolatey.org/packages/blender"
+ resp = request_repo_info(url)
+ html_txt = str(resp.read())
+ found = re.findall(re_blender_version_min_maj, html_txt)
+ if found:
+ print(found[0], end="")
+
+elif sys.argv[1] == "--latest_blender_python_version_maj_min?":
+ # get latest blender version first
+ re_blender_version_min_maj_pat = r"Latest Version.+Blender (\d+\.\d+\.\d+)"
+ url = "https://community.chocolatey.org/packages/blender"
+ resp = request_repo_info(url)
+ html_txt = str(resp.read())
+ found = re.findall(re_blender_version_min_maj_pat, html_txt)
+ if found:
+ latest_blender_version_tag = f"v{found[0]}"
+ re_blender_python_version_maj_min = r"SET\(PYTHON_VERSION (\d+.\d+) "
+ url = f"https://raw.githubusercontent.com/blender/blender/{latest_blender_version_tag}/build_files/cmake/Modules/FindPythonLibsUnix.cmake"
+ resp = request_repo_info(url)
+ html_txt = str(resp.read())
+ found = re.findall(re_blender_python_version_maj_min, html_txt)
+ if found:
+ print(found[0], end="")
+
+
+elif sys.argv[1] == "--pyver?":
+ # get latest blender version first
+ re_blender_version_min_maj_pat = r"Latest Version.+Blender (\d+\.\d+\.\d+)"
+ url = "https://community.chocolatey.org/packages/blender"
+ resp = request_repo_info(url)
+ html_txt = str(resp.read())
+ found = re.findall(re_blender_version_min_maj_pat, html_txt)
+ if found:
+ latest_blender_version_tag = f"v{found[0]}"
+ re_blender_python_version_maj_min = r"SET\(PYTHON_VERSION (\d+.\d+) "
+ url = f"https://raw.githubusercontent.com/blender/blender/{latest_blender_version_tag}/build_files/cmake/Modules/FindPythonLibsUnix.cmake"
+ resp = request_repo_info(url)
+ html_txt = str(resp.read())
+ found = re.findall(re_blender_python_version_maj_min, html_txt)
+ if found:
+ print(f"py{found[0].replace('.', '')}", end="")
+
diff --git a/choco/blenderbim/fill_dynamic_parameters.py b/choco/blenderbim/fill_dynamic_parameters.py
new file mode 100644
index 0000000000..738a779b91
--- /dev/null
+++ b/choco/blenderbim/fill_dynamic_parameters.py
@@ -0,0 +1,49 @@
+import os
+from pathlib import Path
+
+
+print("[INFO] inserting dynamic chocolatey package parameters")
+HERE_DIR = Path(__file__).parent.absolute()
+# print(f"[INFO] HERE_DIR: {HERE_DIR}")
+
+topics = {
+ "spec": {
+ "path": HERE_DIR / "blenderbim.nuspec",
+ "env_vars": {
+ "latest_blender_version_maj_min_pat",
+ "blenderbim_build_version",
+ },
+ },
+ "install": {
+ "path": HERE_DIR / "tools" / "chocolateyinstall.ps1",
+ "env_vars": {
+ "url_blenderbim_py310_win_zip",
+ "sha256sum_blenderbim_py310_win_zip",
+ "latest_blender_version_maj_min",
+ },
+ },
+ "uninstall": {
+ "path": HERE_DIR / "tools" / "chocolateyuninstall.ps1",
+ "env_vars": {
+ "latest_blender_version_maj_min",
+ },
+ },
+}
+
+for topic, info in topics.items():
+ print(f"[INFO] {topic}:")
+ for env_var_name in info["env_vars"]:
+ print(f"[INFO] {env_var_name} exists?: {os.environ[env_var_name]}")
+
+ with open(info["path"], encoding="utf-8") as txt:
+ content = txt.read()
+
+ for env_var_name in info["env_vars"]:
+ # print(f"[INFO] replace: {env_var_name}")
+ content = content.replace(env_var_name, os.environ[env_var_name])
+
+ with open(info["path"], "w", encoding="utf-8") as txt:
+ txt.write(content)
+ print(f"[INFO] written: {info['path']}")
+
+print("[INFO] inserting dynamic chocolatey package parameters successful")
diff --git a/choco/blenderbim/tools/chocolateybeforemodify.ps1 b/choco/blenderbim/tools/chocolateybeforemodify.ps1
new file mode 100644
index 0000000000..4aa0f65d59
--- /dev/null
+++ b/choco/blenderbim/tools/chocolateybeforemodify.ps1
@@ -0,0 +1,11 @@
+$processName = "blender"
+$blenderIsRunning = Get-Process -Name $processName -ErrorAction SilentlyContinue
+
+if($blenderIsRunning -eq $null) {
+ echo "Blender is not running ready for next action."
+}
+else {
+ Write-Warning "$processName is still running - installer cannot safely proceed to next action."
+ Write-Warning "Please retry after closing all running blender applications."
+ exit 1
+}
diff --git a/choco/blenderbim/tools/chocolateyinstall.ps1 b/choco/blenderbim/tools/chocolateyinstall.ps1
new file mode 100644
index 0000000000..d79c87b1bb
--- /dev/null
+++ b/choco/blenderbim/tools/chocolateyinstall.ps1
@@ -0,0 +1,29 @@
+$ErrorActionPreference = 'Stop'
+
+$url64 = 'url_blenderbim_py310_win_zip'
+$checksum64 = 'sha256sum_blenderbim_py310_win_zip'
+$checksumType64 = 'sha256'
+
+$appDataUserDir = [System.Environment]::GetEnvironmentVariable('appdata')
+$unzipTargetDir = "$appDataUserDir\Blender Foundation\Blender\latest_blender_version_maj_min\scripts\addons"
+
+$chocoBaseDir = [System.Environment]::GetEnvironmentVariable('ChocolateyInstall')
+$addonEnable = "$chocoBaseDir\lib\blenderbim\tools\enable_blenderbim_addon.py"
+
+$programFilesDir = [System.Environment]::GetEnvironmentVariable('ProgramFiles')
+$blenderExePath = "$env:ProgramFiles\Blender Foundation\Blender latest_blender_version_maj_min\blender.exe"
+
+$processName = "blender"
+$blenderIsRunning = Get-Process -Name $processName -ErrorAction SilentlyContinue
+
+
+if($blenderIsRunning -eq $null) {
+ echo "attempting to install blenderbim."
+ Install-ChocolateyZipPackage -PackageName $env:ChocolateyPackageName -Url64 $url64 -Checksum64 $checksum64 -checksumType $checksumType64 -UnzipLocation $unzipTargetDir
+ Start-Process -FilePath $blenderExePath -ArgumentList "-b", "-y", "--python", "$addonEnable"
+}
+else {
+ Write-Warning "$processName is still running - blenderbim cannot be safely installed."
+ Write-Warning "Please retry after closing all running blender applications."
+ exit 1
+}
diff --git a/choco/blenderbim/tools/chocolateyuninstall.ps1 b/choco/blenderbim/tools/chocolateyuninstall.ps1
new file mode 100644
index 0000000000..7c319b2829
--- /dev/null
+++ b/choco/blenderbim/tools/chocolateyuninstall.ps1
@@ -0,0 +1,22 @@
+$appDataUserDir = [System.Environment]::GetEnvironmentVariable('appdata')
+$unzippedDir = "$appDataUserDir\Blender Foundation\Blender\latest_blender_version_maj_min\scripts\addons\blenderbim"
+
+$chocoBaseDir = [System.Environment]::GetEnvironmentVariable('ChocolateyInstall')
+$addonDisable = "$chocoBaseDir\lib\blenderbim\tools\disable_blenderbim_addon.py"
+
+$programFilesDir = [System.Environment]::GetEnvironmentVariable('ProgramFiles')
+$blenderExePath = "$env:ProgramFiles\Blender Foundation\Blender latest_blender_version_maj_min\blender.exe"
+
+$processName = "blender"
+$blenderIsRunning = Get-Process -Name $processName -ErrorAction SilentlyContinue
+
+if($blenderIsRunning -eq $null) {
+ echo "attempting to uninstall blenderbim."
+ Start-Process -FilePath $blenderExePath -ArgumentList "-b", "-y", "--python", "$addonDisable"
+ Remove-Item -LiteralPath $unzippedDir -Force -Recurse
+}
+else {
+ Write-Warning "$processName is still running - blenderbim cannot be safely uninstalled."
+ Write-Warning "Please retry after closing all running blender applications."
+ exit 1
+}
diff --git a/choco/blenderbim/tools/disable_blenderbim_addon.py b/choco/blenderbim/tools/disable_blenderbim_addon.py
new file mode 100644
index 0000000000..c7355eb7d9
--- /dev/null
+++ b/choco/blenderbim/tools/disable_blenderbim_addon.py
@@ -0,0 +1,8 @@
+import bpy
+
+
+bpy.ops.preferences.addon_disable(module='blenderbim')
+bpy.ops.wm.save_userpref()
+
+print("disabled blenderbim addon successfully.")
+
diff --git a/choco/blenderbim/tools/enable_blenderbim_addon.py b/choco/blenderbim/tools/enable_blenderbim_addon.py
new file mode 100644
index 0000000000..eae588e5f8
--- /dev/null
+++ b/choco/blenderbim/tools/enable_blenderbim_addon.py
@@ -0,0 +1,8 @@
+import bpy
+
+
+bpy.ops.preferences.addon_enable(module='blenderbim')
+bpy.ops.wm.save_userpref()
+
+print("enabled blenderbim addon successfully.")
+