kopia lustrzana https://github.com/vilemduha/blendercam
commit
84856fdc11
|
|
@ -960,13 +960,13 @@ class camOperation(bpy.types.PropertyGroup):
|
|||
material_from_model: bpy.props.BoolProperty(name="Estimate from model",
|
||||
description="Estimate material size from model", default=True,
|
||||
update=updateMaterial)
|
||||
material_radius_around_model: bpy.props.FloatProperty(name="radius around model",
|
||||
material_radius_around_model: bpy.props.FloatProperty(name='',
|
||||
description="How much to add to model size on all sides",
|
||||
default=0.0, unit='LENGTH', precision=PRECISION,
|
||||
update=updateMaterial)
|
||||
material_center_x: bpy.props.BoolProperty(name="Center with X axis", description="Position model centered on X",
|
||||
material_center_x: bpy.props.BoolProperty(name="Center on X axis", description="Position model centered on X",
|
||||
default=False, update=updateMaterial)
|
||||
material_center_y: bpy.props.BoolProperty(name="Center with Y axis", description="Position model centered on Y",
|
||||
material_center_y: bpy.props.BoolProperty(name="Center on Y axis", description="Position model centered on Y",
|
||||
default=False, update=updateMaterial)
|
||||
|
||||
material_Z: bpy.props.EnumProperty(name="Z placement", items=(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import bpy
|
||||
import sys
|
||||
|
||||
# Panel definitions
|
||||
class CAMButtonsPanel:
|
||||
|
|
@ -17,7 +16,6 @@ class CAMButtonsPanel:
|
|||
def __init__(self):
|
||||
self.active_op = self.active_operation()
|
||||
|
||||
|
||||
def active_operation_index(self):
|
||||
return(bpy.context.scene.cam_active_operation)
|
||||
|
||||
|
|
@ -36,13 +34,3 @@ class CAMButtonsPanel:
|
|||
def has_operations(self):
|
||||
return (self.operations_count() > 0)
|
||||
|
||||
def opencamlib_version(self):
|
||||
try:
|
||||
import ocl
|
||||
except ImportError:
|
||||
try:
|
||||
import opencamlib as ocl
|
||||
except ImportError as e:
|
||||
return
|
||||
return(ocl.version())
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import bpy
|
|||
|
||||
from cam.simple import strInUnits
|
||||
from cam.ui_panels.buttons_panel import CAMButtonsPanel
|
||||
import cam.utils
|
||||
|
||||
# Info panel
|
||||
# This panel gives general information about the current operation
|
||||
|
|
@ -21,12 +22,10 @@ class CAM_INFO_Panel(CAMButtonsPanel, bpy.types.Panel):
|
|||
self.draw_active_op_warnings()
|
||||
self.draw_active_op_time()
|
||||
self.draw_active_op_money_cost()
|
||||
else:
|
||||
self.layout.label(text='No CAM operation created')
|
||||
|
||||
# Display the OpenCamLib version
|
||||
def draw_opencamlib_version(self):
|
||||
opencamlib_version = self.opencamlib_version()
|
||||
opencamlib_version = cam.utils.opencamlib_version()
|
||||
if opencamlib_version is None:
|
||||
self.layout.label(text = "Opencamlib is not installed")
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -10,27 +10,42 @@ class CAM_MATERIAL_Panel(CAMButtonsPanel, bpy.types.Panel):
|
|||
COMPAT_ENGINES = {'BLENDERCAM_RENDER'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
scene = bpy.context.scene
|
||||
|
||||
if len(scene.cam_operations) == 0:
|
||||
layout.label(text='Add operation first')
|
||||
if len(scene.cam_operations) > 0:
|
||||
ao = scene.cam_operations[scene.cam_active_operation]
|
||||
if ao:
|
||||
layout.template_running_jobs()
|
||||
if ao.geometry_source in ['OBJECT', 'COLLECTION']:
|
||||
layout.prop(ao, 'material_from_model')
|
||||
if self.active_op is None: return
|
||||
|
||||
if ao.material_from_model:
|
||||
layout.prop(ao, 'material_radius_around_model')
|
||||
else:
|
||||
layout.prop(ao, 'material_origin')
|
||||
layout.prop(ao, 'material_size')
|
||||
# FIXME: This function displays the progression of a job with a progress bar
|
||||
# Commenting because it makes no sense here
|
||||
# Consider removing it entirely
|
||||
# self.layout.template_running_jobs()
|
||||
|
||||
layout.prop(ao, 'material_center_x')
|
||||
layout.prop(ao, 'material_center_y')
|
||||
layout.prop(ao, 'material_Z')
|
||||
layout.operator("object.cam_position", text="Position object")
|
||||
else:
|
||||
layout.label(text='Estimated from image')
|
||||
if not self.active_op.geometry_source in ['OBJECT', 'COLLECTION']:
|
||||
self.layout.label(text='Estimated from image')
|
||||
return
|
||||
|
||||
self.layout.prop(self.active_op, 'material_from_model')
|
||||
|
||||
if self.active_op.material_from_model:
|
||||
self.draw_estimate_material_from_model()
|
||||
else:
|
||||
self.draw_custom_material_size_and_origin()
|
||||
|
||||
self.draw_axis_alignment()
|
||||
|
||||
# Display section selecting the radius around the model
|
||||
def draw_estimate_material_from_model(self):
|
||||
row_radius = self.layout.row()
|
||||
row_radius.label(text="Radius around model")
|
||||
row_radius.prop(self.active_op, 'material_radius_around_model')
|
||||
|
||||
# Display section showing custom material size
|
||||
def draw_custom_material_size_and_origin(self):
|
||||
self.layout.prop(self.active_op, 'material_origin')
|
||||
self.layout.prop(self.active_op, 'material_size')
|
||||
|
||||
# Display Axis alignment section
|
||||
def draw_axis_alignment(self):
|
||||
row_axis = self.layout.row()
|
||||
row_axis.prop(self.active_op, 'material_center_x')
|
||||
row_axis.prop(self.active_op, 'material_center_y')
|
||||
self.layout.prop(self.active_op, 'material_Z')
|
||||
self.layout.operator("object.cam_position", text="Position object")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import bpy
|
||||
from cam.ui_panels.buttons_panel import CAMButtonsPanel
|
||||
import cam.utils
|
||||
|
||||
class CAM_OPTIMISATION_Panel(CAMButtonsPanel, bpy.types.Panel):
|
||||
"""CAM optimisation panel"""
|
||||
|
|
@ -9,42 +10,38 @@ class CAM_OPTIMISATION_Panel(CAMButtonsPanel, bpy.types.Panel):
|
|||
COMPAT_ENGINES = {'BLENDERCAM_RENDER'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
scene = bpy.context.scene
|
||||
if self.active_op is None: return
|
||||
if not self.active_op.valid: return
|
||||
|
||||
if len(scene.cam_operations) == 0:
|
||||
layout.label(text='Add operation first')
|
||||
if len(scene.cam_operations) > 0:
|
||||
ao = scene.cam_operations[scene.cam_active_operation]
|
||||
if ao.valid:
|
||||
layout.prop(ao, 'optimize')
|
||||
if ao.optimize:
|
||||
layout.prop(ao, 'optimize_threshold')
|
||||
if ao.geometry_source == 'OBJECT' or ao.geometry_source == 'COLLECTION':
|
||||
exclude_exact = ao.strategy in ['MEDIAL_AXIS', 'POCKET', 'CUTOUT', 'DRILL', 'PENCIL',
|
||||
'CURVE']
|
||||
if not exclude_exact:
|
||||
layout.prop(ao, 'use_exact')
|
||||
layout.label(text="Exact mode must be set for opencamlib to work ")
|
||||
ao = self.active_op
|
||||
|
||||
opencamlib_version = self.opencamlib_version()
|
||||
if opencamlib_version is None:
|
||||
layout.label(text="Opencamlib is NOT available ")
|
||||
layout.prop(ao, 'exact_subdivide_edges')
|
||||
else:
|
||||
layout.label(text=f"Opencamlib v{opencamlib_version} installed")
|
||||
layout.prop(ao, 'use_opencamlib')
|
||||
self.layout.prop(ao, 'optimize')
|
||||
if ao.optimize:
|
||||
self.layout.prop(ao, 'optimize_threshold')
|
||||
if ao.geometry_source == 'OBJECT' or ao.geometry_source == 'COLLECTION':
|
||||
exclude_exact = ao.strategy in ['MEDIAL_AXIS', 'POCKET', 'CUTOUT', 'DRILL', 'PENCIL',
|
||||
'CURVE']
|
||||
if not exclude_exact:
|
||||
self.layout.prop(ao, 'use_exact')
|
||||
self.layout.label(text="Exact mode must be set for opencamlib to work ")
|
||||
|
||||
if exclude_exact or not ao.use_exact:
|
||||
layout.prop(ao, 'pixsize')
|
||||
layout.prop(ao, 'imgres_limit')
|
||||
opencamlib_version = cam.utils.opencamlib_version()
|
||||
if opencamlib_version is None:
|
||||
self.layout.label(text="Opencamlib is NOT available ")
|
||||
self.layout.prop(ao, 'exact_subdivide_edges')
|
||||
else:
|
||||
self.layout.prop(ao, 'use_opencamlib')
|
||||
|
||||
sx = ao.max.x - ao.min.x
|
||||
sy = ao.max.y - ao.min.y
|
||||
resx = int(sx / ao.pixsize)
|
||||
resy = int(sy / ao.pixsize)
|
||||
l = 'resolution: ' + str(resx) + ' x ' + str(resy)
|
||||
layout.label(text=l)
|
||||
if exclude_exact or not ao.use_exact:
|
||||
self.layout.prop(ao, 'pixsize')
|
||||
self.layout.prop(ao, 'imgres_limit')
|
||||
|
||||
layout.prop(ao, 'simulation_detail')
|
||||
layout.prop(ao, 'circle_detail')
|
||||
sx = ao.max.x - ao.min.x
|
||||
sy = ao.max.y - ao.min.y
|
||||
resx = int(sx / ao.pixsize)
|
||||
resy = int(sy / ao.pixsize)
|
||||
l = 'resolution: ' + str(resx) + ' x ' + str(resy)
|
||||
self.layout.label(text=l)
|
||||
|
||||
self.layout.prop(ao, 'simulation_detail')
|
||||
self.layout.prop(ao, 'circle_detail')
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
# blender CAM utils.py (c) 2012 Vilem Novak
|
||||
#
|
||||
# ***** BEGIN GPL LICENSE BLOCK *****
|
||||
|
|
@ -52,6 +53,15 @@ from shapely import geometry as sgeometry
|
|||
# from shapely.geometry import * not possible until Polygon libs gets out finally..
|
||||
SHAPELY = True
|
||||
|
||||
def opencamlib_version():
|
||||
try:
|
||||
import ocl
|
||||
except ImportError:
|
||||
try:
|
||||
import opencamlib as ocl
|
||||
except ImportError as e:
|
||||
return
|
||||
return(ocl.version())
|
||||
|
||||
def positionObject(operation):
|
||||
ob = bpy.data.objects[operation.object_source]
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue