Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bl_info = {
"name": "BlendQuery",
"blender": (3, 0, 0),
"blender": (5, 0, 0),
"version": (0, 1, 0),
"category": "Parametric",
}

Expand Down Expand Up @@ -176,7 +177,9 @@ def execute(self, context):
global regenerate_blendquery_object
cadquery = importlib.import_module("cadquery")
build123d = importlib.import_module("build123d")
from .blendquery import regenerate_blendquery_object
# Initialize modules in blendquery.py
from .blendquery import _initialize_modules, regenerate_blendquery_object
_initialize_modules()
are_dependencies_installed = True
except Exception:
are_dependencies_installed = False
Expand Down
36 changes: 24 additions & 12 deletions blendquery.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
from typing import Union, List, Tuple
from typing import Union, List, Tuple, TYPE_CHECKING
from dataclasses import dataclass, field

import bpy
import cadquery
import build123d

ParametricShape = Union[cadquery.Shape, build123d.Shape]
ParametricObject = Union[
ParametricShape,
cadquery.Workplane,
cadquery.Assembly,
build123d.Builder,
]
if TYPE_CHECKING:
import cadquery
import build123d

# These will be imported dynamically when needed
cadquery = None
build123d = None

ParametricShape = "Union[cadquery.Shape, build123d.Shape]"
ParametricObject = "Union[cadquery.Shape, build123d.Shape, cadquery.Workplane, cadquery.Assembly, build123d.Builder]"

def _initialize_modules():
"""Initialize cadquery and build123d modules"""
global cadquery, build123d
try:
import cadquery as cq
import build123d as b123d
cadquery = cq
build123d = b123d
except ImportError:
pass

@dataclass
class ParametricObjectNode:
Expand All @@ -25,7 +37,7 @@ class BlendQueryBuildException(Exception):
def __init__(self, message):
super().__init__(message)

def regenerate_blendquery_object(parametric_objects: List[ParametricObject], root_blender_object: bpy.types.Object, old_blender_objects):
def regenerate_blendquery_object(parametric_objects: List, root_blender_object: bpy.types.Object, old_blender_objects):
# Store current selection
active = bpy.context.view_layer.objects.active
selected_objects = bpy.context.selected_objects.copy()
Expand Down Expand Up @@ -66,7 +78,7 @@ def delete_blender_objects(blender_objects):
continue
blender_objects.clear()

def build_blender_object(parametric_object: ParametricObjectNode, parent: bpy.types.Object):
def build_blender_object(parametric_object: "ParametricObjectNode", parent: bpy.types.Object):

mesh = None

Expand Down
4 changes: 2 additions & 2 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def install():
pip_executable,
"install",
"--pre",
"cadquery",
"git+https://github.com/gumyr/build123d",
"cadquery>=2.4.0",
"build123d>=0.6.0",
],
stderr=subprocess.PIPE,
)
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cadquery==2.3.1
bpy==3.5.0
cadquery>=2.4.0
build123d>=0.6.0