sketchucation logo sketchucation
    • Login
    1. Home
    2. corbinw
    ℹ️ 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 2
    • Groups 1

    corbinw

    @corbinw

    0
    Reputation
    1
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    corbinw Unfollow Follow
    registered-users

    Latest posts made by corbinw

    • RE: Adding Cylinders to Sketch

      That is what I needed, thank you ThomThom.

      I am creating several thousand of these pegs in different locations on the board,I have noticed a real processing hit.
      I read that it would be better to create these objects as components and then add them dynamically? I tried to do a basic example of a component instance and transformation(seems simple with a simple face, but confusing in cylinder)

      What am I missing?

        model = Sketchup.active_model 
        entities = model.entities 
      
        # Create a series of "points", each a 3-item array containing x, y, and z. 
        pt1 = [0, 0, 0] 
        pt2 = [20, 0, 0] 
        pt3 = [20, 20, 0] 
        pt4 = [0, 20, 0] 
         
        # Call methods on the Entities collection to draw stuff. 
        new_face = entities.add_face pt1, pt2, pt3, pt4 
        new_face.pushpull 0.75
      
        # Draw a circle on the ground plane around the origin. 
        center_point = Geom;;Point3d.new(1,1,0) 
        normal_vector = Geom;;Vector3d.new(0,0,1) 
        radius = 0.3 
       
        entities = Sketchup.active_model.entities    
        edgearray = entities.add_circle center_point, normal_vector, radius 
        first_edge = edgearray[0] 
      
        face = first_edge.faces.select { |f| (f.outer_loop.edges & edgearray).length == edgearray.length }.first
        
        group = Sketchup.active_model.entities.add_group
        face.pushpull 3
        face = group.entities.addface face
        comp = group.to_component
          
        transformation = Geom;;Transformation.new([2,1,0])
        componentinstance = entities.add_instance(comp.definition, transformation)
      
      posted in Developers' Forum
      C
      corbinw
    • Adding Cylinders to Sketch

      I am trying to add cylinders to the top of a board programmatically.

      I have attached the a graphic of the desired result, the circles would pushpull up 5"

      Any help is greatly appreciated.

      Corbin

      The current script is as follows:

      require 'sketchup' 
        UI.menu("PlugIns").add_item("Draw board") {  
        # Call our new method. 
        draw_board
      }
      def draw_board 
        # Get "handles" to our model and the Entities collection it contains. 
        model = Sketchup.active_model 
        entities = model.entities 
       
        # Create a series of "points", each a 3-item array containing x, y, and z. 
        pt1 = [0, 0, 0] 
        pt2 = [72, 0, 0] 
        pt3 = [72, 42, 0] 
        pt4 = [0, 42, 0] 
         
        # Call methods on the Entities collection to draw stuff. 
        new_face = entities.add_face pt1, pt2, pt3, pt4 
        new_face.pushpull 0.75
      
      
           normal_vector = Geom;;Vector3d.new(0,0,1)
           radius = 0.2
      
      (1..10).each { |i|
            # Draw a circles
           center_point = Geom;;Point3d.new(1,i,0)
           edgearray = entities.add_circle center_point, normal_vector, radius
           first_edge = edgearray[0]
           arccurve = first_edge.curve
      }
      
      end
      

      What I would like to do programmatically


      Current circles

      posted in Developers' Forum
      C
      corbinw