Skip to content

Instantly share code, notes, and snippets.

@nedrops
Last active July 15, 2018 11:03
Show Gist options
  • Save nedrops/e32e4b158f5729b197fdf6574bba92b9 to your computer and use it in GitHub Desktop.
Save nedrops/e32e4b158f5729b197fdf6574bba92b9 to your computer and use it in GitHub Desktop.
bl_info = {
"name": "N Tools",
"author": "kuku",
"version": (2, 1),
"blender": (2, 79, 0),
"description": "Duplicate Tools, Auto Connect and Cut With Planes",
"support": "TESTING",
"category": "Object"
}
import bpy
import bmesh
import math
from operator import itemgetter
import random
#import datetime
###### Duplicate Tools Function ##########################################################################
def instance(obj):
instance_object = bpy.data.objects.new(obj.name, obj.data)
bpy.context.scene.objects.link(instance_object)
return instance_object
def vec(x,y):
rz2=55
if x==0:
rz=math.pi/2
else:
rz=math.atan(y/x)
if x<0 or (x==0 and y<0):
rz=rz+math.pi
return rz
def building(unitMesh,MeshORLamp,replaceBool):
motoObj=bpy.context.object
motoMesh=motoObj.data
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)####
bpy.ops.object.select_all(action='DESELECT')
motoObj.select=True
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.select_mode(type='FACE')
bm=bmesh.from_edit_mesh(motoMesh)
list=[i for i in bm.faces if i.select==True]
for i in list:
face=i
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.select_all(action='DESELECT')
bm=bmesh.from_edit_mesh(motoMesh)
face.select=True
if replaceBool==False:
bpy.ops.mesh.duplicate()
bpy.ops.mesh.separate(type='SELECTED')
print(face)######################
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
sepObjList=[x for x in bpy.context.selected_objects if not x==motoObj]
sepObjList.sort(key=lambda x:x.name)
bpy.ops.object.empty_add(type='CUBE',location=[0,0,0])
empObj=bpy.context.object
empObj.name='Empty-'+unitMesh.name
for j in sepObjList:
nor=j.data.polygons[0].normal
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
print(nor)######################
rz=-vec(nor[0],nor[1])-math.pi/2
j.rotation_euler=[0,0,rz]
bpy.ops.object.select_all(action='DESELECT')
j.select=True
bpy.ops.object.scale_clear()
bpy.ops.object.location_clear()
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
nor2=j.data.polygons[0].normal
print(nor2)######################
rx=-vec(nor2[1],nor2[2])+math.pi/2
j.rotation_euler=[rx,0,0]
bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
j.rotation_euler=[-rx,0,-rz]
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')
rot=j.rotation_euler
loc=j.location
unitObject=bpy.data.objects.new(unitMesh.name, unitMesh)
ins=unitObject
ins.rotation_euler=rot
ins.location=loc
print('ins',ins)######################
if MeshORLamp == 'Mesh':
dimX=j.dimensions[0]
dimY=j.dimensions[1]
dimZ=(dimX/ins.dimensions[1])*ins.dimensions[2]
ins.dimensions=[dimX,dimY,dimZ]
bpy.context.scene.objects.link(unitObject)
bpy.ops.object.select_all(action='DESELECT')
unitObject.select=True
bpy.context.scene.objects.active=empObj
bpy.ops.object.parent_set()
bpy.ops.object.select_all(action='DESELECT')
j.select=True
bpy.ops.object.delete()
empObj.location=motoObj.location
empObj.rotation_euler=motoObj.rotation_euler
empObj.scale=motoObj.scale
###### Auto Connect Function ##########################################################################
def contactJudgment(ObjectA,ObjectB,Margin,Threshold,Distance):
FaceLen=len(ObjectA.data.polygons)+len(ObjectB.data.polygons)
VertexLen=len(ObjectA.data.vertices)+len(ObjectB.data.vertices)
bpy.ops.object.select_all(action='DESELECT')
ObjectA.select=True
bpy.ops.object.duplicate()
ObjectADup=bpy.context.selected_objects[0]
bpy.context.scene.objects.active=ObjectADup
#Dispalce Modifier
if Margin > 0:
bpy.ops.object.modifier_add(type='DISPLACE')
DisplaceModi=ObjectADup.modifiers[-1]
DisplaceModi.mid_level=0
DisplaceModi.direction='NORMAL'
DisplaceModi.strength=Margin
bpy.ops.object.modifier_apply(apply_as='DATA', modifier=DisplaceModi.name)
#Boolean Modifier
bpy.ops.object.modifier_add(type='BOOLEAN')
BoolModi=ObjectADup.modifiers[-1]
BoolModi.object=ObjectB
BoolModi.operation = 'UNION'
BoolModi.double_threshold=Threshold
bpy.ops.object.modifier_apply(apply_as='DATA', modifier=BoolModi.name)
#Remove Doubles
if Distance >= 0:
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
BmeshObj=bmesh.from_edit_mesh(bpy.context.edit_object.data)
bmesh.ops.remove_doubles(BmeshObj,verts=BmeshObj.verts,dist=Distance)
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
###############
ObjectADupFaceLen=len(ObjectADup.data.polygons)
ObjectADupVertexLen=len(ObjectADup.data.vertices)
bpy.ops.object.delete()
print(ObjectADupFaceLen,ObjectADupVertexLen,FaceLen,VertexLen)
return not [FaceLen,VertexLen]==[ObjectADupFaceLen,ObjectADupVertexLen]
def connectObject(ObjectA,ObjectB):
bpy.ops.object.select_all(action='DESELECT')
#ObjectA.select=True
#ObjectB.select=True
#bpy.context.scene.objects.active=ObjectA
#bpy.ops.rigidbody.connect(pivot_type='CENTER', connection_pattern='SELECTED_TO_ACTIVE')
#Low Level RigidBody Connect
name='Constraint-'+ObjectA.name+'-'+ObjectB.name
Empty=bpy.data.objects.new(name,None)
ObjectAWorldPosition=ObjectA.matrix_world.to_translation()
ObjectBWorldPosition=ObjectB.matrix_world.to_translation()
Empty.location.x=(ObjectAWorldPosition[0] + ObjectBWorldPosition[0])/2
Empty.location.y=(ObjectAWorldPosition[1] + ObjectBWorldPosition[1])/2
Empty.location.z=(ObjectAWorldPosition[2] + ObjectBWorldPosition[2])/2
bpy.context.scene.objects.link(Empty)
bpy.ops.object.select_all(action='DESELECT')
bpy.context.scene.objects.active=Empty
bpy.ops.rigidbody.constraint_add()
Empty.rigid_body_constraint.object1 = ObjectA
Empty.rigid_body_constraint.object2 = ObjectB
print(ObjectA,ObjectB)
def connectPairList(PairList):
List=[]
Empty=bpy.data.objects.new('Empty',None)
bpy.context.scene.objects.link(Empty)
bpy.context.scene.objects.active=Empty
bpy.ops.rigidbody.constraint_add()
for i in PairList:
Obj=[j for j in i]
ObjectA=Obj[0]
ObjectB=Obj[1]
Name='Constraint-'+ObjectA.name+'-'+ObjectB.name
Joint=Empty.copy()
Joint.name=Name
ObjectAWorldPosition=ObjectA.matrix_world.to_translation()
ObjectBWorldPosition=ObjectB.matrix_world.to_translation()
Joint.location.x=(ObjectAWorldPosition[0] + ObjectBWorldPosition[0])/2
Joint.location.y=(ObjectAWorldPosition[1] + ObjectBWorldPosition[1])/2
Joint.location.z=(ObjectAWorldPosition[2] + ObjectBWorldPosition[2])/2
Joint.rigid_body_constraint.object1 = ObjectA
Joint.rigid_body_constraint.object2 = ObjectB
List.append((Empty,ObjectA,ObjectB))
bpy.context.scene.objects.link(Joint)
bpy.context.scene.objects.active=Joint
bpy.ops.object.group_link(group=bpy.context.scene.rigidbody_world.constraints.name)
print(Name)
bpy.ops.object.select_all(action='DESELECT')
Empty.select=True
bpy.ops.object.delete()
def measure(first, second):
x = second[0] - first[0]
y = second[1] - first[1]
z = second[2] - first[2]
distance = math.sqrt(x**2+y**2+z**2)
return distance
def getNearest(Object,SearchObjectList,TopN):
WorldPosition=Object.matrix_world.to_translation()
DisDict=[(j,measure(WorldPosition,(j.matrix_world.to_translation()))) for j in SearchObjectList]
SortedDisList=sorted(DisDict,key=itemgetter(1))
return SortedDisList[:TopN]
def autoConnect(Margin,Threshold,Distance,SearchNumber):
SelectedObjectList=[i for i in bpy.context.selected_objects if i.type=='MESH']
PairList=[]
for ObjectA in SelectedObjectList:
print(ObjectA)
if ObjectA.rigid_body==None:
bpy.ops.object.select_all(action='DESELECT')
ObjectA.select=True
bpy.context.scene.objects.active=ObjectA
bpy.ops.rigidbody.objects_add(type='ACTIVE')
SearchObjectList=SelectedObjectList.copy()
SearchObjectList.remove(ObjectA)
NearestObjectList=getNearest(ObjectA,SearchObjectList,SearchNumber)
for ObjectBTuple in NearestObjectList:
ObjectB=ObjectBTuple[0]
if {ObjectA,ObjectB} not in PairList and contactJudgment(ObjectA,ObjectB,Margin,Threshold,Distance):
PairList.append({ObjectA,ObjectB})
connectPairList(PairList)
def selectDuplicateJoint():
bpy.ops.object.select_all(action='SELECT')
SelectedObjectList=bpy.context.selected_objects
bpy.ops.object.select_all(action='DESELECT')
for i,Joint in enumerate(SelectedObjectList):
if Joint.rigid_body_constraint==None:
break
ObjectSet={Joint.rigid_body_constraint.object1 , Joint.rigid_body_constraint.object2}
for SearchJoint in SelectedObjectList[i+1:]:
if SearchJoint.rigid_body_constraint==None:
break
SearchObjectSet={SearchJoint.rigid_body_constraint.object1 , SearchJoint.rigid_body_constraint.object2}
if ObjectSet==SearchObjectSet:
SearchJoint.select=True
###### Cut With Plane Function ##########################################################################
def cutWithPlane(Target,Plane,Margin,ExtrudeVector):
bpy.ops.object.select_all(action='DESELECT')
Target.select=True
bpy.ops.object.duplicate()
TargetDup=bpy.context.selected_objects[0]
bpy.ops.object.select_all(action='DESELECT')
Plane.select=True
bpy.ops.object.duplicate()
PlaneDup=bpy.context.selected_objects[0]
bpy.context.scene.objects.active=PlaneDup
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.extrude_region_move(
MESH_OT_extrude_region={"mirror":False},
TRANSFORM_OT_translate={
"value":(0, 0, ExtrudeVector),
"constraint_orientation":'NORMAL',
"constraint_axis":(False,False,True) } )
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
############################################
def cutBoolean(TargetDup,PlaneDup,Strength,Operation):
#'DIFFERENCE'or'INTERSECT'
if Margin > 0:
bpy.context.scene.objects.active=PlaneDup
bpy.ops.object.modifier_add(type='DISPLACE')
PlaneModi=PlaneDup.modifiers[-1]
PlaneModi.mid_level=0
PlaneModi.direction='NORMAL'
PlaneModi.strength=Strength
bpy.context.scene.objects.active=TargetDup
bpy.ops.object.modifier_add(type='BOOLEAN')
TargetModi=TargetDup.modifiers[-1]
TargetModi.solver = 'BMESH'
TargetModi.object = PlaneDup
TargetModi.operation = Operation
bpy.ops.object.modifier_apply(apply_as='DATA', modifier=TargetModi.name)
if Margin > 0:
bpy.context.scene.objects.active=PlaneDup
bpy.ops.object.modifier_remove(modifier=PlaneModi.name)
############################################
cutBoolean(Target,PlaneDup, Margin/2,'DIFFERENCE')
cutBoolean(TargetDup,PlaneDup,-Margin/2,'INTERSECT')
bpy.ops.object.select_all(action='DESELECT')
PlaneDup.select=True
bpy.ops.object.delete()
bpy.ops.object.select_all(action='DESELECT')
Target.select=True
TargetDup.select=True
bpy.context.scene.objects.active=Target
bpy.ops.object.join()
print(Target,Plane,Margin)
def getDiagonal(Object):
Dim=Object.dimensions
Diagonal=math.sqrt(Dim[0]**2+Dim[1]**2+Dim[2]**2)
return Diagonal
def cutWithPlanes(Margin):
Active=bpy.context.scene.objects.active
PlaneList=bpy.context.selected_objects
PlaneList.remove(Active)
bpy.ops.object.select_all(action='DESELECT')
Active.select=True
bpy.ops.object.duplicate()
Target=bpy.context.selected_objects[0]
Name=Active.name+'-cell.000'
Target.name=Name
GroupName='Group-'+Name
bpy.ops.group.create(name=GroupName)
ExtrudeVector=getDiagonal(Target)
for Plane in PlaneList:
print(Target,Plane)
cutWithPlane(Target,Plane,Margin,ExtrudeVector)
bpy.context.scene.objects.active=Target
Target.select=True
bpy.ops.mesh.separate(type='LOOSE')
bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_VOLUME', center='MEDIAN')
def createPlane(NumberOfPlane,FirstSubdivide=5,FirstFractal=1.0,SecondSubdivide=5,SecondFractal=1.0,SmoothFactor=1.0,SmoothRepeat=1,CenterOrLine='Line'):
Target=bpy.context.scene.objects.active
##get center
bpy.ops.object.select_all(action='DESELECT')
Target.select=True
bpy.ops.object.duplicate()
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='BOUNDS')
TargetDup=bpy.context.scene.objects.active
CenterLocation=TargetDup.matrix_world.to_translation()
CenterRotation=TargetDup.matrix_world.to_euler()
Dim=TargetDup.dimensions.copy()
DimList=[i for i in Dim]
LineLength=max(DimList)
MaxAxis='XYZ'[DimList.index(LineLength)]
Diagonal=getDiagonal(TargetDup)
bpy.ops.object.delete()
##
Radius=Diagonal/2
bpy.ops.mesh.primitive_plane_add(radius=Radius)
PlaneOrigin=bpy.context.scene.objects.active
PlaneName=Target.name+'CuttingPlane.000'
PlaneOrigin.name=PlaneName
GroupName='Group-'+PlaneName
bpy.ops.group.create(name=GroupName)
###
bpy.ops.object.empty_add()
Empty=bpy.context.scene.objects.active
Empty.name='Empty-'+PlaneName
PlaneOrigin.select+=True
bpy.ops.object.parent_no_inverse_set()
for i in range(NumberOfPlane):
bpy.ops.object.select_all(action='DESELECT')
bpy.context.scene.objects.active=PlaneOrigin
PlaneOrigin.select=True
bpy.ops.object.duplicate()#_move_linked()
PlaneDup=bpy.context.scene.objects.active
##EDIT
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.subdivide(number_cuts=FirstSubdivide, fractal=FirstFractal,seed=random.randint(0,255))
bpy.ops.mesh.subdivide(number_cuts=SecondSubdivide, fractal=SecondFractal,seed=random.randint(0,255))
bpy.ops.mesh.vertices_smooth(factor=SmoothFactor, repeat=SmoothRepeat)
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
####
if CenterOrLine=='Center':
Ro=(math.pi/NumberOfPlane)*(i+1)
PlaneDup.rotation_euler=[0,Ro,0]
if CenterOrLine=='Line':
PlaneDup.rotation_euler=[math.pi/2,0,0]
Loc=LineLength/(NumberOfPlane+1)*(i+1)-LineLength/2
PlaneDup.location=[0,Loc,0]
Empty.rotation_euler=CenterRotation
Empty.location=CenterLocation
print(MaxAxis)
bpy.ops.object.select_all(action='DESELECT')
Empty.select=True
if MaxAxis=='X':
bpy.ops.transform.rotate(value=-math.pi/2, constraint_axis=(False,False,True), constraint_orientation='LOCAL')
if MaxAxis=='Y':
bpy.ops.transform.rotate(value=-math.pi/2, constraint_axis=(False,True,False), constraint_orientation='LOCAL')
if MaxAxis=='Z':
bpy.ops.transform.rotate(value=-math.pi/2, constraint_axis=(True,False,False), constraint_orientation='LOCAL')
bpy.ops.object.select_all(action='DESELECT')
PlaneOrigin.select=True
bpy.ops.object.delete()
PlaneDup=bpy.context.scene.objects.active
bpy.ops.object.select_grouped(type='GROUP')
Target.select=True
bpy.context.scene.objects.active=Target
###### Duplicate Tools Addon Setting ##########################################################################
class OperatorBuildingMesh(bpy.types.Operator):
bl_idname = "object.building_mesh_operator"
bl_label = "Building Mesh Operator"
def execute(self, context):
building(bpy.data.meshes[context.scene.DuplicateToolsMesh],'Mesh',context.scene.DuplicateToolsReplace)
return {'FINISHED'}
class OperatorBuildingLamp(bpy.types.Operator):
bl_idname = "object.building_lamp_operator"
bl_label = "Building Lamp Operator"
def execute(self, context):
building(bpy.data.lamps[context.scene.DuplicateToolsLamp],'Lamp',context.scene.DuplicateToolsReplace)
return {'FINISHED'}
class AddonPanelDuplicateTool(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Duplicate Tool"
bl_idname = "object.duplicate_tools_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_context = "mesh_edit"
bl_category='N Tools'
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row(align=True)
row.label(text="Duplicate Tools", icon='MESH_CUBE')
row = layout.row(align=True)
row.prop(context.scene, "DuplicateToolsReplace",text="Replace")
row = layout.row(align=True)
row.prop_search(context.scene, "DuplicateToolsMesh", bpy.data, "meshes", text='Mesh')
row = layout.row(align=True)
row.operator(OperatorBuildingMesh.bl_idname,text='Duplicate Mesh')
row = layout.row(align=True)
row.prop_search(context.scene, "DuplicateToolsLamp", bpy.data, "lamps", text='Lamp')
row = layout.row(align=True)
row.operator(OperatorBuildingLamp.bl_idname,text='Duplicate Lamp')
row = layout.row(align=True)
###### Auto Connect Addon Setting ###########################################################################
class OperatorAutoConnect(bpy.types.Operator):
bl_idname = "object.auto_connect_operator"
bl_label = "Auto Connect Operator"
def execute(self, context):
Margin=bpy.context.scene.autoConnectMargin
Threshold=bpy.context.scene.autoConnectThreshold
SearchNumber= bpy.context.scene.autoConnectLimit
Distance=bpy.context.scene.autoConnectDistance
autoConnect(Margin,Threshold,Distance,SearchNumber)
return {'FINISHED'}
class OperatorSelectDuplicateJoint(bpy.types.Operator):
bl_idname = "object.select_duplicate_joint_operator"
bl_label = "Select Duplicate Joint Operator"
def execute(self, context):
selectDuplicateJoint()
return {'FINISHED'}
class AddonPanelAutoConnect(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Auto Connect"
bl_idname = "object.auto_connect_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_context = "objectmode"
bl_category='N Tools'
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row(align=True)
row.prop(context.scene,'autoConnectMargin',text='Margin')
row = layout.row(align=True)
row.prop(context.scene,'autoConnectThreshold',text='Threshold')
row = layout.row(align=True)
row.prop(context.scene,'autoConnectDistance',text='Distance')
row = layout.row(align=True)
row.prop(context.scene,'autoConnectLimit',text='Limit')
row = layout.row(align=True)
row.operator(OperatorAutoConnect.bl_idname,text='Auto Connect')
row = layout.row(align=True)
row.operator(OperatorSelectDuplicateJoint.bl_idname,text='Select Duplicate Joint')
###### Cut With Plane Addon Setting ##########################################################################
class OperatorCutWithPlanes(bpy.types.Operator):
bl_idname = "object.cut_with_planes_operator"
bl_label = "Operator Cut With Planes"
def execute(self, context):
Margin=bpy.context.scene.CutWithPlanesMargin
cutWithPlanes(Margin)
return {'FINISHED'}
class OperatorCreatePlanes(bpy.types.Operator):
bl_idname = "object.create_planes_operator"
bl_label = "Operator Create Planes"
def execute(self, context):
NumberOfPlane=bpy.context.scene.CutWithPlanesNumberOfPlanes
FirstSubdivide=bpy.context.scene.CutWithPlanesFirstSubdivide
FirstFractal=bpy.context.scene.CutWithPlanesFirstFractal
CutWithPlanesSecondSubdivide=bpy.props.IntProperty(default=5,min=0)
SecondSubdivide=bpy.context.scene.CutWithPlanesSecondSubdivide
SecondFractal=bpy.context.scene.CutWithPlanesSecondFractal
SmoothFactor=bpy.context.scene.CutWithPlanesSmoothFactor
SmoothRepeat=bpy.context.scene.CutWithPlanesSmoothRepeat
CenterOrLine=bpy.context.scene.CutWithPlanesCenterOrLine
createPlane(NumberOfPlane,FirstSubdivide,FirstFractal,SecondSubdivide,SecondFractal,SmoothFactor,SmoothRepeat,CenterOrLine)
return {'FINISHED'}
class AddonPanelCutWithPlanes(bpy.types.Panel):
"""Creates a Panel in the Object properties window"""
bl_label = "Cut With Planes"
bl_idname = "object.cut_with_planes_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'TOOLS'
bl_context = "objectmode"
bl_category='N Tools'
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row(align=True)
row.prop(context.scene,'CutWithPlanesMargin',text='Margin')
row = layout.row(align=True)
row.operator(OperatorCutWithPlanes.bl_idname,text='Cut With Planes')
######Create Planes
row = layout.row(align=True)
row.prop(context.scene,'CutWithPlanesNumberOfPlanes',text='Planes')
row = layout.row(align=True)
row.prop(context.scene,'CutWithPlanesFirstSubdivide',text='1st Subdivide')
row = layout.row(align=True)
row.prop(context.scene,'CutWithPlanesFirstFractal',text='1st Fractal')
row = layout.row(align=True)
row.prop(context.scene,'CutWithPlanesSecondSubdivide',text='2nd Subdivide')
row = layout.row(align=True)
row.prop(context.scene,'CutWithPlanesSecondFractal',text='2nd Fractal')
row = layout.row(align=True)
row.prop(context.scene,'CutWithPlanesSmoothFactor',text='Smooth')
row = layout.row(align=True)
row.prop(context.scene,'CutWithPlanesSmoothRepeat',text='Smooth Repeat')
row = layout.row(align=True)
row.prop(context.scene,'CutWithPlanesCenterOrLine',expand=True)
row = layout.row(align=True)
row.operator(OperatorCreatePlanes.bl_idname,text='Create Planes')
###### Register ###########################################################################
def register():
print("register")
#bpy.utils.register_module(__name__)
bpy.utils.register_class(AddonPanelDuplicateTool)
bpy.utils.register_class(OperatorBuildingMesh)
bpy.utils.register_class(OperatorBuildingLamp)
bpy.types.Scene.DuplicateToolsMesh=bpy.props.StringProperty()
bpy.types.Scene.DuplicateToolsLamp=bpy.props.StringProperty()
bpy.types.Scene.DuplicateToolsReplace=bpy.props.BoolProperty()
### Auto Connect ###
bpy.utils.register_class(AddonPanelAutoConnect)
bpy.utils.register_class(OperatorAutoConnect)
bpy.utils.register_class(OperatorSelectDuplicateJoint)
bpy.types.Scene.autoConnectMargin=bpy.props.FloatProperty(default=0.01,min=0.0,max=10.0,step=1,precision=3)
bpy.types.Scene.autoConnectThreshold=bpy.props.FloatProperty(default=0.01,min=0.0,max=1.0,step=1,precision=3)
bpy.types.Scene.autoConnectDistance=bpy.props.FloatProperty(default=-1.0,min=-1.0,max=1.0,step=1,precision=3)
bpy.types.Scene.autoConnectLimit=bpy.props.IntProperty(default=10,min=1)
### Cut With Plane ###
bpy.utils.register_class(AddonPanelCutWithPlanes)
bpy.utils.register_class(OperatorCutWithPlanes)
bpy.utils.register_class(OperatorCreatePlanes)
bpy.types.Scene.CutWithPlanesMargin=bpy.props.FloatProperty(default=0.0001,min=0,step=1,precision=4)
bpy.types.Scene.CutWithPlanesNumberOfPlanes=bpy.props.IntProperty(default=1,min=1)
bpy.types.Scene.CutWithPlanesFirstSubdivide=bpy.props.IntProperty(default=5,min=0)
bpy.types.Scene.CutWithPlanesFirstFractal=bpy.props.FloatProperty(default=0.5,min=0,step=1,precision=3)
bpy.types.Scene.CutWithPlanesSecondSubdivide=bpy.props.IntProperty(default=5,min=0)
bpy.types.Scene.CutWithPlanesSecondFractal=bpy.props.FloatProperty(default=0.5,min=0,step=1,precision=3)
bpy.types.Scene.CutWithPlanesSmoothFactor=bpy.props.FloatProperty(default=0,min=0.0,max=1.0,step=1,precision=3)
bpy.types.Scene.CutWithPlanesSmoothRepeat=bpy.props.IntProperty(default=0,min=0)
bpy.types.Scene.CutWithPlanesCenterOrLine=bpy.props.EnumProperty(
name = "None",
items = (
('Line','Line','Line'),('Center','Center','Center') ) )
def unregister():
print("unregister")
#bpy.utils.unregister_module(__name__)
bpy.utils.unregister_class(AddonPanelDuplicateTool)
bpy.utils.unregister_class(OperatorBuildingMesh)
bpy.utils.unregister_class(OperatorBuildingLamp)
del bpy.types.Scene.DuplicateToolsMesh
del bpy.types.Scene.DuplicateToolsLamp
del bpy.types.Scene.DuplicateToolsReplace
### Auto Connect ###
bpy.utils.unregister_class(AddonPanelAutoConnect)
bpy.utils.unregister_class(OperatorAutoConnect)
bpy.utils.unregister_class(OperatorSelectDuplicateJoint)
del bpy.types.Scene.autoConnectMargin
del bpy.types.Scene.autoConnectThreshold
del bpy.types.Scene.autoConnectDistance
del bpy.types.Scene.autoConnectLimit
### Cut With Plane ###
bpy.utils.unregister_class(AddonPanelCutWithPlanes)
bpy.utils.unregister_class(OperatorCutWithPlanes)
bpy.utils.unregister_class(OperatorCreatePlanes)
del bpy.types.Scene.CutWithPlanesMargin
del bpy.types.Scene.CutWithPlanesNumberOfPlanes
del bpy.types.Scene.CutWithPlanesFirstSubdivide
del bpy.types.Scene.CutWithPlanesFirstFractal
del bpy.types.Scene.CutWithPlanesSecondSubdivide
del bpy.types.Scene.CutWithPlanesSecondFractal
del bpy.types.Scene.CutWithPlanesSmoothFactor
del bpy.types.Scene.CutWithPlanesSmoothRepeat
del bpy.types.Scene.CutWithPlanesCenterOrLine
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment