sketchucation logo sketchucation
    • Login
    1. Home
    2. Zane
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    Z
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 4
    • Posts 16
    • Groups 1

    Zane

    @Zane

    10
    Reputation
    1
    Profile views
    16
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    Zane Unfollow Follow
    registered-users

    Latest posts made by Zane

    • RE: Drawing an array of boxes

      Thanks Dan, I have read the pragmatic programmers book but that was a while back and unfortunately I have a deadline submission I need to meet next week, i've managed to get the C++ side of the coding done but am struggling with the Ruby and don't have time to re-assess what i've learnt, just need to sift through the relevant information and collaborate it.

      posted in Developers' Forum
      Z
      Zane
    • RE: Drawing an array of boxes

      ok, thanks for the headsup on that, any idea about the crazy looping issue or why I can't see the puts anymore? Oh, and that module question, sorry there's so much to ask.

      posted in Developers' Forum
      Z
      Zane
    • RE: Drawing an array of boxes

      Sorry Dan, i'm a bit lost as to what you mean by your last post, why is it that I would split the file up into bits and what is the purpose of using modules, i've read they're similar to classes but nothing specified a distinct reason as to why they are as they are?

      I'm also curious as to what you meant when you wrote module_function(:function) in the box.rb file, what does it do exactely? I presume it can only be used for external functions and not ones in classes?

      posted in Developers' Forum
      Z
      Zane
    • RE: Pause until action is complete

      That's great! Thanks Dan and Chris πŸ˜„

      posted in Developers' Forum
      Z
      Zane
    • RE: Drawing an array of boxes

      I think i've found it with the help you gave there (just a snippet of the code where the error might be):

      
      class Building
      	def io_calcs
      		#distprompts = [$exStrings.GetString("What is the distance between the start of one column to the start of the next one? (make it at least 1m more than the width of the foundation")]
      		#distvalues = [5500]
      		# Now display the inputbox
      		#distresults = inputbox distprompts, distvalues, $exStrings.GetString("Distance between each column  (mm)")
      		#return if not distresults # This means that the user cancelled the operation
      		#coldistance = distresults
      		
      		
      		##Enter values from C++ here
      		
      		slab = IO.readlines('C;\\Users\\Zane\\My Documents\\slabout.txt')
      		@slabdepth = slab[0].to_f.mm
      		@slabwidth = slab[1].to_f.mm
      		@slabheight = slab[2].to_f.mm		
      		#UI.messagebox ("Sketchup will now take in the details and attempt to draw the building", MB_OK)
      	end
      
      

      It's either not taking in the values of slabheight, slapdepth nor slabwidth as i'm trying to take them in from an input file.
      It's not even letting me "puts" the variables nor any other string I tell it to output like:

      puts 'test'

      Ideally i want to input variables from a text file whose content is

      250
      5500
      7700

      and assign each one of these values to a variable, then use those respective variables.

      posted in Developers' Forum
      Z
      Zane
    • RE: Drawing an array of boxes

      Ahh i see, thanks for that πŸ˜„

      Another error now, the code keeps looping and doesn't stop (doesn't draw either), the values seem to be wrong also... nothing seems to be working :s

      posted in Developers' Forum
      Z
      Zane
    • RE: Drawing an array of boxes

      I used Building.new and called the io_calcs function as well as the draw_slab_array function, what does that mean about my variables then, should I be able to use them within the functions that are in the class?

      To my knowledge, within a class, Ruby makes all of it's variables and functions public unless specified otherwise, so it confuses me as to why I get this problem of the variable not being read

      posted in Developers' Forum
      Z
      Zane
    • Drawing an array of boxes
      
      module Examples 
      module SU 
      module Structure 
      require 'sketchup.rb' 
      class Building 
              def io_calcs 
                      #distprompts = [$exStrings.GetString("What is the distance between 
      the start of one column to the start of the next one? (make it at 
      least 1m more than the width of the foundation")] 
                      #distvalues = [5500] 
                      # Now display the inputbox 
                      #distresults = inputbox distprompts, distvalues, 
      $exStrings.GetString("Distance between each column  (mm)") 
                      #return if not distresults # This means that the user cancelled the 
      operation 
                      #coldistance = distresults 
                      ##Enter values from C++ here 
                      slab = IO.readlines('C;\\Users\\Zane\\My Documents\\slabout.txt') 
                      $slabdepth = slab[0].to_f.mm 
                      $slabwidth = slab[1].to_f.mm 
                      $slabheight = slab[2].to_f.mm 
                      UI.messagebox ("Sketchup will now take in the details and attempt to 
      draw the building", MB_OK) 
              end 
              def draw_slab 
                      # Makes the process seem to be one rather than many; undo will undo 
      the whole operation 
                      model = Sketchup.active_model 
                      model.start_operation $exStrings.GetString("Draw Slab") 
                      #Adds model to the active entities collection 
                      entities = model.active_entities 
                      #Creates the object as a group 
                      group = entities.add_group 
                      entities = group.entities 
                      #gives an initial location for the foundation 
                      $slabwidth += $start_of_slab 
                      #Creates an array of points for the base 
                      pts = [] 
                      pts[0] = [$start_of_slab, 0, 0] 
                      pts[1] = [$slabwidth, 0, 0] 
                      pts[2] = [$slabwidth, $slabdepth, 0] 
                      pts[3] = [$start_of_slab, $slabdepth, 0] 
                      base = entities.add_face pts 
                      # reverses direction of pushpull if incorrect. 
                      $slabheight = -$slabheight if( base.normal.dot(Z_AXIS) < 0 ) 
                      # pushpulls object 
                      base.pushpull $slabheight 
                      # ends operation 
                      model.commit_operation 
              end 
              def draw_slab_array #need to do 
                      $start_of_slab = 0.mm 
                      draw_slab 
                      wob = 30000.mm #not needed in the final one 
                      wobt = wob 
                      while ((wobt - $slabheight)>$slabheight) 
                              $start_of_slab = $slabwidth + $slabheight 
                              draw_slab 
                              wobt = wobt - $slabheight 
                      end 
                      $start_of_slab = wob - $slabheight 
                      draw_slab 
              end 
      end 
      if( not file_loaded?("structureclasstestforstartpoints.rb") ) 
          # Adds a separator to the menu 
              add_separator_to_menu("Draw") 
          # Adds item inside the menu allowing a bit of code to be 
          #carried out if clicked on 
              UI.menu("Draw").add_item($exStrings.GetString("Test Structural 
      Slab")) do 
                      frame = Building.new 
                      frame.io_calcs 
                      frame.draw_slab_array 
              end 
              file_loaded("structureclasstestforstartpoints.rb") 
      end 
      end #Structure 
      end #SU 
      end #Examples 
      
      
      
      1. Why is it that I need to create global variables for my program to
        say that the variable is recognised? Surely I can just use the
        variable anywhere in the class and it will work so long as it has been
        intialised before use?

      2. Do you guys see anything else wrong with the code?

      3. The code keeps looping in the while loop... help? (slabheight is about 7700)

      Thanks for your help guys!

      posted in Developers' Forum
      Z
      Zane
    • RE: Pause until action is complete

      some text files will available for input is one thing that will be available after the system call

      posted in Developers' Forum
      Z
      Zane
    • RE: Pause until action is complete

      Ah ok, sorry for posting it in the wrong section

      posted in Developers' Forum
      Z
      Zane