Added collection as operation source, fixed drill operation

pull/141/head
ksuprynowicz 2020-01-09 22:53:14 +01:00
rodzic 76ff6c75da
commit 10ecfeb239
6 zmienionych plików z 40 dodań i 40 usunięć

Wyświetl plik

@ -259,11 +259,11 @@ def operationValid(self, context):
if not o.object_name in bpy.data.objects:
o.valid = False;
o.warnings = invalidmsg
if o.geometry_source == 'GROUP':
if not o.group_name in bpy.data.groups:
if o.geometry_source == 'COLLECTION':
if not o.collection_name in bpy.data.collections:
o.valid = False;
o.warnings = invalidmsg
elif len(bpy.data.groups[o.group_name].objects) == 0:
elif len(bpy.data.collections[o.collection_name].objects) == 0:
o.valid = False;
o.warnings = invalidmsg
@ -413,10 +413,9 @@ class camOperation(bpy.types.PropertyGroup):
name="Parent path to object",
description="Parent generated CAM path to source object",
default=False)
# group = bpy.props.StringProperty(name='Object group', description='group of objects which will be included in this operation')
object_name: bpy.props.StringProperty(name='Object', description='object handled by this operation',
update=updateOperationValid)
group_name: bpy.props.StringProperty(name='Group', description='Object group handled by this operation',
collection_name: bpy.props.StringProperty(name='Collection', description='Object collection handled by this operation',
update=updateOperationValid)
curve_object: bpy.props.StringProperty(name='Curve source',
description='curve which will be sampled along the 3d object',
@ -427,7 +426,7 @@ class camOperation(bpy.types.PropertyGroup):
source_image_name: bpy.props.StringProperty(name='image_source', description='image source', update=operationValid)
geometry_source: EnumProperty(name='Source of data',
items=(
('OBJECT', 'object', 'a'), ('GROUP', 'Group of objects', 'a'),
('OBJECT', 'object', 'a'), ('COLLECTION', 'Collection of objects', 'a'),
('IMAGE', 'Image', 'a')),
description='Geometry source',
default='OBJECT', update=updateOperationValid)
@ -522,7 +521,6 @@ class camOperation(bpy.types.PropertyGroup):
cut_type: EnumProperty(name='Cut',
items=(('OUTSIDE', 'Outside', 'a'), ('INSIDE', 'Inside', 'a'), ('ONLINE', 'On line', 'a')),
description='Type of cutter used', default='OUTSIDE', update=updateRest)
# render_all = bpy.props.BoolProperty(name="Use all geometry",description="use also other objects in the scene", default=True)#replaced with groups support
outlines_count: bpy.props.IntProperty(name="Outlines count`EXPERIMENTAL", description="Outlines count", default=1,
min=1, max=32, update=updateCutout)
@ -764,7 +762,7 @@ class camOperation(bpy.types.PropertyGroup):
bridges_height: bpy.props.FloatProperty(name='height of bridges',
description="Height from the bottom of the cutting operation",
default=0.0005, unit='LENGTH', precision=PRECISION, update=updateBridges)
bridges_collection_name: bpy.props.StringProperty(name='Bridges Group', description='Group of curves used as bridges',
bridges_collection_name: bpy.props.StringProperty(name='Bridges Collection', description='Collection of curves used as bridges',
update=operationValid)
use_bridge_modifiers: BoolProperty(name="use bridge modifiers",
description="include bridge curve modifiers using render level when calculating operation, does not effect original bridge data",

Wyświetl plik

@ -147,6 +147,7 @@ def prepareBulletCollision(o):
progress('preparing collisions')
print(o.name)
active_collection = bpy.context.view_layer.active_layer_collection.collection
t = time.time()
s = bpy.context.scene
s.gravity = (0, 0, 0)
@ -194,6 +195,9 @@ def prepareBulletCollision(o):
snap_normal=(0, 0, 0), texture_space=False, release_confirm=False)
collisionob.location = collisionob.location * BULLET_SCALE
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
bpy.context.view_layer.objects.active = collisionob
active_collection.objects.unlink(collisionob)
#bpy.ops.collection.objects_remove(collection=active_collection_name)
getCutterBullet(o)

Wyświetl plik

@ -1615,7 +1615,7 @@ def renderSampleImage(o):
progress('getting zbuffer')
# print(o.zbuffer_image)
if o.geometry_source == 'OBJECT' or o.geometry_source == 'GROUP':
if o.geometry_source == 'OBJECT' or o.geometry_source == 'COLLECTION':
pixsize = o.pixsize
sx = o.max.x - o.min.x

Wyświetl plik

@ -734,7 +734,7 @@ class CamOrientationAdd(bpy.types.Operator):
oriob.empty_draw_size = 0.02 # 2 cm
simple.addToGroup(oriob, gname)
oriob.name = 'ori_' + o.name + '.' + str(len(bpy.data.groups[gname].objects)).zfill(3)
oriob.name = 'ori_' + o.name + '.' + str(len(bpy.data.collections[gname].objects)).zfill(3)
return {'FINISHED'}
@ -1247,7 +1247,7 @@ class CamMeshGetPockets(bpy.types.Operator):
# if the user decides to change the horizontal threshold property
for obj in cobs:
obj.select = True
bpy.ops.group.create(name="multi level pocket ")
bpy.ops.collection.create(name="multi level pocket ")
return {'FINISHED'}

Wyświetl plik

@ -163,7 +163,7 @@ class CAM_MATERIAL_Panel(CAMButtonsPanel, bpy.types.Panel):
if ao:
# label(text='dir(layout))
layout.template_running_jobs()
if ao.geometry_source in ['OBJECT', 'GROUP']:
if ao.geometry_source in ['OBJECT', 'COLLECTION']:
row = layout.row(align=True)
layout.prop(ao, 'material_from_model')
@ -241,7 +241,7 @@ class CAM_CHAINS_Panel(CAMButtonsPanel, bpy.types.Panel):
col.operator("scene.cam_chain_add", icon='ADD', text="")
# col.operator("scene.cam_operation_copy", icon='COPYDOWN', text="")
col.operator("scene.cam_chain_remove", icon='REMOVE', text="")
# if group:
# if collection:
# col.separator()
# col.operator("scene.cam_operation_move", icon='TRIA_UP', text="").direction = 'UP'
# col.operator("scene.cam_operation_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
@ -295,7 +295,7 @@ class CAM_OPERATIONS_Panel(CAMButtonsPanel, bpy.types.Panel):
col.operator("scene.cam_operation_add", icon='ADD', text="")
col.operator("scene.cam_operation_copy", icon='COPYDOWN', text="")
col.operator("scene.cam_operation_remove", icon='REMOVE', text="")
# if group:
# if collection:
col.separator()
col.operator("scene.cam_operation_move", icon='TRIA_UP', text="").direction = 'UP'
col.operator("scene.cam_operation_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
@ -341,22 +341,22 @@ class CAM_OPERATIONS_Panel(CAMButtonsPanel, bpy.types.Panel):
if not ao.strategy == 'CURVE':
if ao.geometry_source == 'OBJECT':
layout.prop_search(ao, "object_name", bpy.data, "objects")
elif ao.geometry_source == 'GROUP':
layout.prop_search(ao, "group_name", bpy.data, "groups")
elif ao.geometry_source == 'COLLECTION':
layout.prop_search(ao, "collection_name", bpy.data, "collections")
else:
layout.prop_search(ao, "source_image_name", bpy.data, "images")
else:
if ao.geometry_source == 'OBJECT':
layout.prop_search(ao, "object_name", bpy.data, "objects")
elif ao.geometry_source == 'GROUP':
layout.prop_search(ao, "group_name", bpy.data, "groups")
elif ao.geometry_source == 'COLLECTION':
layout.prop_search(ao, "collection_name", bpy.data, "collections")
if ao.strategy in ['CARVE', 'PROJECTED_CURVE']:
layout.prop_search(ao, "curve_object", bpy.data, "objects")
if ao.strategy == 'PROJECTED_CURVE':
layout.prop_search(ao, "curve_object1", bpy.data, "objects")
if use_experimental and ao.geometry_source in ['OBJECT', 'GROUP']:
if use_experimental and ao.geometry_source in ['OBJECT', 'COLLECTION']:
layout.prop(ao, 'use_modifiers')
layout.prop(ao, 'hide_all_others')
layout.prop(ao, 'parent_path_to_object')
@ -427,7 +427,7 @@ class CAM_OPERATION_PROPERTIES_Panel(CAMButtonsPanel, bpy.types.Panel):
if ao.strategy in ['BLOCK', 'SPIRAL', 'CIRCLES', 'OUTLINEFILL']:
layout.prop(ao, 'movement_insideout')
# if ao.geometry_source=='OBJECT' or ao.geometry_source=='GROUP':
# if ao.geometry_source=='OBJECT' or ao.geometry_source=='COLLECTION':
'''
o=bpy.data.objects[ao.object_name]
@ -507,12 +507,12 @@ class CAM_OPERATION_PROPERTIES_Panel(CAMButtonsPanel, bpy.types.Panel):
layout.prop(ao, 'skin')
# if gname in bpy.data.groups:
# if gname in bpy.data.collections:
# layout.label(text='orientations')
# group=bpy.data.groups[ao.name+'_orientations']
# layout.template_list("CAM_UL_orientations", '', group, "objects", ao, 'active_orientation')
# layout.prop(group.objects[ao.active_orientation],'location')
# layout.prop(group.objects[ao.active_orientation],'rotation_euler')
# collection=bpy.data.collections[ao.name+'_orientations']
# layout.template_list("CAM_UL_orientations", '', collection, "objects", ao, 'active_orientation')
# layout.prop(collection.objects[ao.active_orientation],'location')
# layout.prop(collection.objects[ao.active_orientation],'rotation_euler')
if ao.machine_axes == '3':
layout.prop(ao, 'array')
if ao.array:
@ -623,8 +623,8 @@ class CAM_OPTIMISATION_Panel(CAMButtonsPanel, bpy.types.Panel):
layout.prop(ao, 'optimize')
if ao.optimize:
layout.prop(ao, 'optimize_threshold')
if ao.geometry_source == 'OBJECT' or ao.geometry_source == 'GROUP':
exclude_exact = ao.strategy in ['WATERLINE', 'POCKET', 'CUTOUT', 'DRILL', 'PENCIL']
if ao.geometry_source == 'OBJECT' or ao.geometry_source == 'COLLECTION':
exclude_exact = ao.strategy in [ 'POCKET', 'CUTOUT', 'DRILL', 'PENCIL']
if not exclude_exact:
layout.prop(ao, 'use_exact')
if ao.use_exact:
@ -643,8 +643,6 @@ class CAM_OPTIMISATION_Panel(CAMButtonsPanel, bpy.types.Panel):
layout.prop(ao, 'simulation_detail')
layout.prop(ao, 'circle_detail')
layout.prop(ao, 'use_opencamlib')
# if not ao.use_exact:#this will be replaced with groups of objects.
# layout.prop(ao,'render_all')# replaced with groups support
class CAM_AREA_Panel(CAMButtonsPanel, bpy.types.Panel):
@ -673,7 +671,7 @@ class CAM_AREA_Panel(CAMButtonsPanel, bpy.types.Panel):
layout.prop(ao, 'ambient_radius')
layout.prop(ao, 'maxz') # experimental
if ao.geometry_source in ['OBJECT', 'GROUP']:
if ao.geometry_source in ['OBJECT', 'COLLECTION']:
layout.prop(ao, 'minz_from_ob')
if not ao.minz_from_ob:
layout.prop(ao, 'minz')

Wyświetl plik

@ -196,13 +196,13 @@ def getOperationSources(o):
# bpy.ops.object.select_all(action='DESELECT')
ob = bpy.data.objects[o.object_name]
o.objects = [ob]
elif o.geometry_source == 'GROUP':
group = bpy.data.groups[o.group_name]
o.objects = group.objects
elif o.geometry_source == 'COLLECTION':
collection = bpy.data.collections[o.collection_name]
o.objects = collection.objects
elif o.geometry_source == 'IMAGE':
o.use_exact = False
if o.geometry_source == 'OBJECT' or o.geometry_source == 'GROUP':
if o.geometry_source == 'OBJECT' or o.geometry_source == 'COLLECTION':
o.onlycurves = True
for ob in o.objects:
if ob.type == 'MESH':
@ -237,8 +237,8 @@ def getChangeData(o):
obs = []
if o.geometry_source == 'OBJECT':
obs = [bpy.data.objects[o.object_name]]
elif o.geometry_source == 'GROUP':
obs = bpy.data.groups[o.group_name].objects
elif o.geometry_source == 'COLLECTION':
obs = bpy.data.collections[o.collection_name].objects
for ob in obs:
changedata += str(ob.location)
changedata += str(ob.rotation_euler)
@ -249,7 +249,7 @@ def getChangeData(o):
def getBounds(o):
# print('kolikrat sem rpijde')
if o.geometry_source == 'OBJECT' or o.geometry_source == 'GROUP':
if o.geometry_source == 'OBJECT' or o.geometry_source == 'COLLECTION':
if o.material_from_model:
minx, miny, minz, maxx, maxy, maxz = getBoundsWorldspace(o.objects, o.use_modifiers)
@ -1733,7 +1733,7 @@ def getOperationSilhouete(operation):
if operation.update_silhouete_tag:
image = None
objects = None
if operation.geometry_source == 'OBJECT' or operation.geometry_source == 'GROUP':
if operation.geometry_source == 'OBJECT' or operation.geometry_source == 'COLLECTION':
if operation.onlycurves == False:
stype = 'OBJECTS'
else:
@ -2152,7 +2152,7 @@ def getBridgesPoly(o):
def useBridges(ch, o):
'''this adds bridges to chunks, takes the bridge-objects group and uses the curves inside it as bridges.'''
'''this adds bridges to chunks, takes the bridge-objects collection and uses the curves inside it as bridges.'''
bridgecollectionname = o.bridges_collection_name
bridgecollection = bpy.data.collections[bridgecollectionname]
if len(bridgecollection.objects) > 0:
@ -2670,7 +2670,7 @@ def strategy_drill(o):
"snap_target": 'CLOSEST', "snap_point": (0, 0, 0),
"snap_align": False, "snap_normal": (0, 0, 0),
"texture_space": False, "release_confirm": False})
bpy.ops.group.objects_remove_all()
#bpy.ops.collection.objects_remove_all()
bpy.ops.object.parent_clear(type='CLEAR_KEEP_TRANSFORM')
ob = bpy.context.active_object