Skip to content
Snippets Groups Projects
add_curve_aceous_galore.py 38.7 KiB
Newer Older
  • Learn to ignore specific revisions
  • 
            col = layout.column()
            col.label(text="Output Curve Type")
            row = layout.row()
            row.prop(props, 'outputType', expand=True)
            col = layout.column()
            col.label(text="Curve Options")
    
            # output options
            box = layout.box()
            if props.outputType == 'NURBS':
                box.row().prop(props, 'shape', expand=True)
                box.prop(props, 'cyclic_u')
    
    Florian Meyer's avatar
    Florian Meyer committed
                #box.prop(props, 'endp_u')
    
                box.prop(props, 'order_u')
    
            if props.outputType == 'POLY':
                box.row().prop(props, 'shape', expand=True)
                box.prop(props, 'cyclic_u')
    
            if props.outputType == 'BEZIER':
                box.row().prop(props, 'shape', expand=True)
                box.row().prop(props, 'handleType', expand=True)
                box.prop(props, 'cyclic_u')
    
    
        ##### POLL #####
        def poll(self, context):
            return context.scene != None
    
        ##### EXECUTE #####
        def execute(self, context):
            # turn off undo
            undo = bpy.context.user_preferences.edit.global_undo
            bpy.context.user_preferences.edit.global_undo = False
    
            props = self.properties
            if props.GalloreType in ['Helix', 'Cycloid']:
                props.shape = '3D'
    
    Florian Meyer's avatar
    Florian Meyer committed
            if props.GalloreType in ['Helix']:
                props.cyclic_u = False
    
    
            # Options
            options = [
                # general properties
                props.outputType,           #0
                props.GalloreType,          #1
                # ProfileCurve properties
                props.ProfileCurveType,     #2
                props.ProfileCurvevar1,     #3
                props.ProfileCurvevar2,     #4
                # MiscCurve properties
                props.MiscCurveType,        #5
                props.MiscCurvevar1,        #6
                props.MiscCurvevar2,        #7
                props.MiscCurvevar3,        #8
                # Common properties
                props.innerRadius,          #9
                props.middleRadius,         #10
                props.outerRadius,          #11
                # Flower properties
                props.petals,               #12
                props.petalWidth,           #13
                # Star properties
                props.starPoints,           #14
                props.starTwist,            #15
                # Arc properties
                props.arcSides,             #16
                props.startAngle,           #17
                props.endAngle,             #18
                props.arcType,              #19
                # Cogwheel properties
                props.teeth,                #20
                props.bevel,                #21
                # Nsided property
                props.Nsides,               #22
                # Splat properties
                props.splatSides,           #23
                props.splatScale,           #24
                props.seed,                 #25
                props.basis,                #26
                # Helix properties
                props.helixPoints,          #27
                props.helixHeight,          #28
                props.helixStart,           #29
                props.helixEnd,             #30
                props.helixWidth,           #31
                props.helix_a,              #32
                props.helix_b,              #33
                # Cycloid properties
                props.cycloPoints,          #34
                props.cyclo_d,          #35
                props.cycloType,            #36
                props.cyclo_a,              #37
                props.cyclo_b,              #38
                props.cycloStart,           #39
                props.cycloEnd              #40
                ]
    
            # Curve options
            curveOptions = [
                props.shape,        #0
                props.cyclic_u,     #1
                props.endp_u,       #2
                props.order_u,      #4
                props.handleType    #5
                ]
    
            # main function
            main(context, options, curveOptions, self.align_matrix)
            
            # restore pre operator undo state
            bpy.context.user_preferences.edit.global_undo = undo
    
            return {'FINISHED'}
    
        ##### INVOKE #####
        def invoke(self, context, event):
            # store creation_matrix
            self.align_matrix = align_matrix(context)
            self.execute(context)
    
            return {'FINISHED'}
    
    ################################################################################
    ##### REGISTER #####
    
    Curveaceous_galore_button = (lambda self, context: self.layout.operator
    
    Florian Meyer's avatar
    Florian Meyer committed
                (Curveaceous_galore.bl_idname, text="curvatures gallore", icon="PLUGIN"))
    
    
    classes = [
    Curveaceous_galore
        ]
    
    def register():
        register = bpy.types.register
        for cls in classes:
            register(cls)
    
        bpy.types.INFO_MT_curve_add.append(Curveaceous_galore_button)
    
    def unregister():
        unregister = bpy.types.unregister
        for cls in classes:
            unregister(cls)
    
        bpy.types.INFO_MT_curve_add.remove(Curveaceous_galore_button)
    
    if __name__ == "__main__":
        register()