• Login
sketchucation logo sketchucation
  • Login
โ„น๏ธ GoFundMe | Our friend Gus Robatto needs some help in a challenging time Learn More

Resolve [Ruby help] Script for create window sills

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 8.3k 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.
  • B Offline
    benj59380
    last edited by benj59380 8 Nov 2019, 13:04

    Hello , Today I wanted Creat script for window sills

    my approach is create face manuel
    click for select

    run script
    ( part 1 : select face , creat color , Push -30 mm
    Part 2 : select vertical face for push +30)

    Part 1 work , but Part 2 fail ๐Ÿ˜ž

    But Ruby = SyntaxError help me please for resolve the problem ๐Ÿ˜‰
    thank you in advance , Benjamin

    #part 1
    model = Sketchup.active_model
    ent = model.entities
    sel = model.selection
    ad = sel.ent

    faces = []

    sel.each do |e|
    faces <<e if e.is_a? Sketchup::Face
    end

    faces.each do |appui|

    appuicolor = Sketchup::Color.new(238,130,238)
    appui.material = appuicolor
    appui.back_material = appuicolor

    status = appui.pushpull(-30.mm , true)

    end
    #part 2

    ad.each do |e|

    s=Sketchup.active_model.selection;
    a=s.to_a;s.clear;
    a.grep(Sketchup::Face).each{|f|s.add(f)if f.normal.z==0}

    faces.each do |facade|

    status = facade.pushpull(30.mm )

    end

    1 Reply Last reply Reply Quote 0
    • S Offline
      sdmitch
      last edited by 9 Nov 2019, 18:40

      Part 1 works if you delete or comment out the ad=sel.ent statement which is invalid.

      Part 2 doesn't work because the faces created by the pushpull operation are not automatically added to the selection. Also you reuse the faces array which only contains the original faces selected.

      Here is how I would do it

      mod = Sketchup.active_model
      ent = mod.active_entities
      sel = mod.selection
      SKETCHUP_CONSOLE.clear
      appuicolor = Sketchup;;Color.new(238,130,238)
      sel.grep(Sketchup;;Face).each do |appui|
        appui.material = appuicolor
        appui.back_material = appuicolor
        old = ent.to_a
        status = appui.pushpull(-30.mm , true)
        new = ent.to_a - old
        new.grep(Sketchup;;Face).select{|f|f.normal.z==0}.each{|f|f.pushpull 30.mm}
      end
      
      

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

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • B Offline
        benj59380
        last edited by 12 Nov 2019, 07:27

        hello , Thank you SDMITCH for help ๐Ÿ˜‰

        cordially Benj

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

        Advertisement