sketchucation logo sketchucation
    • Login
    1. Home
    2. blue_orchid
    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!
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download
    B
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 25
    • Groups 1

    blue_orchid

    @blue_orchid

    10
    Reputation
    1
    Profile views
    25
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    blue_orchid Unfollow Follow
    registered-users

    Latest posts made by blue_orchid

    • RE: Display image using Ruby API

      Ya, WebDialog is also fine.

      posted in Developers' Forum
      B
      blue_orchid
    • RE: Display image using Ruby API

      "Directory" means just the folder in your computer.

      What I wanted to do: On clicking dynamic component, image should pop up.

      posted in Developers' Forum
      B
      blue_orchid
    • RE: Display image using Ruby API

      What I wanted to do is display an image after I click the object.

      posted in Developers' Forum
      B
      blue_orchid
    • Display image using Ruby API

      Can anyone tell me how to display an image which is located in other directory using Ruby API in SketchUP?

      posted in Developers' Forum
      B
      blue_orchid
    • Remove color using ruby

      how to remove the material (color) from object using ruby?

      posted in SketchUp Components sketchup
      B
      blue_orchid
    • RE: Color the DC conditioning on its attributes & values (MYSQL

      This code finally worked πŸ˜„

      UI.menu("Plugins").add_item('Assesment') { Inspection.color }
      
      require 'mysql'
      
      module Inspection
          def self.color
      		dbh = Mysql.real_connect("localhost", "root", "***", "test",3306)
      		dbh.query("drop table if exists inspection")
      		dbh.query("create table inspection(component varchar(20), ID int(4), rating int(1))")
      		dbh.query("insert into inspection values('deck',2345,2),('Substructure',2349,1),('Superstructure',2353,3)")
      
      		res = dbh.query("SELECT rating FROM inspection where id = '2345'")
      		while row = res.fetch_row do
      		xx = row[0]
      		printf "%s\n", xx
      		end
      
      		res1 = dbh.query("SELECT rating FROM inspection where id = '2349'")
      		while row = res1.fetch_row do
      		xy = row[0]
      		printf "%s\n", xy
      		end
      
      		res2 = dbh.query("SELECT rating FROM inspection where id = '2353'")
      		while row = res2.fetch_row do
      		yy = row[0]
      		printf "%s\n", yy
      		end
      
      
      
      		Sketchup.active_model.entities.to_a.each{|e|
      			if e.get_attribute('dynamic_attributes','id','')=='2345'&& xx=='1'
      			e.set_attribute('dynamic_attributes','rating','1')
      			elsif e.get_attribute('dynamic_attributes','id','')=='2345'&& xx=='2'
      			e.set_attribute('dynamic_attributes','rating','2')
      			elsif e.get_attribute('dynamic_attributes','id','')=='2345'&& xx=='3'
      			e.set_attribute('dynamic_attributes','rating','3')
      		end
      		}
      		Sketchup.active_model.entities.to_a.each{|e|
      			if e.get_attribute('dynamic_attributes','id','')=='2349'&& xy=='1'
      			e.set_attribute('dynamic_attributes','rating','1')
      			elsif e.get_attribute('dynamic_attributes','id','')=='2349'&& xy=='2'
      			e.set_attribute('dynamic_attributes','rating','2')
      			elsif e.get_attribute('dynamic_attributes','id','')=='2349'&& xy=='3'
      			e.set_attribute('dynamic_attributes','rating','3')
      		end
      		}
      		Sketchup.active_model.entities.to_a.each{|e|
      			if e.get_attribute('dynamic_attributes','id','')=='2353'&& yy=='1'
      			e.set_attribute('dynamic_attributes','rating','1')
      			elsif e.get_attribute('dynamic_attributes','id','')=='2353'&& yy=='2'
      			e.set_attribute('dynamic_attributes','rating','2')
      			elsif e.get_attribute('dynamic_attributes','id','')=='2353'&& yy=='3'
      			e.set_attribute('dynamic_attributes','rating','3')
      		end
      		}
      		Sketchup.active_model.entities.to_a.each{|e|
      			if e.get_attribute('dynamic_attributes','rating','')=='1'
      			e.set_attribute( 'dynamic_attributes', 'material', 'black')
      			e.set_attribute( 'dynamic_attributes', '_material_formula', '"black"')
      			$dc_observers.get_latest_class.redraw_with_undo(e)
      			elsif e.get_attribute('dynamic_attributes','rating','')=='2'
      			e.set_attribute( 'dynamic_attributes', 'material', 'blue')
      			e.set_attribute( 'dynamic_attributes', '_material_formula', '"blue"')
      			$dc_observers.get_latest_class.redraw_with_undo(e)
      			elsif e.get_attribute('dynamic_attributes','rating','')=='3'
      			e.set_attribute( 'dynamic_attributes', 'material', 'red')
      			e.set_attribute( 'dynamic_attributes', '_material_formula', '"red"')
      			$dc_observers.get_latest_class.redraw_with_undo(e)
      		end
      		}
      	end
      end
      

      Thanks to all.

      posted in Developers' Forum
      B
      blue_orchid
    • RE: Color the DC conditioning on its attributes & values (MYSQL
      UI.menu("Plugins").add_item('Assesment') { Jeny.color }
      require 'mysql'
      module Jeny
          def self.color
      dbh = Mysql.real_connect("localhost", "root", "orange", "test",3306)
      dbh.query("drop table if exists inspection")
      dbh.query("create table inspection(component varchar(20), ID int(4), rating int(1))")
      dbh.query("insert into inspection values('deck',2345,1),('Substructure',2349,2),('Superstructure',2353,3)")
      
      #printf "%d rows were inserted\n",dbh.affected_rows
      #res = dbh.query("SELECT rating, id FROM inspection")
      res = dbh.query("SELECT rating FROM inspection where id = '2345'")
      while row = res.fetch_row do
      xx = row[0]
      printf "%s\n", xx
      end
      
      res1 = dbh.query("SELECT rating FROM inspection where id = '2349'")
      while row = res1.fetch_row do
      xy = row[0]
      printf "%s\n", xy
      end
      
      res2 = dbh.query("SELECT rating FROM inspection where id = '2353'")
      while row = res2.fetch_row do
      yy = row[0]
      printf "%s\n", yy
      end
      
      Sketchup.active_model.entities.to_a.each{|e|
      if e.get_attribute('dynamic_attributes','id','2345')
      e.set_attribute('dynamic_attributes','rating','xx')
         end
      }
      Sketchup.active_model.entities.to_a.each{|e|
      if e.get_attribute('dynamic_attributes','id','')== "2349"
      e.set_attribute('dynamic_attributes','rating','xy')
      end
      }
      Sketchup.active_model.entities.to_a.each{|e|
      if e.get_attribute('dynamic_attributes','id','') == "2353"
      e.set_attribute('dynamic_attributes','rating','yy')
      end
      }
      
      Sketchup.active_model.entities.to_a.each{|e|
      if e.get_attribute('dynamic_attributes','id','2345') && xx == "1"
           e.set_attribute( 'dynamic_attributes', 'material', 'red')
           e.set_attribute( 'dynamic_attributes', '_material_formula', '"red"')
           $dc_observers.get_latest_class.redraw_with_undo(e)
      elsif e.get_attribute('dynamic_attributes','id','2345') && xx == "2"
           e.set_attribute( 'dynamic_attributes', 'material', 'blue')
           e.set_attribute( 'dynamic_attributes', '_material_formula', '"blue"')
           $dc_observers.get_latest_class.redraw_with_undo(e)
      elsif e.get_attribute('dynamic_attributes','id','2349') && xx == "3"
           e.set_attribute( 'dynamic_attributes', 'material', 'green')
           e.set_attribute( 'dynamic_attributes', '_material_formula', '"green"')
           $dc_observers.get_latest_class.redraw_with_undo(e)
           end
           }
      
      Sketchup.active_model.entities.to_a.each{|e|
      if e.get_attribute('dynamic_attributes','id','2349') && xy == "1"
           e.set_attribute( 'dynamic_attributes', 'material', 'red')
           e.set_attribute( 'dynamic_attributes', '_material_formula', '"red"')
           $dc_observers.get_latest_class.redraw_with_undo(e)
      elsif e.get_attribute('dynamic_attributes','id','2349') && xy == "2"
           e.set_attribute( 'dynamic_attributes', 'material', 'blue')
           e.set_attribute( 'dynamic_attributes', '_material_formula', '"blue"')
           $dc_observers.get_latest_class.redraw_with_undo(e)
      elsif e.get_attribute('dynamic_attributes','id','2349') && xy == "3"
           e.set_attribute( 'dynamic_attributes', 'material', 'green')
           e.set_attribute( 'dynamic_attributes', '_material_formula', '"green"')
           $dc_observers.get_latest_class.redraw_with_undo(e)
      end
           }
      
      Sketchup.active_model.entities.to_a.each{|e|
      if e.get_attribute('dynamic_attributes','id','2353') && yy == "1"
           e.set_attribute( 'dynamic_attributes', 'material', 'red')
           e.set_attribute( 'dynamic_attributes', '_material_formula', '"red"')
           $dc_observers.get_latest_class.redraw_with_undo(e)
      elsif e.get_attribute('dynamic_attributes','id','2353') && yy == "2"
           e.set_attribute( 'dynamic_attributes', 'material', 'blue')
           e.set_attribute( 'dynamic_attributes', '_material_formula', '"blue"')
           $dc_observers.get_latest_class.redraw_with_undo(e)
      elsif e.get_attribute('dynamic_attributes','id','2353') && yy == "3"
           e.set_attribute( 'dynamic_attributes', 'material', 'green')
           e.set_attribute( 'dynamic_attributes', '_material_formula', '"green"')
           $dc_observers.get_latest_class.redraw_with_undo(e)
                      end
                  }
       
      
      end
      end
      
      
      

      %(#BF4000)[What I did here:
      I set attribute 'rating' for different objects with different names like xx, xy and yy.
      Then I made these attributes 'ratings' equal to result from query for each component/object.
      Finally i selected the color for each component and different values of ratings a color.

      But it still selects only last code i.e. objects color change to green . May be it could not identify the Db values.]
      Now what i want to do that if the rating for a component is 1 in database, then the attribute 'rating' for that component is changed to 1 using DB value. Is it possible?

      posted in Developers' Forum
      B
      blue_orchid
    • RE: Color the DC conditioning on its attributes & values (MYSQL

      i am not at all experienced in any programming language and mysql. Ruby is my first programming language. I have gone through several ruby guide, but still i am having hard time learning it and working on it.

      i am just doing it for a project and i am really having a hard time doing it.

      posted in Developers' Forum
      B
      blue_orchid
    • RE: Color the DC conditioning on its attributes & values (MYSQL

      UI.menu("Plugins").add_item('Assessmenteww') { Jeny.color }

      module Jeny
      def self.color
      require 'mysql'
      dbh = Mysql.real_connect("localhost", "root", "orange", "test",3306)

      dbh.query("drop table if exists inspection")
      dbh.query("create table inspection(component varchar(20), ID int(4), rating int(1))")
      dbh.query("insert into inspection values('deck',2345,1),('Substructure',2349,2),('Superstructure',2353,3)")
      #printf "%d rows were inserted\n",dbh.affected_rows

      res = dbh.query("SELECT id, rating FROM inspection")
      #while row = res.fetch_row do

      #a=row[0]
      #b=row[1]
      #c=row[2]

      #printf "%s, %s, %s\n", a, b, c
      #end

      #puts a.inspect
      #puts b.inspect
      #puts c.inspect

      Sketchup.active_model.entities.to_a.each{|e|
      this = e.get_attribute('dynamic_attributes','id','') == "2345"
      case this
      when res == '2345' && '1'
      e.material = 'red'
      when res == '2349' && '2'
      e.material == 'green'
      when res == '3'
      e.material == 'blue'
      when '' # empty
      e.material = 'orange'
      else
      e.material = 'yellow'
      end
      }
      end
      end

      
      

      %(#40BF00)[Sketchup.active_model.entities.to_a.each{|e|
      this = e.get_attribute('dynamic_attributes','id','') == "2345"
      case this
      when res == '2345' && '1'
      e.material = 'red'
      when res == '2349' && '2'
      e.material == 'green'
      when res == '3'
      e.material == 'blue'
      when '' # empty
      e.material = 'orange'
      else
      e.material = 'yellow'
      end
      }]

      When I run this script, the component with id '2345' does not change its color, but the other component changes its color to red. Why is this so?

      posted in Developers' Forum
      B
      blue_orchid
    • RE: Color the DC conditioning on its attributes & values (MYSQL

      Dan, I am sorry that I did not understand your question?

      posted in Developers' Forum
      B
      blue_orchid