Skip to content
Snippets Groups Projects
Commit 334009ef authored by Florian Meyer's avatar Florian Meyer
Browse files

== Torus Knot ==

- fixed the previously mentioned bug
- somehow setting the Curve.offset screwed things up
- simply removed it, wasn't used anyway
- updated api revision number
parent 47466bf2
No related branches found
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ bl_addon_info = { ...@@ -22,7 +22,7 @@ bl_addon_info = {
"author": "testscreenings", "author": "testscreenings",
"version": (0,1), "version": (0,1),
"blender": (2, 5, 3), "blender": (2, 5, 3),
"api": 31847, "api": 31885,
"location": "View3D > Add > Curve", "location": "View3D > Add > Curve",
"description": "Adds many types of knots", "description": "Adds many types of knots",
"warning": "", "warning": "",
...@@ -68,7 +68,7 @@ def vertsToPoints(Verts): ...@@ -68,7 +68,7 @@ def vertsToPoints(Verts):
return vertArray return vertArray
# create new CurveObject from vertarray and splineType # create new CurveObject from vertarray and splineType
def createCurve(vertArray, self, align_matrix): def createCurve(vertArray, props, align_matrix):
# options to vars # options to vars
splineType = 'NURBS' splineType = 'NURBS'
name = 'Torus_Knot' name = 'Torus_Knot'
...@@ -89,14 +89,14 @@ def createCurve(vertArray, self, align_matrix): ...@@ -89,14 +89,14 @@ def createCurve(vertArray, self, align_matrix):
newSpline.use_endpoint_u = True newSpline.use_endpoint_u = True
newSpline.order_u = 4 newSpline.order_u = 4
if self.geo_surf: if props.geo_surf:
newCurve.bevel_depth = self.geo_bDepth newCurve.bevel_depth = props.geo_bDepth
newCurve.bevel_resolution = self.geo_bRes newCurve.bevel_resolution = props.geo_bRes
newCurve.use_fill_front = False newCurve.use_fill_front = False
newCurve.use_fill_back = False newCurve.use_fill_back = False
newCurve.extrude = self.geo_extrude newCurve.extrude = props.geo_extrude
newCurve.offset = self.geo_width #newCurve.offset = props.geo_width # removed, somehow screws things up all of a sudden
newCurve.resolution_u = self.geo_res newCurve.resolution_u = props.geo_res
# create object with newCurve # create object with newCurve
new_obj = bpy.data.objects.new(name, newCurve) # object new_obj = bpy.data.objects.new(name, newCurve) # object
...@@ -132,26 +132,26 @@ def Torus_Knot_Curve(p=2, q=3, w=1, res=24, formula=0, h=1, u=1 ,v=1, rounds=2): ...@@ -132,26 +132,26 @@ def Torus_Knot_Curve(p=2, q=3, w=1, res=24, formula=0, h=1, u=1 ,v=1, rounds=2):
##------------------------------------------------------------ ##------------------------------------------------------------
# Main Function # Main Function
def main(context, self, align_matrix): def main(context, props, align_matrix):
# deselect all objects # deselect all objects
bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.select_all(action='DESELECT')
# get verts # get verts
verts = Torus_Knot_Curve(self.torus_p, verts = Torus_Knot_Curve(props.torus_p,
self.torus_q, props.torus_q,
self.torus_w, props.torus_w,
self.torus_res, props.torus_res,
self.torus_formula, props.torus_formula,
self.torus_h, props.torus_h,
self.torus_u, props.torus_u,
self.torus_v, props.torus_v,
self.torus_rounds) props.torus_rounds)
# turn verts into array # turn verts into array
vertArray = vertsToPoints(verts) vertArray = vertsToPoints(verts)
# create object # create object
createCurve(vertArray, self, align_matrix) createCurve(vertArray, props, align_matrix)
return return
...@@ -238,37 +238,38 @@ class torus_knot_plus(bpy.types.Operator): ...@@ -238,37 +238,38 @@ class torus_knot_plus(bpy.types.Operator):
##### DRAW ##### ##### DRAW #####
def draw(self, context): def draw(self, context):
props = self.properties
layout = self.layout layout = self.layout
# general options # general options
col = layout.column() col = layout.column()
#col.prop(self.properties, 'KnotType') waits for more knottypes #col.prop(props, 'KnotType') waits for more knottypes
col.label(text="Torus Knot Parameters") col.label(text="Torus Knot Parameters")
# Parameters # Parameters
box = layout.box() box = layout.box()
box.prop(self.properties, 'torus_res') box.prop(props, 'torus_res')
box.prop(self.properties, 'torus_w') box.prop(props, 'torus_w')
box.prop(self.properties, 'torus_h') box.prop(props, 'torus_h')
box.prop(self.properties, 'torus_p') box.prop(props, 'torus_p')
box.prop(self.properties, 'torus_q') box.prop(props, 'torus_q')
box.prop(self.properties, 'options_plus') box.prop(props, 'options_plus')
if self.options_plus: if props.options_plus:
box.prop(self.properties, 'torus_u') box.prop(props, 'torus_u')
box.prop(self.properties, 'torus_v') box.prop(props, 'torus_v')
box.prop(self.properties, 'torus_rounds') box.prop(props, 'torus_rounds')
# surface Options # surface Options
col = layout.column() col = layout.column()
col.label(text="Geometry Options") col.label(text="Geometry Options")
box = layout.box() box = layout.box()
box.prop(self.properties, 'geo_surf') box.prop(props, 'geo_surf')
if self.geo_surf: if props.geo_surf:
box.prop(self.properties, 'geo_bDepth') box.prop(props, 'geo_bDepth')
box.prop(self.properties, 'geo_bRes') box.prop(props, 'geo_bRes')
box.prop(self.properties, 'geo_extrude') box.prop(props, 'geo_extrude')
#box.prop(self.properties, 'geo_width') # not really good #box.prop(props, 'geo_width') # not really good
box.prop(self.properties, 'geo_res') box.prop(props, 'geo_res')
##### POLL ##### ##### POLL #####
@classmethod @classmethod
...@@ -281,12 +282,13 @@ class torus_knot_plus(bpy.types.Operator): ...@@ -281,12 +282,13 @@ class torus_knot_plus(bpy.types.Operator):
undo = bpy.context.user_preferences.edit.use_global_undo undo = bpy.context.user_preferences.edit.use_global_undo
bpy.context.user_preferences.edit.use_global_undo = False bpy.context.user_preferences.edit.use_global_undo = False
props = self.properties
if not self.options_plus: if not self.options_plus:
self.torus_rounds = self.torus_p self.torus_rounds = self.torus_p
# main function # main function
main(context, self, self.align_matrix) main(context, props, self.align_matrix)
# restore pre operator undo state # restore pre operator undo state
bpy.context.user_preferences.edit.use_global_undo = undo bpy.context.user_preferences.edit.use_global_undo = undo
...@@ -315,4 +317,4 @@ def unregister(): ...@@ -315,4 +317,4 @@ def unregister():
bpy.types.INFO_MT_curve_add.remove(torus_knot_plus_button) bpy.types.INFO_MT_curve_add.remove(torus_knot_plus_button)
if __name__ == "__main__": if __name__ == "__main__":
register() register()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment