WIP port constraints module. See #1222.

This commit is contained in:
Dion Moult
2021-01-23 16:32:52 +11:00
parent d0b2bf85cc
commit 9b6366ddac
16 changed files with 526 additions and 286 deletions
@@ -202,67 +202,6 @@ class RemoveMaterialPset(bpy.types.Operator):
return {"FINISHED"}
class AddConstraint(bpy.types.Operator):
bl_idname = "bim.add_constraint"
bl_label = "Add Constraint"
def execute(self, context):
constraint = bpy.context.scene.BIMProperties.constraints.add()
constraint.name = "New Constraint"
return {"FINISHED"}
class RemoveConstraint(bpy.types.Operator):
bl_idname = "bim.remove_constraint"
bl_label = "Remove Constraint"
index: bpy.props.IntProperty()
def execute(self, context):
bpy.context.scene.BIMProperties.constraints.remove(self.index)
return {"FINISHED"}
class AssignConstraint(bpy.types.Operator):
bl_idname = "bim.assign_constraint"
bl_label = "Assign Constraint"
def execute(self, context):
identification = bpy.context.scene.BIMProperties.constraints[
bpy.context.scene.BIMProperties.active_constraint_index
].name
for obj in bpy.context.selected_objects:
if obj.BIMObjectProperties.constraints.get(identification):
continue
constraint = obj.BIMObjectProperties.constraints.add()
constraint.name = identification
return {"FINISHED"}
class UnassignConstraint(bpy.types.Operator):
bl_idname = "bim.unassign_constraint"
bl_label = "Unassign Constraint"
def execute(self, context):
identification = bpy.context.scene.BIMProperties.constraints[
bpy.context.scene.BIMProperties.active_constraint_index
].name
for obj in bpy.context.selected_objects:
index = obj.BIMObjectProperties.constraints.find(identification)
if index >= 0:
obj.BIMObjectProperties.constraints.remove(index)
return {"FINISHED"}
class RemoveObjectConstraint(bpy.types.Operator):
bl_idname = "bim.remove_object_constraint"
bl_label = "Remove Object Constraint"
index: bpy.props.IntProperty()
def execute(self, context):
bpy.context.active_object.BIMObjectProperties.constraints.remove(self.index)
return {"FINISHED"}
class AddMaterialAttribute(bpy.types.Operator):
bl_idname = "bim.add_material_attribute"
bl_label = "Add Material Attribute"