sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Window components

    Scheduled Pinned Locked Moved Plugins
    5 Posts 3 Posters 874 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.
    • K Offline
      kat
      last edited by

      Hello,
      I'm working on a script to get information about the windows a user placed in his Sketchup model.
      To do so, I'v made some window models and placed them into the 'Components' folder.
      With a Ruby script, I attach the information about the windows by using attributes. Now, I also want my windows to cut a hole in the wall they are placed into, but this doesn't really work.
      I've tried to change the behavior of the componentdefinition of my windows with this code:

      componentdef = Sketchup.active_model.definitions.load path
      componentdef.behavior.snapto = SnapTo_Vertical
      componentdef.behavior.cuts_opening = true
      

      But when a user now places an instance of the window component in his model, nothing happens, the wall stays intact and no hole is cut out. I think the component isn't really glued to the face because when i ask all the faces in the model whether they have a component glued to with get_glued_instances, nil is returned.
      Is my approach to simplistic? Or does anyone know what I am doing wrong?
      Thanks a lot for any help

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Behavior.is2d=
        http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/behavior.html#is2d=

        @unknownuser said:

        The is2d= method is used to set the 2D behavior for a component: whether it can be glued or aligned to a face.

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

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

          Hey,
          Thanks a lot for your help last time, I've changed my script a bit, but unfortunally, it still doesn't work.
          The component doesn't cut a hole in the face it is placed into and it is not placed on the right layer.
          I really can't see what is wrong. I am sending you the entire method I wrote to load the window components placed in the components folder into the SU model.

          def laad_componenten
          
          # Define correct path for the csv information file
          windowcomponents = File.join($components,"Ramen","*.csv")
          files = Dir.glob(windowcomponents)
          # String loaded components
          @loaded_comp = " "
          
          # Look for the windows
            files.each { |file|
          	  f = File.open(file,"r")
          	f.each {|line| line.to_s
          			    @data  = line.split(';').each { |string| string.strip} 
          		  }
          	name = @data[0].to_s
          	
          	# Define the path of the SU window 	  
          	path = File.join($components,"Ramen", name+".skp")
          	# Load the component into the current model
          	componentdef = Sketchup.active_model.definitions.load path
          	
                  # Attatch csv information to component using attributes
          	componentdef.set_attribute "info", "naam", naam.to_s
          	componentdef.set_attribute "info", "diktes", @data[1]
          	componentdef.set_attribute "info", "U-waarde", @data[2]
          	componentdef.set_attribute "info", "g-waarde", @data[3]
          	componentdef.set_attribute "info", "kostprijs", @data[4]
          	
          	componentdef.visible = true
          	componentdef.behavior.is2d = true
          	componentdef.behavior.cuts_opening = true 
          	
          	# Put component on the right layer
          	windowlayer = $model.layers.at("Ramen")
          	componentdef.layer = windowlayer 
          	
          	# Name of loade component in string
          	@loaded_comp = @loaded_comp+naam+" ;"
          	
          	f.close 
          } end
          
          @loaded_comp.chop!
          UI.messagebox "All windows components loaded;"+@loaded_comp
          
          end
          

          Hopefully you can help me
          thanks

          1 Reply Last reply Reply Quote 0
          • TIGT Offline
            TIG Moderator
            last edited by

            Did you make the component so it is 'flat' in 3D so that its "up" axis is Y/green ?
            OR at least when you 'made' it set its axes thus...
            Then it will cut a hole at its Z=0 plane on any face it is glued_to/cuts/is_2d ...

            TIG

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

              yes, it works!
              I made my windows in the SU components folder in the upright position,
              should have done it in the horizontal plane...
              thanks a lot tig!!!

              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