Skip to content

Commit

Permalink
Import and init cleanup
Browse files Browse the repository at this point in the history
All imports made explicit
All redundant and unused imports removed
All circular import errors resolved

Imports alphabetized and sorted by source, in the following order: 
- Python Standard Library
- pip Packages
- Blender Libraries
- cam Modules (from .)

init split into multiple files:
New:
- cam_operation
- chain
- engine
- machine_settings
- preset_managers

Existing:
- pack
- slice
- ui
- utils

Rewrote get_panels to remove legacy panels and updated to follow Blender's guide: https://docs.blender.org/api/current/bpy.types.RenderEngine.html
  • Loading branch information
SpectralVectors authored Apr 2, 2024
1 parent 3a2c237 commit 7325fb1
Show file tree
Hide file tree
Showing 52 changed files with 4,527 additions and 3,102 deletions.
2,600 changes: 290 additions & 2,310 deletions scripts/addons/cam/__init__.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions scripts/addons/cam/async_op.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import bpy
import sys

import types

import bpy


@types.coroutine
def progress_async(text, n=None, value_type='%'):
Expand Down
15 changes: 8 additions & 7 deletions scripts/addons/cam/autoupdate.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import calendar
from datetime import date
from .version import __version__ as current_version
from urllib.request import urlopen
import io
import json
import os
import pathlib
import re
import sys
from urllib.request import urlopen
import zipfile

import bpy
from bpy.props import StringProperty

import re
import io
import os
import sys
import calendar
from .version import __version__ as current_version


class UpdateChecker(bpy.types.Operator):
Expand Down
13 changes: 9 additions & 4 deletions scripts/addons/cam/basrelief.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import bpy
from math import (
ceil,
floor,
sqrt
)
import re
import time

import numpy
import math
import re
from math import *

import bpy
from bpy.props import (
BoolProperty,
EnumProperty,
Expand Down
35 changes: 18 additions & 17 deletions scripts/addons/cam/bridges.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,22 @@
#
# ***** END GPL LICENCE BLOCK *****
# here is the bridges functionality of Blender CAM. The functions here are called with operators defined from ops.py.
from math import (
hypot,
pi,
)

from shapely import ops as sops
from shapely import geometry as sgeometry
from shapely import prepared

import bpy
from bpy_extras.object_utils import AddObjectHelper, object_data_add
from bpy_extras.object_utils import object_data_add
from mathutils import Vector

from . import utils
from . import simple

import mathutils
import math


from shapely import ops as sops
from shapely import geometry as sgeometry
from shapely import affinity, prepared


def addBridge(x, y, rot, sizex, sizey):
bpy.ops.mesh.primitive_plane_add(size=sizey*2, calc_uvs=True, enter_editmode=False, align='WORLD',
Expand Down Expand Up @@ -77,12 +78,12 @@ def addAutoBridges(o):
minx, miny, maxx, maxy = c.bounds
d1 = c.project(sgeometry.Point(maxx + 1000, (maxy + miny) / 2.0))
p = c.interpolate(d1)
bo = addBridge(p.x, p.y, -math.pi / 2, o.bridges_width, o.cutter_diameter * 1)
bo = addBridge(p.x, p.y, -pi / 2, o.bridges_width, o.cutter_diameter * 1)
g.objects.link(bo)
bpy.context.collection.objects.unlink(bo)
d1 = c.project(sgeometry.Point(minx - 1000, (maxy + miny) / 2.0))
p = c.interpolate(d1)
bo = addBridge(p.x, p.y, math.pi / 2, o.bridges_width, o.cutter_diameter * 1)
bo = addBridge(p.x, p.y, pi / 2, o.bridges_width, o.cutter_diameter * 1)
g.objects.link(bo)
bpy.context.collection.objects.unlink(bo)
d1 = c.project(sgeometry.Point((minx + maxx) / 2.0, maxy + 1000))
Expand All @@ -92,7 +93,7 @@ def addAutoBridges(o):
bpy.context.collection.objects.unlink(bo)
d1 = c.project(sgeometry.Point((minx + maxx) / 2.0, miny - 1000))
p = c.interpolate(d1)
bo = addBridge(p.x, p.y, math.pi, o.bridges_width, o.cutter_diameter * 1)
bo = addBridge(p.x, p.y, pi, o.bridges_width, o.cutter_diameter * 1)
g.objects.link(bo)
bpy.context.collection.objects.unlink(bo)

Expand Down Expand Up @@ -153,8 +154,8 @@ def useBridges(ch, o):
if vi + 1 < len(ch_points):
i2 = vi + 1
chp2 = ch_points[vi + 1] # Vector(ch_points[vi+1])
v1 = mathutils.Vector(chp1)
v2 = mathutils.Vector(chp2)
v1 = Vector(chp1)
v2 = Vector(chp2)
if v1.z < bridgeheight or v2.z < bridgeheight:
v = v2 - v1
p2 = sgeometry.Point(chp2)
Expand All @@ -181,13 +182,13 @@ def useBridges(ch, o):
newpoints.append((chp1[0], chp1[1], max(chp1[2], bridgeheight)))
cpoints = []
if itpoint:
pt = mathutils.Vector((intersections.x, intersections.y, intersections.z))
pt = Vector((intersections.x, intersections.y, intersections.z))
cpoints = [pt]

elif itmpoint:
cpoints = []
for p in intersections.geoms:
pt = mathutils.Vector((p.x, p.y, p.z))
pt = Vector((p.x, p.y, p.z))
cpoints.append(pt)
# ####sort collisions here :(
ncpoints = []
Expand Down Expand Up @@ -243,7 +244,7 @@ def useBridges(ch, o):
if z == bridgeheight: # find all points with z = bridge height
count += 1
if isedge == 1: # This is to subdivide edges which are longer than the width of the bridge
edgelength = math.hypot(x - x2, y - y2)
edgelength = hypot(x - x2, y - y2)
if edgelength > o.bridges_width:
# make new vertex
verts.append(((x + x2)/2, (y + y2)/2, o.minz))
Expand Down
Loading

0 comments on commit 7325fb1

Please sign in to comment.