sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Why can not draw the geometric by the ruby script?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 202 Views 2 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.
    • W Offline
      winzard
      last edited by

      require 'sketchup.rb'
      def create_model()
      
        @lengthl=100.m if not @length1
        @widthl=50.m if not @widthl
        @number=4 if not @number
        @blength=10.m if not @blength
        @bwidth=5.m if not @bwidth
        @bheight=5.m if not @bheight
        @spacing=5.m if not @spacing
        prompts=["Length of Land; ","Width of Land; ","The Number of Building; ","Building Length; ","Building Width; ","Building Height; ","Building Spacing; "]###
        defaults=[@lengthl,@widthl,@number,@blength,@bwidth,@bheight,@spacing]
        input=UI.inputbox(prompts,defaults,[],"Create Model")
        return nil if not input 
        @lengthl,@widthl,@number,@blength,@bwidth,@bheight,@spacing=input
        amount=@number 
        model=Sketchup.active_model
        entities=model.active_entities 
        
        if @blength>@lengthl
          UI.messagebox('The Building Length is more than Length of Land!')
        elsif @bwidth>@widthl
          UI.messagebox('The Building Width is more than Width of Land!')
        else 
          model.start_operation("Create Model")### for the 'undo'
          x=0;y=0 ### also don't muddle the width/height !!!
        amount.times{|i|
            pt1=[x,y,0]###
            pt2=[x+@bwidth,y,0]###
            pt3=[x+@bwidth,y+@blength,0]###
            pt4=[x,y+@blength,0]###
            new_face=entities.add_face(pt1,pt2,pt3,pt4)
            new_face.pushpull(-@bheight)
            ### pushUpull typo !!! -ve = pull up as the face is reversed...
            y=y+@blength+@spacing ### set in a line
            x=x+@bwidth+@spacing   if y>@lengthl
            UI.messagebox('The area of land is inadequate !')  if x>@widthl
          } ###
        end #if##
        model.commit_operation ###
        
      end#def ###
      if not file_loaded?("2.rb") ### so only get menu item once...
        UI.menu("Plugins").add_item("Create Model2"){create_model} ###
      end#if ###
      file_loaded("2.rb") ###
      

      I have difficult to the script,help me 😢 .Thanks!

      1 Reply Last reply Reply Quote 0
      • W Offline
        winzard
        last edited by

        The ruby script can not run in sketchup 6,but can run in sketchup 7. 😳

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          I'm not sure, it worked for me in both 6 and 7. Are you getting any errors in the ruby console?

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          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