Skip to content

Commit

Permalink
Merge pull request #183 from abosafia/master
Browse files Browse the repository at this point in the history
get back object silhouette
  • Loading branch information
pppalain authored Sep 20, 2024
2 parents bf4b75a + 1063ea1 commit 7f445a8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 49 deletions.
4 changes: 2 additions & 2 deletions scripts/addons/cam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
CamCurveRemoveDoubles,
CamMeshGetPockets,
CamOffsetSilhouete,
# CamObjectSilhouete,
CamObjectSilhouete,
)
from .engine import (
CNCCAM_ENGINE,
Expand Down Expand Up @@ -206,7 +206,7 @@
CamCurveRemoveDoubles,
CamMeshGetPockets,
CamOffsetSilhouete,
# CamObjectSilhouete,
CamObjectSilhouete,

# .engine
CNCCAM_ENGINE,
Expand Down
88 changes: 43 additions & 45 deletions scripts/addons/cam/curvecamtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,29 +608,27 @@ def poll(cls, context):
def execute(self, context):
obj = bpy.context.selected_objects
for ob in obj:
if ob.type == 'CURVE' and ob.data.splines[0].type == 'BEZIER':
if self.keep_bezier:
bpy.ops.curvetools.operatorsplinesremoveshort()
bpy.context.view_layer.objects.active = ob
ob.data.resolution_u = 64
if bpy.context.mode == 'OBJECT':
if ob.type == 'CURVE':
if ob.data.splines[0].type == 'BEZIER':
if self.keep_bezier:
bpy.ops.curvetools.operatorsplinesremoveshort()
bpy.context.view_layer.objects.active = ob
ob.data.resolution_u = 64
if bpy.context.mode == 'OBJECT':
bpy.ops.object.editmode_toggle()
bpy.ops.curve.select_all()
bpy.ops.curve.remove_double(distance=self.merg_distance)
bpy.ops.object.editmode_toggle()
bpy.ops.curve.select_all()
bpy.ops.curve.remove_double(distance=self.merg_distance)
bpy.ops.object.editmode_toggle()
else:
mode = False
if ob.type == 'CURVE' and bpy.context.mode == 'EDIT_CURVE':
if bpy.context.mode == 'EDIT_CURVE':
bpy.ops.object.editmode_toggle()
mode = True
bpy.ops.object.convert(target='MESH')
bpy.ops.object.editmode_toggle()
bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.remove_doubles(threshold= self.merg_distance)
bpy.ops.object.editmode_toggle()
bpy.ops.object.convert(target='CURVE')
if mode:
bpy.ops.object.editmode_toggle()

return {'FINISHED'}

def draw(self, context):
Expand Down Expand Up @@ -844,36 +842,36 @@ def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)

# Finds object silhouette, usefull for meshes, since with curves it's not needed.
'''class CamObjectSilhouete(Operator):
"""Object Silhouette"""
bl_idname = "object.silhouete"
bl_label = "Object Silhouette"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
# return context.active_object is not None and (context.active_object.type == 'CURVE'
# or context.active_object.type == 'FONT' or context.active_object.type == 'MESH')
return context.active_object is not None and (
context.active_object.type == 'FONT' or
context.active_object.type == 'MESH')
# this is almost same as getobjectoutline, just without the need of operation data
def execute(self, context):
ob = bpy.context.active_object
self.silh = utils.getObjectSilhouete(
'OBJECTS', objects=bpy.context.selected_objects)
bpy.context.scene.cursor.location = (0, 0, 0)
# smp=sgeometry.asMultiPolygon(self.silh)
for smp in self.silh.geoms:
polygon_utils_cam.shapelyToCurve(
ob.name + '_silhouette', smp, 0) #
# bpy.ops.object.convert(target='CURVE')
simple.join_multiple(ob.name + '_silhouette')
bpy.context.scene.cursor.location = ob.location
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
bpy.ops.object.curve_remove_doubles()
return {'FINISHED'}'''
class CamObjectSilhouete(Operator):
"""Object Silhouette"""
bl_idname = "object.silhouete"
bl_label = "Object Silhouette"
bl_options = {'REGISTER', 'UNDO'}

@classmethod
def poll(cls, context):
# return context.active_object is not None and (context.active_object.type == 'CURVE'
# or context.active_object.type == 'FONT' or context.active_object.type == 'MESH')
return context.active_object is not None and (
context.active_object.type == 'FONT' or
context.active_object.type == 'MESH')

# this is almost same as getobjectoutline, just without the need of operation data
def execute(self, context):
ob = bpy.context.active_object
self.silh = utils.getObjectSilhouete(
'OBJECTS', objects=bpy.context.selected_objects)
bpy.context.scene.cursor.location = (0, 0, 0)
# smp=sgeometry.asMultiPolygon(self.silh)
for smp in self.silh.geoms:
polygon_utils_cam.shapelyToCurve(
ob.name + '_silhouette', smp, 0) #
# bpy.ops.object.convert(target='CURVE')
simple.join_multiple(ob.name + '_silhouette')
bpy.context.scene.cursor.location = ob.location
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
bpy.ops.object.curve_remove_doubles()
return {'FINISHED'}
# ---------------------------------------------------


2 changes: 1 addition & 1 deletion scripts/addons/cam/pie_menu/pie_curvetools.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def draw(self, context):
# Bottom
box = pie.box()
column = box.column(align=True)
#column.operator("object.silhouete")
column.operator("object.silhouete")
column.operator("object.silhouete_offset")
column.operator("object.curve_remove_doubles")
column.operator("object.mesh_get_pockets")
Expand Down
2 changes: 1 addition & 1 deletion scripts/addons/cam/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def draw(self, context):
layout.operator("object.curve_intarsion")
layout.operator("object.curve_overcuts")
layout.operator("object.curve_overcuts_b")
#layout.operator("object.silhouete")
layout.operator("object.silhouete")
layout.operator("object.silhouete_offset")
layout.operator("object.curve_remove_doubles")
layout.operator("object.mesh_get_pockets")
Expand Down

0 comments on commit 7f445a8

Please sign in to comment.