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

    Posts

    Recent Best Controversial
    • AI-Created Extension for SketchUp – Issues with CTRL Modifier Functionality

      Hi everyone,

      I’m having trouble with a custom SketchUp tool that was created by AI. The tool correctly highlights a selected plane and applies materials to it when clicked. Additionally, this code works for closed groups and components. However, the CTRL modifier functionality is not working as expected. Here’s a summary of the issues I’m facing:

      Plane Highlighting: The tool highlights the plane correctly when hovered over and works on closed groups and components.
      Material Application: Materials are correctly applied to the selected plane or to closed groups and components when clicked.
      CTRL Modifier: The CTRL key should trigger the application of the material to the entire object (group or component) rather than just the selected plane. This should work for both closed groups and components, but this functionality is not working.
      Here is the relevant code:

      module CustomSelectionTool
      
        class SelectPlaneTool
      
          def initialize
            @ip = Sketchup::InputPoint.new
            @view = Sketchup.active_model.active_view
            @last_face = nil
            @model = Sketchup.active_model
            @selection = @model.selection
            @materials = @model.materials
          end
      
          def onMouseMove(flags, x, y, view)
            @ip.pick(view, x, y)
            face = @ip.face
      
            if face && face.is_a?(Sketchup::Face)
              if face != @last_face
                # Clear previous selection
                @selection.clear
      
                # Select the new face
                @selection.add(face)
                @last_face = face
                view.invalidate
              end
            else
              if @last_face
                # Clear selection when there is no face
                @selection.clear
                @last_face = nil
                view.invalidate
              end
            end
      
            view.tooltip = @last_face ? "Face selected" : "No face selected"
          end
      
          def onLButtonDown(flags, x, y, view)
            if @last_face
              if (flags & MK_CONTROL) == MK_CONTROL
                # Apply material to the entire object (group or component)
                apply_material_to_object(@last_face.parent)
              else
                # Apply material to the selected face
                apply_material(@last_face)
              end
              @last_face = nil
              view.invalidate
            end
          end
      
          def apply_material(face)
            material = @model.materials.current
            if material
              face.material = material
            else
              puts "No material to apply"
            end
          end
      
          def apply_material_to_object(entity)
            material = @model.materials.current
            if material
              if entity.is_a?(Sketchup::Group) || entity.is_a?(Sketchup::ComponentInstance)
                entity.entities.grep(Sketchup::Face).each { |f| f.material = material }
              elsif entity.is_a?(Sketchup::Face)
                entity.material = material
              else
                puts "Cannot apply material to this type of object"
              end
            else
              puts "No material to apply"
            end
          end
      
        end
      
        def self.activate_select_plane_tool
          Sketchup.active_model.select_tool(SelectPlaneTool.new)
        end
      
      end
      
      if !file_loaded?(__FILE__)
        UI.menu('Plugins').add_item('Select Plane Tool') {
          CustomSelectionTool.activate_select_plane_tool
        }
        file_loaded(__FILE__)
      end
      
      

      What I’ve Tried:

      Using Sketchup::InputModifier::CTRL to check if the CTRL key is pressed.
      Ensuring the current material is selected before applying it.
      Any suggestions or insights on why the CTRL key functionality is not applying the material to the entire object (including closed groups and components) as intended would be greatly appreciated. Thank you!

      The code is written in Ruby 1.8, which is compatible with SketchUp 8.

      Robert

      posted in Developers' Forum
      robertWanR
      robertWan
    • RE: [PLUGIN] Flowify v1.1.0 (updated 150327)

      There is no chance for the plugin to work in SU8?

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • RE: [Plugin] Center of Gravity

      CoG2.png
      Works!
      I am extremely grateful.
      Thank you.

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • RE: [Plugin] Center of Gravity

      @TIG said in [Plugin] Center of Gravity:

      restart SketchUp and see if that helps...

      CoG1.png

      Unfortunately it didn't help.

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • RE: [Plugin] Center of Gravity

      @TIG Should I look for an older version or is there any way to make it work in 8.0 Pro?CoG.png

      posted in Plugins
      robertWanR
      robertWan
    • System clipboard

      Is it possible to copy the contents of the VCB window to the system clipboard using a script (SU8)?

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • Cabinet

      Cabinet. Recess for a TV decoder.
      I was hoping they would choose a lightened version.

      Robert


      rtv y.jpg


      1111.jpg


      111.jpg


      11.jpg


      1.jpg

      posted in Woodworking
      robertWanR
      robertWan
    • Three beds.

      Nothing special. The client chose one of three proposals.

      Robert


      2.png


      3.png


      4.png


      lozko2.jpg

      posted in Woodworking
      robertWanR
      robertWan
    • RE: Magic balls.

      @gullfo said:

      nice box, nice balls.

      Thanks. The customer wants something more exclusive. I'm looking for inspiration. Apparently squares and triangles are fashionable now.


      piramidki111.jpg

      posted in Woodworking
      robertWanR
      robertWan
    • RE: Table

      I found photos of ready-made tables.


      P1154514.JPG


      P1154512.JPG


      P1154519.JPG

      posted in Woodworking
      robertWanR
      robertWan
    • Magic balls.

      pudelko2.jpg

      My job is just boxes.
      The balls are made of copper. Holding them in your hand is said to improve your health. I hid the magnet in the actual box.

      Robert


      K1.png


      K2.jpg

      posted in Woodworking
      robertWanR
      robertWan
    • RE: [Plugin] SPGears

      @dave r said:

      It's trivial to make them 3D in SketchUp from there, though.

      Yes I know. That's what I do. I was forced to look for a gear generator because I needed a rack gear.

      But there is nothing like in the plugin, i.e. HELIX and BEVEL.

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • RE: [Plugin] SPGears

      @dave r said:

      It doesn't appear to be but who knows?

      But if... someday. There are a lot of parameters here, but 2D.
      https://evolventdesign.com/pages/spur-gear-generator

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • RE: [Plugin] SPGears

      The plugin works, but when starting SU8 I get:
      "Error Loading File MJGrundman_SPGears.rb
      uninitialized constant MJGrundman::SPGears::EXTENSION"

      Any conflict with another plugin? I've had it on another computer before with no problems.

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • RE: Group dimension

      Yes, I know what the problem is.
      I have removed the UI.messagebox window and display the results in VCB. Now it works more efficiently. You do not have to close the window after each measurement. Only with PAN or ORBIT the window is cleared.

      Sketchup;;set_status_text(("#{dims.sort.reverse[0].to_l} x #{dims.sort.reverse[1].to_l} x #{dims.sort.reverse[2].to_l}"), SB_VCB_VALUE)
      

      Dimension2.jpg

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • RE: Group dimension

      @dave r said:

      set up a keyboard shortcut.

      So I did.

      @dave r said:

      Question: Are you planning to go through your model and manually get the dimensions of each component or group? That sounds like a lot of work.

      I have control over what I want on the list.
      I know that there are dedicated plug-ins for lists of elements, but I think this simple solution will work. There is a small problem.
      Dimension.jpg

      There was probably a plugin that aligns such a rotated group. But that's a detail and probably won't bother me.

      Or is there a simple way to modify the code?

      #-----------------------------------------------------------------------------
      #
      # Copyright 2005, CptanPanic 
      #
      # THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
      # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
      # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
      #
      #-----------------------------------------------------------------------------
      # Name        ; GetDimensions.rb
      # Type        ; Tool
      # Description ; Displays Dimensions of Component.
      # Menu Item   ; Plugins -> Get Component Dimensions.
      # Context-Menu; None
      # Author      ; CptanPanic
      # Usage       ; Select Component, and call script.
      # Date        ; December 2005
      # Version     ;	1.1			2014 compatible
      # History     ;	1.0			Initial Release.
      #
      #             ; 2010-06 <jim.foltz@gmail.com>
      #               returns "true" dimensions for rotated and scaled Group and Instance.
      #
      #             ; 
      #
      #-----------------------------------------------------------------------------
      
      require 'sketchup.rb'
      
      module JF
        module GetDimensions
          VERSION = 1.1
      
          def self.get_dimensions
      
            model = Sketchup.active_model
            selection = model.selection
      
            ### show VCB and status info...
            Sketchup;;set_status_text(("GET COMPONENT DIMENSIONS..." ), SB_PROMPT)
            Sketchup;;set_status_text(" ", SB_VCB_LABEL)
            Sketchup;;set_status_text(" ", SB_VCB_VALUE)
      
            ### Get Selected Entities.
            return unless selection.length == 1
            e = selection[0]
            return unless e.respond_to?(;transformation)
      
            scale_x = ((Geom;;Vector3d.new 1,0,0).transform! e.transformation).length
            scale_y = ((Geom;;Vector3d.new 0,1,0).transform! e.transformation).length
            scale_z = ((Geom;;Vector3d.new 0,0,1).transform! e.transformation).length
      
            bb = nil
            if e.is_a? Sketchup;;Group
              bb = Geom;;BoundingBox.new
              e.entities.each {|en| bb.add(en.bounds) }
            elsif e.is_a? Sketchup;;ComponentInstance
              bb = e.definition.bounds
            end
      
            if bb
              dims = [
                width  = bb.width  * scale_x,
                height = bb.height * scale_y,
                depth  = bb.depth  * scale_z
              ]
              UI.messagebox("Width;\t#{dims[0].to_l}\nHeight;\t#{dims[1].to_l}\nDepth;\t#{dims[2].to_l}")
            end
          end
        end
      end
      
      ### do menu
      
      if( not file_loaded?("jf_get_dimensions.rb") )
        menu_name = "[jf] Get Dimensions"
        UI.menu("Plugins").add_item(menu_name) { JF;;GetDimensions.get_dimensions }
      end#if
      file_loaded("jf_get_dimensions.rb")
      

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • RE: Group dimension

      I found this one, I think:
      https://sketchucation.com/forums/viewtopic.php?f=323&t=28851

      There's only one catch... there is no icon, but maybe a keyboard shortcut will help.

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • RE: Group dimension

      Yes, only I will use it by selecting individual groups (or components) that the furniture consists of.

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • Group dimension

      Is there a plugin that displays the dimensions of a group after selecting it? I'm looking for a simple way to make a list of furniture items. I know that there are extensive plugins that make a list to a file.

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • RE: [Plugin] SketchUcation Tools 2.6.1

      Where can I find version 261? I have SU8.
      It still says here that it's version 261 to SU8.
      https://sketchucation.com/plugin/696-sketchucationtools

      @unknownuser said:

      for earlier SketchUp versions <=v8 v2.6.1

      Robert

      posted in Plugins
      robertWanR
      robertWan
    • 1 / 1