bonsai other scripts #5178

This commit is contained in:
Andrej730
2024-08-14 15:43:06 +05:00
committed by Andrej
parent 3318de7f6d
commit f8f7884278
12 changed files with 23 additions and 27 deletions
+3 -3
View File
@@ -36,7 +36,7 @@ import os
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
project = "BlenderBIM Add-on" project = "Bonsai"
copyright = "2020-2024 IfcOpenShell Contributors" copyright = "2020-2024 IfcOpenShell Contributors"
author = "IfcOpenShell Contributors" author = "IfcOpenShell Contributors"
@@ -89,7 +89,7 @@ html_logo = "https://bonsaibim.org/assets/images/blender/blender-logo.png"
html_theme_options = { html_theme_options = {
"source_repository": "https://github.com/IfcOpenShell/IfcOpenShell/", "source_repository": "https://github.com/IfcOpenShell/IfcOpenShell/",
"source_branch": "v0.8.0", "source_branch": "v0.8.0",
"source_directory": "src/blenderbim/docs/", "source_directory": "src/bonsai/docs/",
"light_css_variables": { "light_css_variables": {
"color-brand-primary": "#39b54a", "color-brand-primary": "#39b54a",
"color-brand-content": "#39b54a", "color-brand-content": "#39b54a",
@@ -132,7 +132,7 @@ html_theme_options = {
}, },
{ {
"name": "GitHub", "name": "GitHub",
"url": "https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.8.0/src/blenderbim/docs", "url": "https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.8.0/src/bonsai/docs",
"html": """ "html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16"> <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path> <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
+2 -2
View File
@@ -22,7 +22,7 @@
import bpy import bpy
import ifcopenshell import ifcopenshell
import ifcopenshell.api import ifcopenshell.api
import blenderbim.tool as tool import bonsai.tool as tool
class LibraryGenerator: class LibraryGenerator:
@@ -183,7 +183,7 @@ class LibraryGenerator:
self.create_type("IfcDoorType", "DEMO1", {"model_body": "Door", "plan_body": "Door-Annotation"}) self.create_type("IfcDoorType", "DEMO1", {"model_body": "Door", "plan_body": "Door-Annotation"})
self.create_type("IfcFurnitureType", "BUNNY", {"model_body": "Bunny", "plan_body": "Bunny-Annotation"}) self.create_type("IfcFurnitureType", "BUNNY", {"model_body": "Bunny", "plan_body": "Bunny-Annotation"})
self.file.write("blenderbim-au-library.ifc") self.file.write("bonsai-au-library.ifc")
def create_layer_set_type(self, name, data): def create_layer_set_type(self, name, data):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=data["type"], name=name) element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=data["type"], name=name)
+3 -5
View File
@@ -19,7 +19,7 @@
import bpy import bpy
import ifcopenshell import ifcopenshell
import ifcopenshell.api import ifcopenshell.api
import blenderbim.tool as tool import bonsai.tool as tool
class LibraryGenerator: class LibraryGenerator:
@@ -28,11 +28,9 @@ class LibraryGenerator:
ifcopenshell.api.post_listeners = {} ifcopenshell.api.post_listeners = {}
self.file = ifcopenshell.api.run("project.create_file") self.file = ifcopenshell.api.run("project.create_file")
self.project = ifcopenshell.api.run( self.project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject", name="Bonsai Demo")
"root.create_entity", self.file, ifc_class="IfcProject", name="BlenderBIM Demo"
)
self.library = ifcopenshell.api.run( self.library = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name="BlenderBIM Demo Library" "root.create_entity", self.file, ifc_class="IfcProjectLibrary", name="Bonsai Demo Library"
) )
ifcopenshell.api.run( ifcopenshell.api.run(
"project.assign_declaration", self.file, definitions=[self.library], relating_context=self.project "project.assign_declaration", self.file, definitions=[self.library], relating_context=self.project
@@ -20,13 +20,13 @@ import os
import bpy import bpy
import ifcopenshell import ifcopenshell
import ifcopenshell.api import ifcopenshell.api
import blenderbim.tool as tool import bonsai.tool as tool
from pathlib import Path from pathlib import Path
# When run from Blender # When run from Blender
BLEND_DIR = os.path.dirname(bpy.data.filepath) BLEND_DIR = os.path.dirname(bpy.data.filepath)
OUT_PATH = os.path.join(BLEND_DIR, "..", "blenderbim", "bim", "data", "libraries", "IFC4 Entourage Library.ifc") OUT_PATH = os.path.join(BLEND_DIR, "..", "bonsai", "bim", "data", "libraries", "IFC4 Entourage Library.ifc")
class LibraryGenerator: class LibraryGenerator:
@@ -1929,7 +1929,7 @@ class LibraryGenerator:
if __name__ == "__main__": if __name__ == "__main__":
path = Path(__file__).parents[1] / "blenderbim/bim/data/libraries" path = Path(__file__).parents[1] / "bonsai/bim/data/libraries"
LibraryGenerator().generate( LibraryGenerator().generate(
"Non-structural assets library", output_filename=str(path / "IFC4 Furniture Library.ifc") "Non-structural assets library", output_filename=str(path / "IFC4 Furniture Library.ifc")
) )
@@ -22,7 +22,7 @@ import csv
import random import random
import ifcopenshell import ifcopenshell
import ifcopenshell.api import ifcopenshell.api
import blenderbim.tool as tool import bonsai.tool as tool
from math import cos, sin, tan, pi from math import cos, sin, tan, pi
from pathlib import Path from pathlib import Path
from itertools import chain from itertools import chain
@@ -34,7 +34,7 @@ from random import uniform
# When run from Blender # When run from Blender
BLEND_DIR = os.path.dirname(bpy.data.filepath) BLEND_DIR = os.path.dirname(bpy.data.filepath)
OUT_PATH = os.path.join(BLEND_DIR, "..", "blenderbim", "bim", "data", "libraries", "IFC4 Landscape Library.ifc") OUT_PATH = os.path.join(BLEND_DIR, "..", "bonsai", "bim", "data", "libraries", "IFC4 Landscape Library.ifc")
SimpleTreeParams = namedtuple("SimpleTreeParams", "plant_height crown_diameter trunk_diameter") SimpleTreeParams = namedtuple("SimpleTreeParams", "plant_height crown_diameter trunk_diameter")
LowPolyTreeParams = namedtuple( LowPolyTreeParams = namedtuple(
+4 -6
View File
@@ -19,7 +19,7 @@
import bpy import bpy
import ifcopenshell import ifcopenshell
import ifcopenshell.api import ifcopenshell.api
import blenderbim.tool as tool import bonsai.tool as tool
class LibraryGenerator: class LibraryGenerator:
@@ -28,11 +28,9 @@ class LibraryGenerator:
ifcopenshell.api.post_listeners = {} ifcopenshell.api.post_listeners = {}
self.file = ifcopenshell.api.run("project.create_file") self.file = ifcopenshell.api.run("project.create_file")
self.project = ifcopenshell.api.run( self.project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject", name="Bonsai Demo")
"root.create_entity", self.file, ifc_class="IfcProject", name="BlenderBIM Demo"
)
self.library = ifcopenshell.api.run( self.library = ifcopenshell.api.run(
"root.create_entity", self.file, ifc_class="IfcProjectLibrary", name="BlenderBIM Demo Library" "root.create_entity", self.file, ifc_class="IfcProjectLibrary", name="Bonsai Demo Library"
) )
ifcopenshell.api.run( ifcopenshell.api.run(
"project.assign_declaration", self.file, definitions=[self.library], relating_context=self.library "project.assign_declaration", self.file, definitions=[self.library], relating_context=self.library
@@ -66,7 +64,7 @@ class LibraryGenerator:
{"body": "Mobile Crane 50T", "clearance": "Mobile Crane 50T - Clearance"}, {"body": "Mobile Crane 50T", "clearance": "Mobile Crane 50T - Clearance"},
) )
self.file.write("blenderbim-site-library.ifc") self.file.write("bonsai-site-library.ifc")
def create_type(self, ifc_class, name, representations): def create_type(self, ifc_class, name, representations):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name) element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class=ifc_class, name=name)
@@ -229,7 +229,7 @@ class LibraryGenerator:
if __name__ == "__main__": if __name__ == "__main__":
path = Path(__file__).parents[1] / "blenderbim/bim/data/libraries" path = Path(__file__).parents[1] / "bonsai/bim/data/libraries"
LibraryGenerator().generate(parse_profiles_type="EU", output_filename=str(path / "IFC4 EU Steel.ifc")) LibraryGenerator().generate(parse_profiles_type="EU", output_filename=str(path / "IFC4 EU Steel.ifc"))
LibraryGenerator().generate(parse_profiles_type="AU", output_filename=str(path / "IFC4 AU Steel.ifc")) LibraryGenerator().generate(parse_profiles_type="AU", output_filename=str(path / "IFC4 AU Steel.ifc"))
LibraryGenerator().generate(parse_profiles_type="US", output_filename=str(path / "IFC4 US Steel.ifc")) LibraryGenerator().generate(parse_profiles_type="US", output_filename=str(path / "IFC4 US Steel.ifc"))
@@ -18,7 +18,7 @@
import ifcopenshell import ifcopenshell
import blenderbim.tool as tool import bonsai.tool as tool
import bpy import bpy
import bmesh import bmesh
+1 -1
View File
@@ -55,7 +55,7 @@ class Describer:
f.write(json.dumps(self.enum_descriptions, indent=4)) f.write(json.dumps(self.enum_descriptions, indent=4))
def get_html_sources(self): def get_html_sources(self):
html_dir = "/home/dion/Projects/IfcOpenShell/src/blenderbim/descriptions/IFC4_3/RC1/HTML" html_dir = "/home/dion/Projects/IfcOpenShell/src/bonsai/descriptions/IFC4_3/RC1/HTML"
for filename in Path(html_dir).rglob("*.htm"): for filename in Path(html_dir).rglob("*.htm"):
if "lexical" not in str(filename): if "lexical" not in str(filename):
continue continue
+1 -1
View File
@@ -1,7 +1,7 @@
# This can be run using `blender -b -P headless_import.py` # This can be run using `blender -b -P headless_import.py`
import bpy import bpy
from blenderbim.bim.ifc import IfcStore from bonsai.bim.ifc import IfcStore
# When federating, you may wish to manually specify the origin to ensure models # When federating, you may wish to manually specify the origin to ensure models
# with different or arbitrary origin conventions will turn up in the right spot. # with different or arbitrary origin conventions will turn up in the right spot.
+2 -2
View File
@@ -20,14 +20,14 @@
It is useful when an annotation drawing has been created on windows and you want to recreate the It is useful when an annotation drawing has been created on windows and you want to recreate the
drawig in linux. drawig in linux.
In this case, blenderbim would tell you that can't load "stylesheet" or "markers" or "symbols" or "patterns" folder. In this case, bonsai would tell you that can't load "stylesheet" or "markers" or "symbols" or "patterns" folder.
If this happens, this script comes in rescue! If this happens, this script comes in rescue!
Basically, as the path is stored in a string, the script replaces the existing sep char with the right one. Basically, as the path is stored in a string, the script replaces the existing sep char with the right one.
It works on the active ifc file (if exists). It works on the active ifc file (if exists).
""" """
import blenderbim.tool as tool import bonsai.tool as tool
import ifcopenshell import ifcopenshell
import sys import sys