# Abusing spirals

**URL:** <https://forums.sketchup.com/t/abusing-spirals/243536>\
**Category:** Ruby API\
**Tags:** sketchup, hole, ruby, faces, surfaces\
**Created:** [October 2, 2023, 9:48pm UTC](https://forums.sketchup.com/t/abusing-spirals/243536 "2023-10-02T21:48:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![j\_jones](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/j_jones/32/110741_2.png) [@j\_jones](https://forums.sketchup.com/u/j_jones)\
**Post date:** [October 2, 2023, 9:48pm UTC](https://forums.sketchup.com/t/abusing-spirals/243536/1 "2023-10-02T21:48:46Z")

</div>

![topological_anomaly](https://global.discourse-cdn.com/sketchup/original/3X/7/9/7989d7b4350fd04a7978d07940c69bb5f7bb5ad5.jpeg)  
Toplogical Anomaly

Hello, I decided to mess around with some spirals now that my script is working.

Here it is again

```auto
module Spiral

  def self.make_circle_face(entities, circle_edges)
    pts = []
    circle_edges.each { |e|
      pts << e.vertices[0]
    }
    face = entities.add_face(pts)
    return face
  end

  def self.make_circle(entities, point, radius, normal)
    # make a circle face at the point with the given radius
    circ = entities.add_circle(point, normal, radius)
    circ_face = self.make_circle_face(entities, circ)
    return circ_face
  end

  def self.draw_turns(entities, segments, radius, taper_amount, 
                        z, z_increment, facet_size, last_point, num_turns)
    (facet_size..(360 * num_turns)).step(facet_size).each do |angle|
      theta = angle.degrees
      radius -= taper_amount
      x = radius * Math.cos(theta)
      y = radius * Math.sin(theta)
      point = Geom::Point3d.new(x, y, z)
      line = entities.add_line(last_point, point)
      segments << line
      last_point = point
      z += z_increment
    end
  end

  def self.draw(radius, taper_amount, z_increment, num_turns, facet_size, segments)
    model = Sketchup.active_model
    entities = model.active_entities
    z = 0
    endpoint = Geom::Point3d.new(radius, 0, z)
    spiral_group = entities.add_group
    spiral_entities = spiral_group.entities
    self.draw_turns(spiral_entities, segments, radius, 
          taper_amount, z, z_increment, facet_size, endpoint, num_turns)
    return spiral_group
  end # method draw

end # module Spiral

radius = 100
taper_amount = 0.3
z_increment = 1
num_turns = 3
facet_size = 6
segments = []
wire_thickness = 20

model = Sketchup.active_model
model.start_operation('spiral', true)

  spiral_group = Spiral.draw(radius, taper_amount, z_increment, num_turns, facet_size, segments)
  entities = spiral_group.entities

  start_point = Geom::Point3d.new(radius, 0, 0)
  normal = [0,-1,0]
  face = Spiral.make_circle(entities, start_point, wire_thickness, normal)

  face.followme(segments)

  # begin abusing spiral
  stuff = spiral_group.explode
  curves = stuff.grep(Sketchup::Curve)
  curves.each { |c|
    points = c.vertices.map(&:position)
    points.each_with_index { |pt,i| 
      pt.z = pt.z * i
      pt.x = pt.x * i
      pt.y = pt.y * i
    }
    c.move_vertices(points)
  }
model.commit_operation

```

I decided to iterate through the curves and mess with the position of the vertices, resulting in this interesting shape here.

 ![abusing-spirals](https://global.discourse-cdn.com/sketchup/original/3X/e/3/e3537e474255d6eec4b230241ec2bc345b92d88e.jpeg)

However I’m not sure why the faces became so patchy. (My husband immediately remembered a similar shape from Star Trek - pictured above.)

Is there a way to programmatically heal the faces so the object looks smooth again?

Thanks for any thoughts  
-j\_jones

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [October 3, 2023, 2:30am UTC](https://forums.sketchup.com/t/abusing-spirals/243536/2 "2023-10-03T02:30:07Z")

</div>

SketchUp does not like small faces. (It’s meant for modeling buildings.)  
Try doing it at a larger scale.

Also, if interested in Spirals, @jimhami42 has [spirixcode (google.com)](https://sites.google.com/site/spirixcode/) available to learn from.

* * *

P.S. - That looks like the [mobius / Tyken’s Rift](https://memory-alpha.fandom.com/wiki/Tyken's_Rift) episode from StarTrek:TNG.

Also, as you go deeper into coding for SketchUp, please realize that **all** of you modules should be inside **one unique** top-level namespace module. This separates all of your code and extensions from everyone else’s.
