sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Simple question: Click to create a point

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 620 Views 2 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.
    • B Offline
      bardlind
      last edited by

      Long time lurker and Sketchup user, first time poster. Hello!

      I have finally gotten around to creating a little extension for Sketchup, which I will post later on. This is my first time coding in Ruby (and one of my first times coding, ever).

      In the beginning of my script, I create two concentric circles which the rest of the code is based upon. For now, I have just entered the [x, y, z] coordinate for the center point manually. However, I would like to be able to do this:

      Draw a line in Sketchup. Then select my tool from the extensions menu. Click the end of the line I just drew, and this point's xyz is used in my script as the center point.

      I realize this is probably the simplest part of my script, but I have not been able to figure it out. Help is appreciated πŸ˜„

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        @bardlind said:

        Long time lurker and Sketchup user, first time poster. Hello!

        I have finally gotten around to creating a little extension for Sketchup, which I will post later on. This is my first time coding in Ruby (and one of my first times coding, ever).

        In the beginning of my script, I create two concentric circles which the rest of the code is based upon. For now, I have just entered the [x, y, z] coordinate for the center point manually. However, I would like to be able to do this:

        Draw a line in Sketchup. Then select my tool from the extensions menu. Click the end of the line I just drew, and this point's xyz is used in my script as the center point.

        I realize this is probably the simplest part of my script, but I have not been able to figure it out. Help is appreciated πŸ˜„

        Your plugin must be an interactive tool like this

        #------------------------------------------------------------------------------------------------
        # Permission to use, copy, modify, and distribute this software for 
        # any purpose and without fee is hereby granted.
        #------------------------------------------------------------------------------------------------
        # 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;	Add Circles
        #      By;	Bardlind
        #   Usage;	Plugins>Add Circles
        #------------------------------------------------------------------------------------------------
        require 'Sketchup'
        #
        unless file_loaded?(__FILE__)
        	UI.menu("Plugins").add_item("Add Circles") { Sketchup.active_model.select_tool Bardlind;;Add_Circles.new }
        	file_loaded(__FILE__)
        end
        #
        module Bardlind
        
        	class Add_Circles
        
        		def initialize
        			@mod=Sketchup.active_model
        			@ent=@mod.active_entities
        			@sel=@mod.selection
        			@ip=Sketchup;;InputPoint.new
        			@status_text = "Pick End Point"
        		end
        		
        		def onMouseMove(flags, x, y, view)
        			@ip.pick view,x,y; view.tooltip = @ip.tooltip; view.refresh
        			Sketchup;;set_status_text @status_text,SB_PROMPT
        			Sketchup;;set_status_text "", SB_VCB_LABEL
        			Sketchup;;set_status_text "", SB_VCB_VALUE
        		end
        		
        		def onLButtonDown(flags, x, y, view)
        			if @ip.vertex
        				@rad1 ||= 10; @rad2 ||= 20; @sides ||= 24
        				values = UI.inputbox(["Radius1;","Radius2;","No. Sides;"],[@rad1,@rad2,@sides],"Add Circles")
        				if values
        					@rad1,@rad2,@sides=values
        					@mod.start_operation "Add Circles"
        					@ent.add_circle(@ip.position,Z_AXIS,@rad1,@sides)
        					@ent.add_circle(@ip.position,Z_AXIS,@rad2,@sides)
        					@mod.commit_operation
        				else
        					onCancel(flags,view)
        				end
        			else
        				UI.beep
        			end
        		end
        		
        		def onCancel(flags,view)
        			Sketchup.send_action "selectSelectionTool;"
        		end
        		 
        		def draw(view)
        			if( @ip.valid? && @ip.display? )
        				@ip.draw(view)
        			end
        		end
        		
        	end
        	
        end
        
        

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • B Offline
          bardlind
          last edited by

          Thanks alot! I will give it a try.

          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