sketchucation logo sketchucation
    • Login
    1. Home
    2. crazystick
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    C
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 4
    • Groups 1

    crazystick

    @crazystick

    10
    Reputation
    1
    Profile views
    4
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    crazystick Unfollow Follow
    registered-users

    Latest posts made by crazystick

    • RE: Plugin for changing radius of multiple circles

      I didn't know you could scale a cylinder like that. It's handy to know. I don't know how to do that in ruby though - I tried scaling all 24 faces in the x,y axes using the centre of the cylinder, but unfortunately that didn't work.

      I also don't know why the model gets corrupted when I run the script and not when others do, I get the same results in 2013 Pro too. Maybe its a Mac issue.

      If you have any more ideas, let me know, otherwise I'll just have to live with it πŸ˜„

      posted in Developers' Forum
      C
      crazystick
    • RE: Plugin for changing radius of multiple circles

      @sdmitch said:

      I have run several tests and I don't get any error messages in v8 or v2014. Could you post the model. Also info on initial and final radii.

      The model is the one from this post, just a simple cube with a cylindrical hole. I ran the script on the top and bottom circle, then tried to save.

      I just made one change, which was to convert to mm - I can't cope with 0.15346 etc.

      rad = crv.radius.to_mm
      

      The starting radius in the model is 15mm, I tried going down to 10mm and up to 20mm with the same result. I'm using Sketchup Pro 2014

      posted in Developers' Forum
      C
      crazystick
    • RE: Plugin for changing radius of multiple circles

      I don't know why, I just figured that was too easy πŸ˜„

      Anyway, I tested that method, and it does work and appears to be accurate, so thank you. Unfortunately it still breaks the model, not as badly as my previous method, but on saving you still get a bunch of warnings The plane equation for CFace (xxxxxx) is not valid.

      Any ideas?

      posted in Developers' Forum
      C
      crazystick
    • Plugin for changing radius of multiple circles

      I've been looking for a plugin to change the radius of multiple circles but I didn't find one, so I had the idea to write one myself. I want to replicate the functionality of editing the radius in the Entity Info box, as I have a lot of holes which are pushed into / through another object, so they form empty cylinders.

      My basic idea was:

      1. select a circle
      2. get the center and normal
      3. make a new (bigger or smaller) circle and grab the points of the vertices
      4. delete the new circle
      5. move the vertices of the original circle to the new points

      My problem is that when you create a circle and push it through another one, the two circles are not directly above each other - they are offset by 2 arcs. If you do the same through the API they don't twist, and so moving the vertices twists the face of the cylinder which breaks it. Here's the code and the model. Before.skp

      ` model = Sketchup.active_model

      !!!manually select the top circle (sorry, has to be run in the console atm)

      cur_c = model.selection[0].curve
      cur_p = []

      grab the positions of each vertex

      cur_c.vertices.each { | v | cur_p << v.position }

      !!!manually select the bottom circle

      cur_c2 = model.selection[0].curve
      cur_p2 = []

      grab the position of the bottom circle's vertices

      cur_c2.vertices.each { | v | cur_p2 << v.position }

      show the points

      cur_p
      cur_p2`

      The output was

      
      > cur_p
      [Point3d(2.55906, 1.9685, 0.590551), Point3d(2.53893, 1.81566, 0.590551), Point3d(2.47994, 1.67323, 
      0.590551), Point3d(2.38609, 1.55092, 0.590551), Point3d(2.26378, 1.45707, 0.590551), Point3d(2.12135, 1.39808, 0.590551), Point3d(1.9685, 1.37795, 0.590551), Point3d(1.81566, 1.39808, 0.590551), Point3d(1.67323, 1.45707, 0.590551), Point3d(1.55092, 1.55092, 0.590551), Point3d(1.45707, 1.67323, 0.590551), Point3d(1.39808, 1.81566, 0.590551), Point3d(1.37795, 1.9685, 0.590551), Point3d(1.39808, 2.12135, 0.590551), Point3d(1.45707, 2.26378, 0.590551), Point3d(1.55092, 2.38609, 0.590551), Point3d(1.67323, 2.47994, 0.590551), Point3d(1.81566, 2.53893, 0.590551), Point3d(1.9685, 2.55906, 0.590551), Point3d(2.12135, 2.53893, 0.590551), Point3d(2.26378, 2.47994, 0.590551), Point3d(2.38609, 2.38609, 0.590551), Point3d(2.47994, 2.26378, 0.590551), Point3d(2.53893, 2.12135, 0.590551), Point3d(2.55906, 1.9685, 0.590551)]
      
      > cur_p2
      [Point3d(2.47994, 2.26378, 0), Point3d(2.53893, 2.12135, 0), Point3d(2.55906, 1.9685, 0), Point3d(2.53893, 1.81566, 0), Point3d(2.47994, 1.67323, 0), Point3d(2.38609, 1.55092, 0), Point3d(2.26378, 1.45707, 0), Point3d(2.12135, 1.39808, 0), Point3d(1.9685, 1.37795, 0), Point3d(1.81566, 1.39808, 0), Point3d(1.67323, 1.45707, 0), Point3d(1.55092, 1.55092, 0), Point3d(1.45707, 1.67323, 0), Point3d(1.39808, 1.81566, 0), Point3d(1.37795, 1.9685, 0), Point3d(1.39808, 2.12135, 0), Point3d(1.45707, 2.26378, 0), Point3d(1.55092, 2.38609, 0), Point3d(1.67323, 2.47994, 0), Point3d(1.81566, 2.53893, 0), Point3d(1.9685, 2.55906, 0), Point3d(2.12135, 2.53893, 0), Point3d(2.26378, 2.47994, 0), Point3d(2.38609, 2.38609, 0), Point3d(2.47994, 2.26378, 0)]
      
      

      The first point in the top circle is the third point in the bottom circle. Continuing anyway:

      ` entities = model.active_entities
      new_p = []

      create a bigger circle on the top face

      new_e = entities.add_circle cur_c.center, cur_c.normal, 20.mm
      new_c = new_e[0].curve

      grab the new vertices

      new_c.vertices.each { | v | new_p << v.position }

      delete the circle

      entities.erase_entities new_e

      move the vertices to the new positions

      cur_c.move_vertices new_p

      new_p2 = []

      create a bigger circle on the bottom face

      new_e2 = entities.add_circle cur_c2.center, cur_c2.normal, 20.mm
      new_c2 = new_e2[0].curve

      grab the vertices

      new_c2.vertices.each { | v | new_p2 << v.position }

      delete the circle and move the vertices

      entities.erase_entities new_e2
      cur_c2.move_vertices new_p2

      look at the points where the new vertices are

      new_p
      new_p2`

      The output was:

      
      > new_p
      [Point3d(1.1811, 1.9685, 0.590551), Point3d(1.20793, 2.1723, 0.590551), Point3d(1.28659, 2.3622, 0.590551), Point3d(1.41173, 2.52528, 0.590551), Point3d(1.5748, 2.65041, 0.590551), Point3d(1.76471, 2.72908, 0.590551), Point3d(1.9685, 2.75591, 0.590551), Point3d(2.1723, 2.72908, 0.590551), Point3d(2.3622, 2.65041, 0.590551), Point3d(2.52528, 2.52528, 0.590551), Point3d(2.65041, 2.3622, 0.590551), Point3d(2.72908, 2.1723, 0.590551), Point3d(2.75591, 1.9685, 0.590551), Point3d(2.72908, 1.76471, 0.590551), Point3d(2.65041, 1.5748, 0.590551), Point3d(2.52528, 1.41173, 0.590551), Point3d(2.3622, 1.28659, 0.590551), Point3d(2.1723, 1.20793, 0.590551), Point3d(1.9685, 1.1811, 0.590551), Point3d(1.76471, 1.20793, 0.590551), Point3d(1.5748, 1.28659, 0.590551), Point3d(1.41173, 1.41173, 0.590551), Point3d(1.28659, 1.5748, 0.590551), Point3d(1.20793, 1.76471, 0.590551), Point3d(1.1811, 1.9685, 0.590551)]
      
      > new_p2
      [Point3d(1.1811, 1.9685, 0), Point3d(1.20793, 2.1723, 0), Point3d(1.28659, 2.3622, 0), Point3d(1.41173, 2.52528, 0), Point3d(1.5748, 2.65041, 0), Point3d(1.76471, 2.72908, 0), Point3d(1.9685, 2.75591, 0), Point3d(2.1723, 2.72908, 0), Point3d(2.3622, 2.65041, 0), Point3d(2.52528, 2.52528, 0), Point3d(2.65041, 2.3622, 0), Point3d(2.72908, 2.1723, 0), Point3d(2.75591, 1.9685, 0), Point3d(2.72908, 1.76471, 0), Point3d(2.65041, 1.5748, 0), Point3d(2.52528, 1.41173, 0), Point3d(2.3622, 1.28659, 0), Point3d(2.1723, 1.20793, 0), Point3d(1.9685, 1.1811, 0), Point3d(1.76471, 1.20793, 0), Point3d(1.5748, 1.28659, 0), Point3d(1.41173, 1.41173, 0), Point3d(1.28659, 1.5748, 0), Point3d(1.20793, 1.76471, 0), Point3d(1.1811, 1.9685, 0)]
      
      
      

      The second set of points, created from circles added through the API are not twisted, i.e. the first point in new_c is directly above the first point in new_c2

      The result of this is that after you have moved both sets of vertices, the surface of the cylinder is broken. You'll get a warning when you load it. After.skp

      posted in Developers' Forum
      C
      crazystick