sketchucation logo sketchucation
    • Login
    1. Home
    2. pingpink
    3. Posts
    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!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 16
    • Posts 56
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Face-tag number

      Thank you kindly for your recommendation , it's my task to do facade modeling. I'm revising codes in each module now to make it better.

      I'm curious that Is there a way to do a code for copying different coloured panels and lay down on a base in the program ? For example , in a picture there are 2 different panels and I want to copy out. So, it can reduce a time of copying faces to draw patterns and convert to components, and then do mapping prototype panels back onto faces.


      Copy different panels to make a component later.

      posted in Developers' Forum
      pingpinkP
      pingpink
    • Face-tag number

      Hi,
      I'm working on face-tag number of similar faces to tag the same number on normal faces and change colours to see the different panel types , could anyone give me some ideas how to do this method as you can see in a picture ? I'm not quite good at programming. I have to do this before doing component mapping on faces.


      Tag Number on faces

      posted in Developers' Forum
      pingpinkP
      pingpink
    • RE: Drop-Down List Options

      Thank you very much ,Jolran !!! I've tested the codes. There is still having an error about variable of 'xrotation'. I will try all my effort to solve the codes to link my component's folder which I've created 1 meter upright at the axis (0,0,0). This is my first plugin to do from the user's requirement. You are the first person who understand my project and give me an advice in here. I am much appreciated your ideas !. I can bring to sketch my flowcharts. If I can do the codes, I will inform you later. The big task of coding is waiting for me.I'm fighting 💚

      posted in Developers' Forum
      pingpinkP
      pingpink
    • RE: Drop-Down List Options

      Hi , Jolran

       Patterned Model Data-edges and faces , the users have to create and draw by SU.
       
       I agree with you now. This idea is complicated to do.
      
       And when I read you idea , I can picture about it. Thus , I try to test for a square face I want the width to be transom(horizontal) , and the height to be mullion(vertical). That I can load the each type of components on face.bounds.
      
       I did a code from your suggestions by steps. 
      
       1. Find face.bounds dimensions - Width and Height
       2. Conditions before doing load component
       3. Rotate origin Axis at the start position
       4. Scaling length
      
       I'm not sure how to compare in conditions
      

      for loading components around a face.I have a basic of programming.I have been trying to load " Face.load_comp " in a ruby console but it has an error.

       Thanks for recommending about WYSIWYG editor , I will gradually look about it. I use a free code editor of NotePad ++. 
      

      TYPE IN A CONSOLE

      Face.load_comp

      require 'sketchup.rb'
      
      module Face
      
      	def self.load_comp
      	
      	        $stdout.write("START-FUNC; Face.load_comp();\n") 
      				mod = Sketchup.active_model 
      				sel = mod.selection 
      				ents = mod.active_entities 
      			# Grab all the selected faces. 
      				faces = sel.each{|e| e.typename=='Face'} 
      			if faces == 0; 
      				UI.messagebox("Must select at least one face!") 
                  return 
              end 
              $stdout.write(" FOR-EACH(face);\n") 
              faces.each do |face| 
                  $stdout.write("  #{face}\n")
      
      			    face = face.bounds
      				puts "Transom = #{face.width.inspect}"
      				puts "Mullion = #{face.depth.inspect}"
      
      		end
      
      #=begin		
      		if 	puts "Transom = #{face.width.inspect}" # for the width , top and buttom
      	
      			path = Sketchup.find_support_file "CurtainWall_Architect/Components/00_No_Cap/C-50/Transom/T50X193.2_No-Cap.skp", "Plugins"
      			#path = File.join(File.dirname(__FILE__), "CurtainWall_Architect/Components/00_No_Cap/C-50/Mullion/T50X193.2_No-Cap.skp") #No need to dig into C;
      				
      			mydefinition = Sketchup.active_model.definitions.load(path)
      			gp = Sketchup.active_model.entities.add_group() # Container group. Not a must..
      			#tr = Geom;;Transformation.new(ORIGIN, user_face.normal) #face selected by user
      
      			inst = gp.entities.add_instance(mydefinition, tr)
      	
      			scalefactorW = face.bounds.width/inst.bounds.width #(simplified, needs some laboring)
      			
      			tr = Geom;;Transformation.new(ORIGIN,face.normal) #face selected by user
      
      			tr = tr*Geom;;Transformation.rotation(ORIGIN, X_AXIS, self.xrotation)
      
      			position = entity.transformation.to_a
      		
      			pt = edge.start.position
      
      			tr = Geom;;Transformation.scaling pt, 1.0, 1.0, xscale
      
      			entity.transform!( tr )
      			# invalidate the view to see the move action
      			#Sketchup.active_model.active_view.invalidate
      			
      			inst.invalidate_bounds
      			
      		else puts "Mullion = #{face.depth.inspect}"# for the height of left and right sides
      		
      			path = Sketchup.find_support_file "CurtainWall_Architect/Components/00_No_Cap/C-50/Mullion/M50X230.5_No-Cap.skp", "Plugins"
      			#path = File.join(File.dirname(__FILE__), "CurtainWall_Architect/Components/00_No_Cap/C-50/Mullion/M50X230.5_No-Cap.skp") #No need to dig into C;
      				
      			mydefinition = Sketchup.active_model.definitions.load(path)
      			gp = Sketchup.active_model.entities.add_group() # Container group. Not a must..
      			#tr = Geom;;Transformation.new(ORIGIN, user_face.normal) #face selected by user
      
      			inst = gp.entities.add_instance(mydefinition, tr)
      	
      			scalefactorD = face.bounds.depth/inst.bounds.depth #(simplified, needs some laboring)
      	
      			tr = Geom;;Transformation.new(ORIGIN,face.normal) #face selected by user
      
      			tr = tr*Geom;;Transformation.rotation(ORIGIN, Z_AXIS, self.zrotation)
      		
      			position = entity.transformation.to_a
      
      			pt = edge.start.position
      
      			tr = Geom;;Transformation.scaling pt, 1.0, 1.0, zscale
      	
      		
      			entity.transform!( tr )
      			# invalidate the view to see the move action
      			# Sketchup.active_model.active_view.invalidate
      			
      			inst.invalidate_bounds
      
      			end 
      			
      	return Geom;;Transformation.new(tr)
      #=end
      
              $stdout.write("END-FUNC; load_comp\n")
          end # def
      
      end # module
      
      posted in Developers' Forum
      pingpinkP
      pingpink
    • RE: Drop-Down List Options

      Thanks ! I should tell you about the background of this project.

      I'm an architect , and designing a plugin which studied from the process of architects and facade designers.

      This plugin is for architect's use when doing a schematic design , so we must have to redesign until clients like , then submit 3D model to the facade designers to do material take-off. Thus , we have to do 3D modeling as a real name of component's structure - The mullion and transom with designer's options to have no-cap or cap's features from the lists.
      I studied from aluminium catalogs from many companies , and summarized that the plugin can contained these kinds of aluminium's style.I created lots of components for the mullion and transom in 1 meter high , saved in a component's file , but I can't share because it's a big file.

      In Curtain Wall Modeling is the main part that I'm thinking what procedure should I do.
      I want the process to be :

      1. Architect provides " Patterned Model data - edges and faces "

      2. The webdialog have to be defined and then convert pattern faces into 3D model which load components- mullion and transom from my data. But , in the theory , the mullion ( vertical ) can have 90 degrees or random degrees of edge , and the transom ( horizontal ) is 0 degree of edge. I'm still finding the way to solve for many months.I can't find the solution for now. The code is "Place-Face.rb" in a "rb/02_Profile".

        OR Do I have to select edges manually by users and decide which ones should be mullions or transoms ?. Then the program will load from the selection edges. And apply colors for components and faces later ?.

        The webdialog now is a test , suppose I created components for aluminium frames and faces for glasses. I choose only 2 selections for now , but it change the color sometimes component's color , and sometimes face's colors , linking from Def- "rb/02_Profile/AluColor" and "rb/01_Glass/GlassColor". If a plugin can change the color in one time , it would be nice.

        The HTML created with Dreamweaver , I do graphic design and code in it.
        I just know from you about WYSIWYG editor,never used it before.
        The Visual studio , I learnt in the past for a basic programming in C#.

      posted in Developers' Forum
      pingpinkP
      pingpink
    • RE: Drop-Down List Options

      ApplyTo.new.getDef , There's no problem since It is called the Class and function from outside file. About the hash , it's very interesting. I will try it later.

      My Icon buttons on the Toolbar can launch the WebDialogs when click them.
      
      Correct , myprogram_arch() is the WebDialog.
      
      But , now I've got some issues for selecting 2 options of component's color (frame colors) , and a face's color (glass colors). I test the webdialog , I want to select 2 options in one time , but it changes only component's color. If I want to change face color , I have to reset the frame colors to be -No-. 
      
      How can I set the Values ?
      
       
      
      		#==========================#
      		#     Value Variables	   #
      		#==========================#
      		
      		my_value = web_dialog.get_element_value("SchemeLayer")
      		
      		frame_color_value = web_dialog.get_element_value("Frame_Colors")
      		
      		glass_color_value = web_dialog.get_element_value("Glass_Colors")
      		
      		#==========================#
      		#   Add Layers of Schemes  #
      		#==========================#
      
      		
      		if my_value == "Scheme_A" && action_name=="Select"
      		create_scheme_A 
      		UI.messagebox "Layers created for Scheme-A...?", MB_YESNO
      		UI.play_sound "Plugins/CA/sound/fins__button.wav"
      		
      		elsif my_value == "Scheme_B" && action_name=="Select"
      		create_scheme_B 
      		UI.messagebox "Layers created for Scheme-B...?", MB_YESNO
      		UI.play_sound "Plugins/CA/sound/fins__button.wav"
      		
      		elsif my_value == "Scheme_C" && action_name=="Select"
      		create_scheme_C 
      		UI.messagebox "Layers created for Scheme-C...?", MB_YESNO
      		UI.play_sound "Plugins/CA/sound/fins__button.wav"
      		
      		#==========================#
      		#      3D Modeling         #
      		#==========================#
      		
      		#  Aluminium Color Selections	
      		
      		elsif frame_color_value == "Clear" && action_name=="Create"
      		al_Light_Satin
      		
      		#  Glass Color Selections	  
      
      		elsif glass_color_value == "Clear" && action_name=="Create"
      		clear
             
      
      
          
      
      

      options.jpg


      Comp.jpg

      posted in Developers' Forum
      pingpinkP
      pingpink
    • RE: Drop-Down List Options

      Thank you so much for guiding me , Jolran ! I'm not specialized in Ruby. I try to learn.

      Yes , ApplyTo is a class linking from other codes.

      I used $globals because I studied the example from a keycuts_popper.rb

      After reading your explanations , I thought about before codes.I had to change $globals name every time due to its conflict and when I click my other Icon on a toolbar to open a web dialog , it doesn't run. Now I come back to change @instance instead of $globals as you said.It's true.

      @html_path = Sketchup.find_support_file "CA_Architect/html/index_Architectural.html", "Plugins"
      @my_dialog = nil
      
      def self.show_hide_program() # << This is a method not to show a webdialog when open a program every time.
      
      	if @my_dialog&&@my_dialog.visible?
      		@my_dialog.close()
      		 @my_dialog = nil
      	else
      		@my_dialog = myprogram_arch()
      	end
      end
      

      In my html , I pasted the reference code on the top :

        /*send action to sketchup ruby*/
        function callRuby(actionName) {
                 query = 'skp;get_data@' + actionName;
                 window.location.href = query;
        }
        /*get action from sketchup ruby*/
        function passFromRubyToJavascript1(value) {
             var message = "You have " + value + " items selected.";
             document.getElementById('output').innerHTML = message;
        }
      /* 
      

      On the "Select" button , I have onclick event. It's link to the above reference code :

      <input type="button" onclick="callRuby('Select')" value="Select" />
      
      posted in Developers' Forum
      pingpinkP
      pingpink
    • RE: Drop-Down List Options

      Thank you very much Jolran , You are very nice guy ! I learnt from you.
      This is one part of a web dialog.
      After reading your suggestions , I revised my code and added a button 'Select' besides
      a drop-down list. Now it works very okay.

      The process :

      1. Select model entities
      2. Select Scheme option
      3. Click Button " Select "
        Then the model entities will be classified for the Scheme Layers.
      require 'sketchup.rb'
      
      load 'CA/rb/00_Scheme/Create-Layers.rb'
      load 'CA/rb/00_Scheme/Design-Change.rb'
      
      module Architectural
      
      def self.read_data1(web_dialog)
          js_command = "Shell('send from ruby')"
          web_dialog.execute_script(js_command)
      end
      
      
      $html_patharch = Sketchup.find_support_file "CA/html/index_Architectural.html", "Plugins"
      $my_dialogarch = nil
      
      def self.show_hide_program() # << This is a method not to show a web dialog when open a program every time.
      
      	if $my_dialogarch&&$my_dialogarch.visible?
      		$my_dialogarch.close()
      		 $my_dialogarch= nil
      	else
      		$my_dialogarch = myprogram_arch()
      	end
      end
      
      
      def self.myprogram_arch()
      
      my_caption = "CA;Main Program"
      
      wdarch = UI;;WebDialog.new(my_caption, false, my_caption, 200, 200, 200, 200, true)
      
      wdarch.add_action_callback('get_data') do | web_dialog,action_name |  
      
      		#==========================#
      		#   Add Layers of Schemes  #
      		#==========================#
      		
      		
      		my_value = web_dialog.get_element_value("SchemeLayer")
      		if my_value == "Scheme_A" && action_name=="Select"
      		create_scheme_A 
      		UI.messagebox "Layers created for Scheme-A..." 
      		
      		elsif my_value == "Scheme_B" && action_name=="Select"
      		create_scheme_B 
      		UI.messagebox "Layers created for Scheme-B..." 
      		
      		elsif my_value == "Scheme_C" && action_name=="Select"
      		create_scheme_C 
      		UI.messagebox "Layers created for Scheme-C..."
      
      		#==========================#
      		#   Design Change          #
      		#==========================#
      
      		elsif  action_name=="set"
      			ApplyTo.new.getDef 
      		
      
      			
      		else   action_name=="get"
      			ApplyTo.new.applyDef 
      		
      	
      		end
      
      end
         
      wdarch.set_file($html_patharch)
      wdarch.show()#####################################
      
      return wdarch
      end
      
      # Add things to the Plugins menu
      
      unless file_loaded?( "CA_MainProgram.rb" )
      	UI.menu( "Plugins" ).add_item( "CA_Main" ) { Architectural;;myprogram_arch()}
      	file_loaded( "CA_MainProgram.rb" )
      end
      
      end # module
      
      

      layers.jpg


      Scheme.jpg

      posted in Developers' Forum
      pingpinkP
      pingpink
    • Drop-Down List Options

      Hi everyone ,

       I'm designing a web dialog which contains a drop-down list for creating each layer depending on scheme options. First of all , a user has to select model then pick one of options , and it will put a model into 3 layers. I did this function already and load the def name outside a main program. But I don't understand about how to send data from ruby to html. How can I link option value ?
      
       Many thanks !
      
       Here is in html
      
           Scheme ; 
                    <select name="SchemeLayer" id="SchemeLayer">
                    <option value="No_Scheme">-No-</option>
                    <option value="Scheme_A" >Scheme-A</option> 
                    <option value="Scheme_B">Scheme-B</option>
                    <option value="Scheme_C">Scheme-C</option>
                     
                  </select>
      
       This is in a ruby file 
      
      def myprogram_arch()
      
      my_caption = "CA;Main Program"
      
      wdarch = UI;;WebDialog.new(my_caption, false, my_caption, 200, 200, 200, 200, true)
      
      
      wdarch.add_action_callback('get_data') do | web_dialogarch,action_name |  
      
      
      		#==========================#
      		#   Add Layers of Schemes  #
      		#==========================#
      	
      		if  value = web_dialogarch.get_element_value("SchemeLayer")
      		
      	             puts create_scheme_A # Def function is called outside from an external file.
      		  
      		end
      		   UI.messagebox "Layer created..."
      end
         
      wdarch.set_file($html_patharch)
      wdarch.show()#####################################
      
      return wdarch
      end
      

      A5 copy.jpg

      posted in Developers' Forum
      pingpinkP
      pingpink
    • RE: How to distinguish face size

      Thank you very much !

      Actually , I refer "round_to" in a class Fixnum below my main codes. I don't see any error.

      It's my new knowledge about sprintf("%.2f", 1.23456)

      [ruby]class Fixnum
        def abs
          rx = self
      	if rx < 0
      	  rx = -rx
      	end 
          return rx
        end
        
        def to_meter
          ufactor = 1.m
      	rx = (self) / ufactor
      	return rx
        end
        
        def round_to(x)
          (self * 10**x).round.to_f / 10**x
        end
      
        def ceil_to(x)
          (self * 10**x).ceil.to_f / 10**x
        end
      
        def floor_to(x)
          (self * 10**x).floor.to_f / 10**x
        end
        def rad_to_deg
          (self / Math;;PI) * 180.0 
        end
        
        def deg_to_rad
          (self * Math;;PI) / 180.0 
        end
        
        def comma_format
          s = self.to_s
          if s.include? ?.
              pre, post = s.split '.'
              "#{pre.reverse.gsub( /\d{3}(?=\d)/, '\&,' ).reverse}.#{post}"
          else
              s.reverse.gsub( /\d{3}(?=\d)/, '\&,' ).reverse
          end
        end  
      end
      

      [/ruby][/code]

      posted in Developers' Forum
      pingpinkP
      pingpink
    • RE: How to distinguish face size

      Thank you kindly jolran and TIG.

      @jolran , I always use round_to and it can run on SU 7,8.
      Do I have to change to be ' float ' ?
      I'm not expert in ruby.

      @TIG , I will study about the export which you suggested to me.

      I don't know how to do automatic part-numbers meanwhile changing each colored faces separately , then report sizes , pieces ,and area.

      I'm trying to figure it out.

      😄

      posted in Developers' Forum
      pingpinkP
      pingpink
    • How to distinguish face size

      Hi , I have some questions.

      I'm trying to distinguish face sizes with the part-number by using set_attribute( Generate part number and displaying colored faces) , and get_attribute ( Export in Excel ). But , I can't make same face size area to have same color , and count the pieces.

      What should I revise to make it works?

      Thanks so much

      <span class="syntaxdefault">def set_attribute<br /><br />    model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br />    model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_operation</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'Colour by same area and dimensions'</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    entities </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br />    face</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault">    face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">set_attribute</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Attribute"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"Glass"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">true</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    colors </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Color</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">names    <br />        attribute_name </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> colors</span><span class="syntaxkeyword">[</span><span class="syntaxdefault"> rand</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> colors</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">1 </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault">        m </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">materials</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> attribute_name </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">        m</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">color </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> attribute_name<br />        model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">          next unless e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">is_a</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Face</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">          e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">material </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> m<br />         <br />        </span><span class="syntaxkeyword">}</span><span class="syntaxdefault">    <br />          <br /></span><span class="syntaxcomment">### this gives the face your-attribute called Glass that is true<br /></span><span class="syntaxdefault">end<br /><br />def get_attribute<br /><br />    model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br />    entities </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br />    face</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault">    context </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_attribute</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"Attribute"</span><span class="syntaxkeyword">,</span><span class="syntaxstring">"Glass"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    if context<br />      </span><span class="syntaxcomment">#===============#<br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment">#  PART-NUMBER  # GL-01 , GL-02 , GL-03 , ....<br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment">#===============#<br /></span><span class="syntaxdefault">        puts </span><span class="syntaxstring">"GL-01"<br /></span><span class="syntaxdefault">        <br />      </span><span class="syntaxcomment">#===============#<br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment">#  DIMENSIONS   # <br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment">#===============#      <br /></span><span class="syntaxdefault">      <br />        glas </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">bounds<br />        puts </span><span class="syntaxstring">"Width ; #{(glas.width*(0.0254)).to_f.round_to(2).to_s }"</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> </span><span class="syntaxstring">" m"<br /></span><span class="syntaxdefault">        puts </span><span class="syntaxstring">"Height ; #{(glas.depth*(0.0254)).to_f.round_to(2).to_s }"</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> </span><span class="syntaxstring">" m"<br /></span><span class="syntaxdefault">        <br />      </span><span class="syntaxcomment">#===============#<br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment">#   QUANTITY    # <br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment">#===============#<br /></span><span class="syntaxdefault">  <br />        num</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">0<br />        ss</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection<br />            if ss</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault">                ents</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">ss</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_a<br />            else<br />                ents</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_a<br />            end</span><span class="syntaxcomment">#if<br /></span><span class="syntaxdefault">        defs</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">definitions<br />        ents</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">|</span><span class="syntaxdefault">num</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">num</span><span class="syntaxkeyword">+(</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">)</span><span class="syntaxdefault">if e</span><span class="syntaxkeyword">.class==</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Face</span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        defs</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">d</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">        d</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">        n</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">d</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">instances</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length<br />        num</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">num</span><span class="syntaxkeyword">+(</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">*</span><span class="syntaxdefault">n</span><span class="syntaxkeyword">)</span><span class="syntaxdefault">if e</span><span class="syntaxkeyword">.class==</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Face<br />            </span><span class="syntaxkeyword">}</span><span class="syntaxdefault">    <br />        </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">        puts </span><span class="syntaxstring">"Quantity ; #{num}"</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> </span><span class="syntaxstring">"  Pcs"<br /></span><span class="syntaxdefault">                <br />      </span><span class="syntaxcomment">#===============#<br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment">#     AREA       # <br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment">#===============#<br /></span><span class="syntaxdefault">      <br />        area </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">area</span><span class="syntaxkeyword">*(</span><span class="syntaxdefault">0.00694444444</span><span class="syntaxkeyword">)).</span><span class="syntaxdefault">to_f</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">round_to</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">to_s <br />     <br />        </span><span class="syntaxcomment">#area = (face.area /(1.m*1.m)).to_f.round_to(2).to_s + " SQ.M"<br /><br /></span><span class="syntaxdefault">        puts </span><span class="syntaxstring">"Area ; #{area}"</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">+</span><span class="syntaxdefault"> </span><span class="syntaxstring">" SQ.Ft"<br /></span><span class="syntaxdefault">       <br />     else<br />        puts </span><span class="syntaxstring">"This glass does not have Part-Number"<br /></span><span class="syntaxdefault">     end</span><span class="syntaxcomment">#if<br /></span><span class="syntaxdefault">     <br />  </span><span class="syntaxcomment">#return num<br /></span><span class="syntaxdefault">     </span><span class="syntaxcomment">#===============#<br /></span><span class="syntaxdefault">     </span><span class="syntaxcomment"># Export  Excel # <br /></span><span class="syntaxdefault">     </span><span class="syntaxcomment">#===============#     <br /></span><span class="syntaxkeyword">=</span><span class="syntaxdefault">begin         <br />    out_name </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"#{File.basename(model.path).split("</span><span class="syntaxkeyword">.</span><span class="syntaxstring">")[0]}"</span><span class="syntaxdefault"> <br />    if out_name </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> </span><span class="syntaxstring">''</span><span class="syntaxdefault"> then out_name </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Report'</span><span class="syntaxdefault"> <br />    out_name </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"#{out_name}_faceareas.xlsx"</span><span class="syntaxdefault"> <br /><br /><br />    unless </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">out_name </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">savepanel</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">"Where shall I save the output?"</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"."</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> out_name </span><span class="syntaxkeyword">)).</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">?</span><span class="syntaxdefault"> then <br /><br /> <br />        area_file </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> out_name </span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"w+"</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br /><br /> <br />        if area_file</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">nil</span><span class="syntaxkeyword">?</span><span class="syntaxdefault"> then <br />            UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">messagebox</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">'File error!'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br />            return <br />        end <br /><br /><br />        face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each do </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">f</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> <br />            area_file</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">puts</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxstring">"#{f.area}"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br />            <br />        end <br />    else <br />        User aborted <br />    end <br /><br />    area_file</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">close <br />end <br /></span><span class="syntaxkeyword">=</span><span class="syntaxdefault">end<br />end</span>
      

      Attribute_Set.jpg

      posted in Developers' Forum
      pingpinkP
      pingpink
    • RE: Question : Select edges depends on degrees

      Here is my piktogramm to determine the degrees of edges on selected surfaces.
      I would like to select only edges following to the condition of structure.
      Mullion is random degree except 180 degrees , and transom is only 180 degrees.

      Thank you kindly


      The Idea of degree

      posted in Newbie Forum
      pingpinkP
      pingpink
    • Question : Select edges depends on degrees

      Hi ,

      Is there a way to " select edges on surface which depends on specific degrees " ,eg. Vertical structure is 360 degrees except 0 degree and Horizontal structure is only 0 degree.
      After that , I can use the specific components to run along edges.

      Thanks

      posted in Newbie Forum sketchup
      pingpinkP
      pingpink
    • Do a report text file of Spec

      Hi ,

      I'm curious that Is there a method to calculate specific components by using model.definitions linked to a text file in the specification :

      CW50X41.5 | 1.264 | kg/m | #
      CW50X62.5 | 1.311 |kg/m |#
      CW50X83.5 |1.450 |kg/m |#

      then report the summary text file of -- name , quantity , length , kg/m --- Thereby , it can be used for further cost estimation.

      posted in Developers' Forum
      pingpinkP
      pingpink
    • Question-How to link model components and generate on edges

      I'm trying to write a ruby code to generate a component of Aluminium Profiles
      which there are many types. My idea is undertaking to link the provided components
      to run on edges and make a group of each component , then apply the material automatically.But,I can't find the method to do it. I would be very thoughtful to receive the suggestion.

      Below is the code that do not know how to revise it.

      RectangularFrame_location = Sketchup.active_model.definitions.load("C:\rec.skp")
      transform = Geom::Transformation.new RectangularFrame_location
      entities = Sketchup.active_model.active_entities
      instance = entities.add_instance RectangularFrame_location, transform


      Program Idea

      posted in Developers' Forum
      pingpinkP
      pingpink
    • 1 / 1