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 00910ea commit a2a6eb0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
15 changes: 9 additions & 6 deletions scripts/addons/cam/opencamlib/oclSample.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import os
from math import (
radians,
tan
)

try:
import ocl
except ImportError:
try:
import opencamlib as ocl
except ImportError:
pass
import tempfile

from io_mesh_stl import blender_utils
import mathutils
import math

from ..simple import activate
from ..exception import *
from ..exception import CamException
from ..async_op import progress_async

OCL_SCALE = 1000.0
Expand Down Expand Up @@ -50,9 +53,9 @@ async def ocl_sample(operation, chunks, use_cached_mesh=False):
op_cutter_type = operation.cutter_type
op_cutter_diameter = operation.cutter_diameter
op_minz = operation.minz
op_cutter_tip_angle = math.radians(operation.cutter_tip_angle)/2
op_cutter_tip_angle = radians(operation.cutter_tip_angle)/2
if op_cutter_type == "VCARVE":
cutter_length = (op_cutter_diameter/math.tan(op_cutter_tip_angle))/2
cutter_length = (op_cutter_diameter/tan(op_cutter_tip_angle))/2
else:
cutter_length = 10

Expand Down
31 changes: 15 additions & 16 deletions scripts/addons/cam/opencamlib/opencamlib.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
# used by OpenCAMLib sampling
import os
from subprocess import call
import tempfile

import bpy
import numpy as np
try:
import ocl
except ImportError:
try:
import opencamlib as ocl
except ImportError:
pass
import os
import tempfile
import numpy as np

from subprocess import call
from ..collision import BULLET_SCALE
from .. import simple
import bpy

from ..constants import BULLET_SCALE
from ..simple import activate
from .. import utils
from ..chunk import camPathChunk
from ..simple import *
from ..cam_chunk import camPathChunk
from ..async_op import progress_async
from shapely import geometry as sgeometry
from .oclSample import (
get_oclSTL,
ocl_sample
Expand Down Expand Up @@ -146,12 +145,12 @@ def oclWaterlineLayerHeights(operation):
return layers


def oclGetMedialAxis(operation, chunks):
oclWaterlineHeightsToOCL(operation)
operationSettingsToOCL(operation)
curvesToOCL(operation)
call([PYTHON_BIN, os.path.join(bpy.utils.script_path_pref(), "addons", "cam", "opencamlib", "ocl.py")])
waterlineChunksFromOCL(operation, chunks)
# def oclGetMedialAxis(operation, chunks):
# oclWaterlineHeightsToOCL(operation)
# operationSettingsToOCL(operation)
# curvesToOCL(operation)
# call([PYTHON_BIN, os.path.join(bpy.utils.script_path_pref(), "addons", "cam", "opencamlib", "ocl.py")])
# waterlineChunksFromOCL(operation, chunks)


async def oclGetWaterline(operation, chunks):
Expand Down

0 comments on commit a2a6eb0

Please sign in to comment.