sketchucation logo sketchucation
    • Login
    1. Home
    2. driven
    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 43
    • Posts 2,966
    • Groups 2

    Posts

    Recent Best Controversial
    • RE: (TRICK) To re-enable skp file preview

      it works fine with El Capitan and SU v17 for me...

      if the Finder icon size is set to small it will revert to the generic icon instead...

      and it will show old files the same unless saved in v17...

      are you seeing none?

      john

      posted in SketchUp Tutorials
      D
      driven
    • RE: HTMLDialog vs WebDialog?

      gotcha, you mean bug SU-35701.

      john

      posted in Developers' Forum
      D
      driven
    • RE: HTMLDialog vs WebDialog?

      @dan rathbun said:

      Let us try some tests to see if we can get Chrome to close the select drop lists.

      using Enter or a Click closes them, if not, there is a javascript over-ride preventing default behaviour...

      john

      posted in Developers' Forum
      D
      driven
    • RE: HTMLDialog vs WebDialog?

      @garry k said:

      I use JQuery - not JsFiddle.

      JsFiddle is an online test environment...

      you can even test your jQuery in it...

      if you launch it from within SU it quickly shows if code works in the SU browser of your running [IE/Safari/CEF]...

      to test you use set_url and add code too see what flies...

      both your issues work in CEF using vanilla js inside SU, so are most likely jQuery needing updating...

      john

      posted in Developers' Forum
      D
      driven
    • RE: HTMLDialog vs WebDialog?

      Garry

      I can color the backgrounds of input boxes with css...

      and the Enter key works as well...

      test this fiddle in a HtmlDialog...

      http://jsfiddle.net/wkpeq/1/

      it works on a mac for CEF in SU...

      are you trying with jQuery or another framework?

      john

      posted in Developers' Forum
      D
      driven
    • RE: Delete a list of components by their definitions.

      you must have changed something because it does work for me...

      did you read the code?

      it collects all nested materials from 'everything' before removing any materials...

      click image to see gif:it_wors.gif

      attach your test code...

      john

      posted in Developers' Forum
      D
      driven
    • RE: Delete a list of components by their definitions.

      another way is to Hash the materials and set values for each...

        def purge_comps_n_mats(*args)
        model  = Sketchup.active_model
        defs   = model.definitions
        sel    = model.selection
        view   = model.active_view
        ents   = model.active_entities
        mats   = model.materials
        # add a hasj for materials and entities
        mats_h = Hash[mats.zip([1] * mats.size)]
      
        # this means you don't have to get Regexp right yourself
        names = Regexp.union(args)
        # this is similar to defs.to_a.dup.flatten
        list = defs.find_all { |d| d }
        # we will still only use one operation as v17 will error
        model.start_operation('mats')
      
      
        list.each do |defn|
          defn.instances.each do |i|
      
             ######################
             # optional 'showtime' for testing
      	sel.add(i)
      	view.refresh
      	sleep 0.2
      	######################
      
            dents = defn.entities
            if defn.name =~ names
              # get rid of the comps checking their materials
               mats_h[defn.material] = 3 unless defn.material.nil?
               mats_h[i.material] = 3 unless i.material.nil?
               dents.to_a.each do |item|
                mats_h[item.material] = 3 if item.respond_to? ;material
                mats_h[item.back_material] = 3 if item.respond_to? ;back_material
              end
      	# delete the instance
      	ents.erase_entities(i)
            else
              mats_h[defn.material] = 2 unless defn.material.nil?
              mats_h[i.material] = 2 unless i.material.nil?
              dents.to_a.each do |item|
                mats_h[item.material] = 2 if item.respond_to? ;material
                mats_h[item.back_material] = 2 if item.respond_to? ;back_material
              end
            end
          end
        end
      
        ents.to_a.each do |item|
      
      		######################
      		# optional 'showtime' for testing
      		sel.add(item)
      		view.refresh
      		sleep 0.2
      		######################
      
          mats_h[item.material] = 2 if item.respond_to? ;material
          mats_h[item.back_material] = 2 if item.respond_to? ;back_material
        end
      
         mats_h.each { |k, v| mats.remove(k) unless k.nil? || v != 3 }
      
        model.commit_operation #
      end
      
      purge_comps_n_mats('CUBE', 'TOTO', 'LOLA')
      
      

      john

      posted in Developers' Forum
      D
      driven
    • RE: Delete a list of components by their definitions.

      edited my example...

      line 55 i is now item...

      john

      posted in Developers' Forum
      D
      driven
    • RE: Application Development Exploding Component Instances

      it's basically TIG's code + a couple of tweaks, I made it 'visualised' to help you 'see' what's happening because I find it useful myself...

      none of these are needed at all and the code will run faster...

      
            sel.add(i)
            view.refresh
            sleep 0.2
      

      so either comment them out or delete them for 'production code'...

      any 'progress bar' will add even more overhead and can only slow the progress more...

      john

      posted in Developers' Forum
      D
      driven
    • RE: Weird DimensionLinear behavior

      you can do things by comparing instance scaling...

      model = Sketchup.active_model
      defs = model.definitions
      insts = defs[0].instances
      insts.each{|i| p (i.scaled_size - i.unscaled_size)[0].to_mm if i.scaled_size != i.unscaled_size}
      

      john

      posted in Developers' Forum
      D
      driven
    • RE: Application Development Exploding Component Instances

      sometime it's worth writing 'visual code' to see how the ruby works...

      click to see gif...
      to_go.gif

      this is based on Tigs example

      def explode_named(*args)       
      	model = Sketchup.active_model
      	defs = model.definitions
      	sel    = model.selection
      	view = model.active_view 
      	names = Regexp.union(args)
      	matches = defs.find_all{|d| d.name =~ names }
      	model.start_operation('Explode Inards')
      	matches.each{|match| 
           match.instances.each{|i|
      		sel.add(i)
      		view.refresh
      		sleep 0.2
      		i.explode
      		}
      	}
        defs.purge_unused
        model.commit_operation #
      end
      
      
      

      to run

      explode_named("Sophie","Chris")
      

      john

      posted in Developers' Forum
      D
      driven
    • RE: Using geometry to erase geometry?

      you can use a copy of raw geometry to remove it...

      click image to see the gif...

      raw_delete.gif

      john

      posted in SketchUp Discussions
      D
      driven
    • RE: Get mac address in ruby

      I don't use win dose at all, but you could try fixing the ruby which is failing on line 86...

      add this after the current line 85 and save...

       next if addr.addr.nil?
      

      re-start SU and

      # required the gem
      require 'macaddr'
      # call the method
      Mac.addr
      

      john

      posted in Developers' Forum
      D
      driven
    • RE: Get mac address in ruby

      that is copy pasted from Ruby Console in SU v17

      # first I installed the two gems
       Gem.install 'systemu'
       Gem.install 'macaddr'
      # then I required the gem
      require 'macaddr'
      # then I called the method
      Mac.addr
      # I left out the return as I don't want it public...
      
      

      john

      posted in Developers' Forum
      D
      driven
    • RE: Get mac address in ruby

      works on my mac...

      you need to fill in your details...

      > Gem.install 'systemu'
      [#<Gem;;Specification;0x3fdf178087e4 systemu-2.6.5>]
      > Gem.install 'macaddr'
      [#<Gem;;Specification;0x3fdf1841b4c8 macaddr-1.7.1>]
      > require 'macaddr'
      true
      > Mac.addr
      
      

      john

      posted in Developers' Forum
      D
      driven
    • RE: Fluid freehand

      the way it works in Preview.app would be good...

      in_preview.gif

      john

      posted in Developers' Forum
      D
      driven
    • RE: Measure a dxf for me?

      @tuna1957 said:

      Why did this file import into SU at such an abnormal size?

      you need to set the import units to match the files units...

      I normally have it set to meters, but changed it to inches for this one...

      john

      posted in Corner Bar
      D
      driven
    • RE: [Plugin] Goldilocks v2.0

      Goldilocks needs a minor tweak to be better on a mac...

      do a search and replace for the word 'show' and replace with 'show_modal'...

      john

      posted in Plugins
      D
      driven
    • RE: Measure a dxf for me?

      there is an error on the end and results depend on how you fix it...
      2017-05-07 08.33.11 pm.png

      john

      posted in Corner Bar
      D
      driven
    • RE: 6x1 Cubemap

      have you tried setting your 'Viewport' to the same ratio as export?

      i.e. make it square...

      john

      posted in SketchUp Discussions
      D
      driven
    • 1
    • 2
    • 3
    • 4
    • 5
    • 148
    • 149
    • 2 / 149