• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Efficient Code?

Scheduled Pinned Locked Moved Developers' Forum
1 Posts 1 Posters 2.7k Views
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.
  • M Offline
    medeek
    last edited by 8 May 2018, 20:47

    As I'm working on the finishing touches to the Wall Plugin the six panel door geometry is something that keeps coming back to me.

    This type of door geometry is fairly typical so eventually I would like to implement it however it does have a very high polygon count comparatively speaking. I've devised a fairly straightforward piece of code that generates a single panel, see below (cut and paste into the ruby console to view solid geometry):

      group1 = Sketchup.active_model.entities.add_group
        entities = group1.entities
    
    
        new_face1 = entities.add_face [0,0,0], [500,0,0], [500,500,0], [0,500,0]
        new_face1.pushpull 50
    
        pt1 = [100,100,0]
        pt2 = [200,100,0]
        pt3 = [200,200,0]
        pt4 = [100,200,0]
    
        new_face2 = entities.add_face pt1, pt2, pt3, pt4
    
        pt1 = [130,130,0]
        pt2 = [170,130,0]
        pt3 = [170,170,0]
        pt4 = [130,170,0]
    
        new_face2 = entities.add_face pt1, pt2, pt3, pt4
    
        pt1 = [110,110,0]
        pt2 = [190,110,0]
        pt3 = [190,190,0]
        pt4 = [110,190,0]
    
        new_face2 = entities.add_face pt1, pt2, pt3, pt4
    
        line1 = entities.add_line pt1, pt2
        line2 = entities.add_line pt2, pt3
        line3 = entities.add_line pt3, pt4
        line4 = entities.add_line pt4, pt1
    
        entities_to_transform = [line1, line2, line3, line4]
    
        transform = Geom;;Transformation.new([0,0,-5])
        entities.transform_entities(transform, entities_to_transform)
    

    However, my concern is that this block of code will need to be iterated twelve times in order to create the six panels on each side of the door, a lot of computation in order to create this door style. In that light, I would like for this code to be efficient and tight as possible, since the plugin is already quite heavy just in generating simple block geometry (ie. studs, casing, trim etc...).

    Is there a more efficient way to write this block of code?

    Nathaniel P. Wilkerson PE
    Medeek Engineering Inc
    design.medeek.com

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

    Advertisement