sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Smooth Line after push/pull

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 357 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      davesexcel
      last edited by

      Hello,
      When using the below code, how do I smooth the edges?

      ` prompts = ["length", "Run","height","Rise","Total Rises"]
      defaults = [36.0,10.0,1.0,7.75,7]
      input = UI.inputbox prompts, defaults, "Tread."

      if input == false
      UI.messagebox("All Must Be Entered")
      else
        a,b,c,d,e=input
      #UI.messagebox("Tread input accepted!, #{input}!")
      end
      
      
      ent = Sketchup.active_model.entities
      

      for i in 0..e-1
      ent.add_line [0,(b+1)+ib,0+id-1],[0,(1.5+ib),0+id-1]
      ent.add_line [0,1.5+ib,0+id-1],[0,1.5+ib,-d+(id)-1]
      ent.add_line [0,1+ib,0+id-1],[0,1+ib,-d+(id)-1]
      ent.add_line [0,1+ib,-d+(id)-1],[0,1.5+ib,-d+(id)-1]
      ent.add_line [0,1+ib,-1+id],[0,0.5+ib,-1+id]
      ent.add_arc [0,0.5+ib,-c/2.0+(id)],[0,0,-1],[-1,0,0],c/2.0,0,180.degrees,20
      ent.add_line [0,0.5+ib,0+id],[0,b+(ib)+1,0+id]
      edg=ent.add_line [0,b+1+ib,-c+id],[0,b+1+ib,0+id]
      edg.find_faces; face=edg.faces[0]

      # #face = ent.add_face [0,0,0], [a,0,0], [a,b,0], [0,b,0]
      #face.reverse!
       face.pushpull -a
      # edg.soft="true"
       #group1 = ent.add_group face.all_connected
      end   
        #group1_copy = group1.parent.entities.add_instance(group1.entities.parent, group.transformation)`
      

      Before Smooth

      https://drive.google.com/file/d/0ByXxMRXssekcaDdGRTJaN013dHc/view?usp=sharing

      After Smooth

      https://drive.google.com/file/d/0ByXxMRXssekcNC1GOWxRQTZWMmM/view?usp=sharing

      edg.soft="true" doesn't appear to do anything
      Thanks

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        @davesexcel said:

        Hello,
        When using the below code, how do I smooth the edges?

        ` prompts = ["length", "Run","height","Rise","Total Rises"]
        defaults = [36.0,10.0,1.0,7.75,7]
        input = UI.inputbox prompts, defaults, "Tread."

        if input == false
        UI.messagebox("All Must Be Entered")
        else
          a,b,c,d,e=input
        #UI.messagebox("Tread input accepted!, #{input}!")
        end
        
        
        ent = Sketchup.active_model.entities
        

        for i in 0..e-1
        ent.add_line [0,(b+1)+ib,0+id-1],[0,(1.5+ib),0+id-1]
        ent.add_line [0,1.5+ib,0+id-1],[0,1.5+ib,-d+(id)-1]
        ent.add_line [0,1+ib,0+id-1],[0,1+ib,-d+(id)-1]
        ent.add_line [0,1+ib,-d+(id)-1],[0,1.5+ib,-d+(id)-1]
        ent.add_line [0,1+ib,-1+id],[0,0.5+ib,-1+id]
        ent.add_arc [0,0.5+ib,-c/2.0+(id)],[0,0,-1],[-1,0,0],c/2.0,0,180.degrees,20
        ent.add_line [0,0.5+ib,0+id],[0,b+(ib)+1,0+id]
        edg=ent.add_line [0,b+1+ib,-c+id],[0,b+1+ib,0+id]
        edg.find_faces; face=edg.faces[0]

        # #face = ent.add_face [0,0,0], [a,0,0], [a,b,0], [0,b,0]
        #face.reverse!
         face.pushpull -a
        

        edg.soft="true"

        #group1 = ent.add_group face.all_connected
        end
        #group1_copy = group1.parent.entities.add_instance(group1.entities.parent, group.transformation)`
        Before Smooth

        https://drive.google.com/file/d/0ByXxMRXssekcaDdGRTJaN013dHc/view?usp=sharing

        After Smooth

        https://drive.google.com/file/d/0ByXxMRXssekcNC1GOWxRQTZWMmM/view?usp=sharing

        edg.soft="true" doesn't appear to do anything
        Thanks

        #<----- where changes and additions were made

        prompts = ["length", "Run","height","Rise","Total Rises"]
        defaults = [36.0,10.0,1.0,7.75,7]
        input = UI.inputbox prompts, defaults, "Tread."
        
        
        if input == false
        UI.messagebox("All Must Be Entered")
        else
        a,b,c,d,e=input
        #UI.messagebox("Tread input accepted!, #{input}!")
        end
        
        
        ent = Sketchup.active_model.entities
        for i in 0..e-1
        ent.add_line [0,(b+1)+i*b,0+i*d-1],[0,(1.5+i*b),0+i*d-1]
        ent.add_line [0,1.5+i*b,0+i*d-1],[0,1.5+i*b,-d+(i*d)-1]
        ent.add_line [0,1+i*b,0+i*d-1],[0,1+i*b,-d+(i*d)-1]
        ent.add_line [0,1+i*b,-d+(i*d)-1],[0,1.5+i*b,-d+(i*d)-1]
        edg = ent.add_line [0,1+i*b,-1+i*d],[0,0.5+i*b,-1+i*d];vrt1=edg.end#<-----
        ent.add_arc [0,0.5+i*b,-c/2.0+(i*d)],[0,0,-1],[-1,0,0],c/2.0,0,180.degrees,20
        edg = ent.add_line [0,0.5+i*b,0+i*d],[0,b+(i*b)+1,0+i*d];vrt2=edg.start#<----_
        edg=ent.add_line [0,b+1+i*b,-c+i*d],[0,b+1+i*b,0+i*d]
        edg.find_faces; face=edg.faces[0]
        
        # #face = ent.add_face [0,0,0], [a,0,0], [a,b,0], [0,b,0]
        #face.reverse!
        face.pushpull -a
        edgs=vrt1.edges.reject!{|e| e.length<a};edgs[0].soft=true#<-----
        edgs=vrt2.edges.reject!{|e| e.length<a};edgs[0].soft=true#<-----
        # edg.soft="true"
        #group1 = ent.add_group face.all_connected
        end 
        #group1_copy = group1.parent.entities.add_instance(group1.entities.parent, group.transformation)
        

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • K Offline
          ktkoh
          last edited by

          sdmitch

          I am trying to learn from you code. How is the smoothing only applied to the edges created by the add arc? It needs some English description if you will!!

          Keith

          1 Reply Last reply Reply Quote 0
          • sdmitchS Offline
            sdmitch
            last edited by

            @ktkoh said:

            sdmitch

            I am trying to learn from you code. How is the smoothing only applied to the edges created by the add arc? It needs some English description if you will!!

            Keith

            I save the vertices, vrt1 and vrt2, at the beginning and end of the arc. Then I look at all the edges associated with those vertices and eliminate all that are not the proper length. This leaves me with a single edge that is softened.

            Nothing is worthless, it can always be used as a bad example.

            http://sdmitch.blogspot.com/

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement