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

    Posts

    Recent Best Controversial
    • Component axes, glueing and animating

      In the situation where door/window components are inserted into a wall, the glueing axis of the component is red/green plane parallel to the wall. However, when you wish to animate the window/door the component axes need to be changed to match the global model, ie red/green plane parallel to floor. Is there a smarter way to all this, or am I missing something?

      posted in Newbie Forum sketchup
      D
      Deanby7
    • RE: Architectural layer name conventions

      Sonder - Sketchup to Layout?

      posted in SketchUp Discussions
      D
      Deanby7
    • RE: Architectural layer name conventions

      JQL How do you split geometry across inside and outside layers of the building? Are external doors and windows residing on both internal and external layers?

      posted in SketchUp Discussions
      D
      Deanby7
    • RE: Architectural layer name conventions

      What book are you referring to Sonder?

      posted in SketchUp Discussions
      D
      Deanby7
    • Architectural layer name conventions

      I'm looking for an architectural layer naming convention to use, rather than re-invent the wheel I wondered if anyone has any suggestions for ones that work for mainly residential type work?

      posted in SketchUp Discussions sketchup
      D
      Deanby7
    • Obtaining selected face vertices

      I know I'm missing something basic here but trying to get the vertices of a selected faced....

      @mod = Sketchup.active_model
            sel = @mod.selection
            verts = sel.grep(Sketchup;;Face) {|f|f.vertices}
            v = verts.position
      
      

      Doesn't give me an array of 3d point values as expected?

      posted in Developers' Forum
      D
      Deanby7
    • RE: Axes vectors in Sketchup 8

      Spotted my error.... p0 = [org] , should be p0 = org
      I had 0,0,0 in there before changing it to a variable. Apologies for wasting forum time!!!

      posted in Developers' Forum
      D
      Deanby7
    • RE: Axes vectors in Sketchup 8

      Trying to follow your example from the holeinthewall!!
      I seem to get hung up on the simplest of things!! I am getting Error: #<ArgumentError: wrong number of values in array> between p "ok" and p "ok2" lines of code!! Grrrrrr

      module DeanBy7
      	module Stair_Builder
      		def self.main
      		    @tht = 2600.mm if(!@tht)
      			@wid = 900.mm if(!@wid)
      			@trd = 32.mm if(!@trd)
      			org = [0,0,0]
      			mod = Sketchup.active_model			
      			xa = X_AXIS
      			ya = Y_AXIS
      			za = Z_AXIS
      			ents = mod.entities
      			str_grp = ents.add_group()
      			str_grp.name = "dbStairs"
      			sents = str_grp.entities
      			prompts = ["Stair Height Total", "Stair Width", "Tread Thickness"]
      			results = UI.inputbox prompts, [@tht,@wid,@trd], "db Stair Builder"
      				if results
      					@tht,@wid,@trd = results; mod.start_operation "db Window Opening"
      					p @tht
      					p @wid
      			        testrisers = @tht / 220.mm
      					risers = testrisers.ceil
                          p testrisers
                          p risers
                          riser = @tht / risers
      					p "Riser = " + riser.to_mm.to_s
      					tread = riser / Math.tan(42.degrees)
      					p "Tread = " + tread.to_mm.to_s
      					p0 = [org]
      					p "ok"
      					p1 = p0.offset(xa, @wid)
      					p "ok2"
      					p2 = p1.offset(ya, tread)
      					p3 = p0.offset(ya, tread)
      					step = sents.add_face(p0,p1,p2,p3)
      					step.pushpull @trd
      					
      					mod.commit_operation
      			    end
      		end
      	end
      end
      unless file_loaded?("dbstairbuilder")
      	UI.menu("Plugins").add_item("db Stair Builder") { DeanBy7;;Stair_Builder.main }
      	file_loaded("dbstairbuilder")
      end
      
      posted in Developers' Forum
      D
      Deanby7
    • Axes vectors in Sketchup 8

      I want to offset points along the x, y and z axes and want to setup vector variables. The following doesn't work in Sketchup 8.

      xa, ya, za = Sketchup.active_model.axes.axes
      

      The Ruby API shows 2016+ in the reference document.
      Is there another way of doing this?

      posted in Developers' Forum
      D
      Deanby7
    • RE: Assigning a default material.

      The last code is exactly what I want. Thanks.

      posted in Developers' Forum
      D
      Deanby7
    • RE: Help with window hole in wall script

      Gary K - They look interesting, I will check these out!
      With TIG and sdmitch's very informative help I have succeeded with my little script!
      Posted here for information. Cheers guys.
      Now to look at automating the move of window component with its associated reveals! Hmmm observers?


      dbwindowwallopen.rb

      posted in Developers' Forum
      D
      Deanby7
    • Assigning a default material.

      I am trying to add a Brick_Antique material to a face with Ruby. The material is in the model already, but will not apply the material with this code....

      mats = Sketchup.active_model.materials
      brick = mats['Brick_Antique']
      ......
      oface.material = brick
      
      

      However, if I make the Brick material current in the model and then use this....

      current = Sketchup.active_model.materials.current
      .....
      oface.material = current
      

      It works!
      I assume from this that the display name cannot be used to reference the material. So how would I get the internal name of any in-model material if you only know its display name?

      posted in Developers' Forum
      D
      Deanby7
    • RE: Help with window hole in wall script

      I take your point. The sides of the reveal are good enough. The bottom is usually covered by a window cill, and the top reveal could be adjusted if needed but could be adjusted but is not as visible as the sides in views of a building. Your door looks good. Was it created with your own plugin? I'd like to play with that! I have a quick and dirty window builder which I created as my first Ruby project. The code is nor pretty, but it works!!

      posted in Developers' Forum
      D
      Deanby7
    • RE: Help with window hole in wall script

      By using the pushpull, the reveals inherit the materials of the main wall faces. In the case of the outer face the reveal brickwork pattern is maintained round the corner, which is good! However, it appears that moving geometry with Ruby is a no-no. Therefore if I want to group the reveal geometry for later ease of movement of window etc then I will have to create it as you say within a group. But I will have to add the material and probably align the texture to suit. It's a trade off I think! Unless anyone has a solution!! Here's hoping πŸ˜„

      posted in Developers' Forum
      D
      Deanby7
    • RE: Help with window hole in wall script

      It's the faces produced by the pushpull operations (the reveal faces "rev_faces") that I want to group together. Can this be done?

      posted in Developers' Forum
      D
      Deanby7
    • RE: Help with window hole in wall script

      Here is an image of my test wall opening!

      https://dl.dropboxusercontent.com/u/2572853/WallOpenTest.jpg

      After the pushpull operation, I've tested the face entities to see if they connect with 2 vertices i've offset into the middle of the reveals (diagonally opposite corners of opening). These faces then reside in rev_faces. I'm trying to create a reveal group within the wall group.

      posted in Developers' Forum
      D
      Deanby7
    • RE: From AutoLisp to Ruby

      I now have the two pick points working from sdmitch's code. I will study the linetool.rb script to fathom getting the cursor to snap to geometry! Something tells me this will be easy task! πŸ˜•

      posted in Developers' Forum
      D
      Deanby7
    • RE: Help with window hole in wall script

      Me again!! 😎
      Trying to group the reveal entities to make it easy to move a window and it opening if I need to. I have managed to create the group but it ends up being transformed and its not inside the wall groupd as expected. I also get a copy of the elements (not grouped but within the wall group transformed to the wall group origin. Also get a BugSplat! Anyone have an idea what I've done wrong?

      module DeanBy7
      	module Window_Opening
      		def self.main
      		    @olt = 103.mm if(!@olt)
      			@twt = 315.mm if(!@twt)
      			@wfd = 70.mm if(!@wfd)
      			@wdi = 50.mm if(!@wdi)
      			
      			mod = Sketchup.active_model
      			sel = mod.selection
      			unless sel.grep(Sketchup;;ComponentInstance).empty?
      				prompts = ["Wall external leaf thickness", "Wall total thickness", "Window Frame Depth", "Window inset"]
      				results = UI.inputbox prompts, [@olt,@twt,@wfd,@wdi], "db Window Opening"
      				if results
      					@olt,@twt,@wfd,@wdi = results; mod.start_operation "db Window Opening"
      					sel.grep(Sketchup;;ComponentInstance){|cdi|
      						trn = cdi.transformation
      						org = cdi.transformation.origin
      						wid = cdi.definition.bounds.width
      						hgt = [cdi.definition.bounds.depth,cdi.definition.bounds.height].max
      						fog = cdi.glued_to
      						if fog!=nil
      						    if fog.is_a?(Sketchup;;Face)
      							    p0 = org; ents = mod.active_entities
      							    xa,ya,za = fog.normal.axes
      						    elsif fog.is_a?(Sketchup;;Group)
      							    gt = fog.transformation;ents = fog.entities
      							    p0 = org.transform(gt.inverse)
      							    gf = ents.grep(Sketchup;;Face).find{|f|f.classify_point(p0)==1}
      							    xa,ya,za = gf.normal.axes
      						    end
      							
      						    cdi.glued_to = nil
      						
      						    p1 = p0.offset(xa,wid) 
      						    p2 = p1.offset(ya,-hgt)
      						    p3 = p0.offset(ya,-hgt)
      						    cut = ents.add_face(p0,p1,p2,p3)
      						    cut.pushpull(-@olt)
      						
      						    p0.offset!(za,-@twt)
      						    p1 = p0.offset(xa,wid)
      						    p2 = p1.offset(ya,-hgt)
      						    p3 = p0.offset(ya,-hgt)
      						    cut = ents.add_face(p0,p1,p2,p3)
      						    cut.pushpull(@olt-@twt)
      							
      							q0 = p0.offset(za, @twt - @olt)
      							q2 = p2.offset(za, @twt - @olt)
      							
      							rev_faces = []
      							ents.each {|e|
                                  if e.is_a? Sketchup;;Face
                                      clp = e.classify_point q0
      	                            if clp == 2
      	                                rev_faces << e
      					            end
                                  end
                                  }
      							ents.each {|e|
                                  if e.is_a? Sketchup;;Face
                                      clp = e.classify_point q2
      	                            if clp == 2
      	                                rev_faces << e
      					            end
                                  end
                                  }
      							
      						    rev_grp = fog.entities.add_group rev_faces
      							rev_grp.name = "Reveals"
      							
      						    vect = cdi.transformation.zaxis.reverse
                                  vect.length = @wfd+@wdi
      						    cdi.transform!(vect)
                              else
                                  UI.messagebox "Component not Glued!", MB_OK					  
                              end
      					}
      					mod.commit_operation
      				end
      			end
      		end
      	end
      end
      
      unless file_loaded?("dbwindowwallopen")
      	UI.menu("Plugins").add_item("db Window Opening") { DeanBy7;;Window_Opening.main }
      	file_loaded("dbwindowwallopen")
      end
      
      

      I'm learning through a lot of mistakes!!!

      posted in Developers' Forum
      D
      Deanby7
    • RE: Help with window hole in wall script

      TIGs thanks for very useful detailed information regarding variables etc. I thought I would try the simple solution of using instance variables as I only want the values to persist within the current session and model. If I've read your explanation correctly. Not sure I have as this script works on the first run through but on the second run of the script I get an error ......
      Error: #<ArgumentError: comparison of Length with nil failed>

      module DeanBy7
      	module Window_Opening
      		def self.main
      		    if @olt==nil; @olt = 103.mm; end
      			if @twt==nil; @twt = 315.mm; end
      			if @wfd==nil; @wfd = 70.mm; end
      			if @wdi==nil; @wdi = 50.mm; end
      			
      			mod = Sketchup.active_model
      			sel = mod.selection
      			unless sel.grep(Sketchup;;ComponentInstance).empty?
      				prompts = ["Wall external leaf thickness", "Wall total thickness", "Window Frame Depth", "Window inset"]
      				results = UI.inputbox prompts, [@olt,@twt,@wfd,@wdi], "db Window Opening"
      				if results
      					@olt,@twt,@wfd,@wdi = results; mod.start_operation "db Window Opening"
      					sel.grep(Sketchup;;ComponentInstance){|cdi|
      						trn = cdi.transformation
      						org = cdi.transformation.origin
      						wid = cdi.definition.bounds.width
      						hgt = [cdi.definition.bounds.depth,cdi.definition.bounds.height].max
      						fog = cdi.glued_to
      						if fog!=nil
      						    if fog.is_a?(Sketchup;;Face)
      							    p0 = org; ents = mod.active_entities
      							    xa,ya,za = fog.normal.axes
      						    elsif fog.is_a?(Sketchup;;Group)
      							    gt = fog.transformation;ents = fog.entities
      							    p0 = org.transform(gt.inverse)
      							    gf = ents.grep(Sketchup;;Face).find{|f|f.classify_point(p0)==1}
      							    xa,ya,za = gf.normal.axes
      						    end
      							
      						    cdi.glued_to = nil
      						
      						    p1 = p0.offset(xa,wid) 
      						    p2 = p1.offset(ya,-hgt)
      						    p3 = p0.offset(ya,-hgt)
      						    cut = ents.add_face(p0,p1,p2,p3)
      						    cut.pushpull(-@olt)
      						
      						    p0.offset!(za,-@twt)
      						    p1 = p0.offset(xa,wid)
      						    p2 = p1.offset(ya,-hgt)
      						    p3 = p0.offset(ya,-hgt)
      						    cut = ents.add_face(p0,p1,p2,p3)
      						    cut.pushpull(@olt-@twt)
      						
      						    vect = cdi.transformation.zaxis.reverse
                                  vect.length = @wfd+@wdi
      						    cdi.transform!(vect)
                              else
                                  UI.messagebox "Component not Glued!", MB_OK					  
                              end
      					}
      					mod.commit_operation
      				end
      			end
      		end
      	end
      end
      
      unless file_loaded?(__FILE__)
      	UI.menu("Plugins").add_item("db Window Opening") { DeanBy7;;Window_Opening.main }
      	file_loaded(__FILE__)
      end
      
      

      Ruby is obviously "picky" about nil and lengths, unlike AutoLisp! 😞
      Or have I done something stupid?

      posted in Developers' Forum
      D
      Deanby7
    • RE: Help with window hole in wall script

      Thanks for suggestions. I have used TIG's holepunch tool and it is very good (complicated code!) but I wanted a script which would pushpull from both sides to retain materials applied to both sides of the wall, ie brick on the outer and a colour on the inside for instance. Doing it this way, populates the reveals with the corresponding material.
      I've also looked at the technique you suggested in url. This assumes you know the wall thickness and construct the reveals on your window components. The window components need to be modified for different wall constructions. Not what I want to do.
      With sdmitch and TIG's help, my script is working ok for my needs. Just need to sort out the user changeable variables to be persistent between script uses now!! 😐
      Thanks anyway.

      posted in Developers' Forum
      D
      Deanby7
    • 1 / 1