sketchucation logo sketchucation
    • Login
    1. Home
    2. sdmitch
    3. Posts
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    Offline
    • Profile
    • Following 0
    • Followers 3
    • Topics 54
    • Posts 1,483
    • Groups 2

    Posts

    Recent Best Controversial
    • RE: Resolve [Ruby help] Script for create window sills

      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
      
      
      posted in Developers' Forum
      sdmitchS
      sdmitch
    • RE: Replace component with random components

      @unknownuser said:

      What happen to this plugin? Would be so great to have it... Will save LOTS of time ๐Ÿ˜„

      The plugin was my ComponentReplacement which can be found on my blog page. Click the "plugin" link then click download. It requires that the "source" instances be given the same instance name and the "target" instances also have the same instance name. The instance name is accessible through the Entity Info window.

      posted in Plugins
      sdmitchS
      sdmitch
    • RE: Make Face Multiple Solids

      Repaired SimpleFrame and code used

      mod = Sketchup.active_model
      ent = mod.active_entities
      sel = mod.selection
      SKETCHUP_CONSOLE.clear
      ent.grep(Sketchup;;Group).each{|g|
       edg = g.entities.grep(Sketchup;;Edge).select{|e|e.faces.count==1}
       edg.each{|e|e.find_faces}; remove=[]
       g.entities.grep(Sketchup;;Edge).each{|e| remove<<e if e.faces.length==2 && e.faces[0].normal.parallel?(e.faces[1].normal)}
       ent.erase_entities(remove.reverse)
      }
      

      SimpleFrameRepaired.skp

      posted in Newbie Forum
      sdmitchS
      sdmitch
    • RE: Who could help to develop this rb?
      
      # version;
      # Added Undo
      
      module JF
        def self.layer_face_camera
          layers = Sketchup.active_model.layers
          name = UI.inputbox(["Layer;","On/Off;"], [layers[0].name,"Off"], [layers.map{|l|l.name}.join("|"),"On|Off"])
          return unless name
          Sketchup.active_model.start_operation("Layer Face Camera")
          Sketchup.active_model.entities.each { |ent|
            next unless ent.is_a? Sketchup;;ComponentInstance
            next unless ent.layer.name == name[0]
            cdef = ent.definition
            cdef.behavior.always_face_camera = true if name[1]=="On"
            cdef.behavior.always_face_camera = false if name[1]=="Off"
          }
          Sketchup.active_model.commit_operation
        end
      end
      
      
      
      posted in Extensions & Applications Discussions
      sdmitchS
      sdmitch
    • RE: Move vertices down to surface

      @pbacot said:

      sdmitch: It worked awesomely. Thank you! What can I do in return?

      You're welcome. Nothing.

      posted in SketchUp Discussions
      sdmitchS
      sdmitch
    • RE: Move vertices down to surface
      
      mod = Sketchup.active_model
      ent = mod.entities
      sel = mod.selection
      SKETCHUP_CONSOLE.clear
      edgs = sel.grep(Sketchup;;Edge)
      if edgs[0]
        vers = edgs.map{|e|e.vertices}.flatten.uniq;
        vecs = []; vrts = []; axis = [0,0,-1]
        for v in vers
          p=v.position;
          h=mod.raytest([p,axis]);
          if h
            vrts << v;
            vecs << p.vector_to(h[0])
          end
        end
        ent.transform_by_vectors(vrts,vecs)
      else
        puts "select edge(s)"
      end
      
      
      
      posted in SketchUp Discussions
      sdmitchS
      sdmitch
    • RE: Select *Most* Collinear Edges

      @m3damind said:

      Is there a plugin to do the following?

      Select Edge
      Operation: read connected edges at selected edge vertices, add to selection the most collinear (In-line with) edge attached to vertice and disregard the rest. Repeat until no edges fall under a custom angle parameter (i.e. X=30ยฐ).

      An operation that would start and end as shown on the attached.

      Try this

      mod = Sketchup.active_model
      ent = mod.active_entities
      sel = mod.selection
      val = UI.inputbox(["Max Ang;"],[30.0],"Most Colinear")
      if val
        max_ang = val[0].degrees
        sel_edg = sel.first
        sel_edg.vertices.each{|start|
          found=true; nxt_edg = sel_edg
          while found
            found=false;
            if start.edges.length > 1
              edges=start.edges-[nxt_edg];
              vec = nxt_edg.line[1]
              edg = edges.min_by{|e|vec.angle_between(e.line[1])}
              ang = vec.angle_between(edg.line[1])
              if  ang < max_ang || ang > Math;;PI-max_ang
                sel.add edg;found=true;
                start = edg.other_vertex(start)
                nxt_edg = edg;
              end
            end
          end
        }
      end
      
      

      Most Colinear.gif

      posted in Plugins
      sdmitchS
      sdmitch
    • RE: Turn off all layers except selected?

      Make selection, paste following code into Ruby Console, press Enter.

      
      mod = Sketchup.active_model
      sel = mod.selection
      unless sel.empty?
        layers = []
        sel.to_a.each{|e|
          layers << e.layer
        }
        layers.flatten!;layers.uniq!
        mod.layers.each{|l|
          next if layers.include?(l)
          l.visible=false
        }
      end
      
      
      posted in Newbie Forum
      sdmitchS
      sdmitch
    • RE: [Plugin] FloorGenerator ( Updated 6-Apr-2017)

      @utiler said:

      Where has the complaint come from??

      Apparently from Trimble and I still have no idea why or what the complaint is about.


      Capture.PNG

      posted in Plugins
      sdmitchS
      sdmitch
    • RE: [Plugin] FloorGenerator ( Updated 6-Apr-2017)

      @dimashariyanto said:

      where i can download this plugin? i have been download from the site http://sdmitch.blogspot.com/ but wan't work.. thanks

      I have removed the plugin from the blog and plugin store because I have received a complaint regarding Copyright infringement.

      posted in Plugins
      sdmitchS
      sdmitch
    • RE: Undoing all transformations

      Maybe this?

      
      mod = Sketchup.active_model
      ent = mod.entities
      sel = mod.selection
      
      cmp=sel.first
      t=cmp.transformation.to_a
      t[0]=1;t[1]=0;t[2]=0;#t[3]=nil
      t[4]=0;t[5]=1;t[6]=0;#t[7]=nil
      t[8]=0;t[9]=0;t[10]=1;#t[11]=nil
      t[12]=0;t[13]=0;t[14]=0;#t[15]=nil
      cmp.transformation=cmp.transformation.set! t
      
      
      
      posted in Developers' Forum
      sdmitchS
      sdmitch
    • RE: Joining wayward edges

      If there is no Face then either there is a 'gap' or the edges are not coplanar. The do not have to be 'welded' together to form a face.

      posted in Newbie Forum
      sdmitchS
      sdmitch
    • RE: Is there a way to view the file size of components &amp; layers?

      A similar request from 2016

      https://sketchucation.com/forums/viewtopic.php?f=15&t=64668&hilit=size+component

      posted in SketchUp Discussions
      sdmitchS
      sdmitch
    • RE: Auto Flat Text or Label

      Select groups.

      Copy and paste the following code into the Ruby Console and press Enter.

      mod = Sketchup.active_model
      ent = mod.active_entities
      sel = mod.selection
      sel.grep(Sketchup;;Group).each{|g|
       pt = Geom;;Point3d.linear_combination(0.5,g.bounds.corner(4),0.5,g.bounds.corner(7))
       ent.add_text(g.name,pt,[0,0,g.bounds.depth])
      }
      
      
      posted in SketchUp Feature Requests
      sdmitchS
      sdmitch
    • RE: Combining components into 1 component

      @ktkoh said:

      I am not familiar with in your code. SKETCHUP_CONSOLE.clear and IDENTITY.

      SKETCHUP_CONSOLE.clear simply clears the Ruby Console so any errors that occur will be more obvious.

      IDENTITY is the same as Geom::Transformation.new().

      posted in Developers' Forum
      sdmitchS
      sdmitch
    • RE: [Plugin] FloorGenerator ( Updated 6-Apr-2017)

      @kuzmic said:

      The Rand Tex Material Picker isn't letting me select materials from a folder or the model.

      Operator error obviously.

      posted in Plugins
      sdmitchS
      sdmitch
    • RE: Combining components into 1 component

      @ktkoh said:

      I am bringing 3 parts (components) which are placed such that if all 3 are exploded and then all selected and made a single component. I have not been able to accomplish this with the API. Any suggestions

      Keith

      1. Create a group
      2. Add instances of each component to the group and explode
      3. Convert group to component.
      mod = Sketchup.active_model
      ent = mod.active_entities
      sel = mod.selection
      SKETCHUP_CONSOLE.clear
      grp = ent.add_group
      cmp = grp.entities.add_instance(mod.definitions["component#1"],IDENTITY);cmp.explode
      cmp = grp.entities.add_instance(mod.definitions["component#2"],IDENTITY);cmp.explode
      cmp = grp.entities.add_instance(mod.definitions["component#3"],IDENTITY);cmp.explode
      cmp = grp.to_component;cmp.definition.name="Cmps1-3"
      
      
      
      posted in Developers' Forum
      sdmitchS
      sdmitch
    • RE: Exporting vertices of every edge to csv

      @coremaster110 said:

      Is this even possible? If yes, then how difficult would that be?

      Also I wouldn't mind any tips.

      Regards,
      Karl

      Yes and not very.

      the basics would be

      mod = Sketchup.active_model
      ent = mod.active_entities
      SKETCHUP_CONSOLE.clear; cnt=0
      ent.grep(Sketchup;;Edge).each{|e|
       cnt += 1;
       sx,sy,sz = e.start.position.to_a;
       ex,ey,ez = e.end.position.to_a;
       printf("Edge %d = (%.1f,%.1f); (%.1f,%.1f)\n",cnt,sx,sz,ex,ez)
      }
      
      

      which would output to the Ruby Console.

      posted in Developers' Forum
      sdmitchS
      sdmitch
    • RE: [Plugin] FloorGenerator ( Updated 6-Apr-2017)

      @traxxx said:

      At least I tried ! ๐Ÿ˜„ And what about the gaps ? Can I avoid them to happen on the planks smallest sides ? Like continuous planks from floor to roof ? Or does it have to be necessarily linked to the longest sides gaps value ?

      Yes, the gap is the same on all sides.

      posted in Plugins
      sdmitchS
      sdmitch
    • RE: [Plugin] FloorGenerator ( Updated 6-Apr-2017)

      One should never say never but modifying FloorGenerator to allow multiple wood widths is as close as you can get. Sorry but I just don't see it happening.

      posted in Plugins
      sdmitchS
      sdmitch
    • 1 / 1