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

    Posts

    Recent Best Controversial
    • RE: [Plugin] Import ALL from Folder

      Thanks TIG that worked

      posted in Plugins
      P
      pmagans
    • RE: [Plugin] Import ALL from Folder

      TIG,
      Do you know of any .stl batch importers? I have found two .stl importers but nothing with the batch capabilities.
      Thanks

      posted in Plugins
      P
      pmagans
    • RE: Intersecting Hollow Objects using intersect_with

      Well I've been using the "solid" tools for the last few days and it is a whole lot easier than what I was trying before. It would be nice to find a non-Pro version, for home use. The following is my test_code. I will re-write using Dan's previous post as a guide. It's a little over my head at this moment and I'm still trying to completly understand it.

      module PMA_INT_TEST
      	require('sketchup.rb')
      	
      	l = 1.50
      	w = 1.50
      	t = 0.078
      	h = 20
      
      	model = Sketchup.active_model
      	ents = model.entities
      	
      	#Just test geometry
      	pt1 = [0,0,0]
      	pt2 = [l,0,0]
      	pt3 = [l,w,0]
      	pt4 = [0,w,0]
      	object_group = ents.add_group()
      	object_group.name = "OBJECT GROUP"
      	cpt = object_group.entities.add_cpoint(ORIGIN)
      	face1 = object_group.entities.add_face pt1,pt2,pt3,pt4
      	cpt.erase!
      	pt1 = [0+t,0+t,0]
      	pt2 = [l-t,0+t,0]
      	pt3 = [l-t,w-t,0]
      	pt4 = [0+t,w-t,0]
      	face2 = object_group.entities.add_face pt1,pt2,pt3,pt4
      	face2.erase! 
      	face1.reverse!
      	face1.pushpull h
      	
      	#Creating Test Cutgroup1
      	cut_group1 = ents.add_group()
      	cpt = cut_group1.entities.add_cpoint(ORIGIN)
      
      	pt1 = [0,0,0]
      	pt2 = [l,0,0]
      	pt3 = [l,w,0]
      	pt4 = [0,w,0]
      	face3 = cut_group1.entities.add_face pt1,pt2,pt3,pt4
      	face3.reverse!
      	face3.pushpull h
      	t1 = Geom;;Transformation.translation [0,0,10]
      	ts1 = Geom;;Transformation.scaling [l/2,w/2,0], 10
      	tr1 = Geom;;Transformation.rotation [0, 0, 0], [1, 0, 0], 10.degrees
      	cut_group1.transform! tr1 * t1 * ts1  
      	cut_group1.name = "CUT GROUP1"
      	cpt.erase!
      	
      	#Creating Test Cutgroup2
      	cut_group2 = ents.add_group()
      	cpt = cut_group2.entities.add_cpoint(ORIGIN)
      
      	pt1 = [0,0,0]
      	pt2 = [l,0,0]
      	pt3 = [l,w,0]
      	pt4 = [0,w,0]
      	face4 = cut_group2.entities.add_face pt1,pt2,pt3,pt4
      	face4.pushpull h
      	t2 = Geom;;Transformation.translation [0,0,1]
      	tr2 = Geom;;Transformation.rotation [0, 0, 0], [1, 0, 0], -10.degrees
      	cut_group2.transform! tr2 * t2 * ts1  
      	cut_group2.name = "CUT GROUP2"
      	cpt.erase!
      	
      	#Create "NEW" group from cut group and from object group
      	UI.messagebox("CUTTING")
      	
      	cut_group = cut_group1.subtract(object_group)
      	cut_group = cut_group2.subtract(cut_group)
      	cut_group.name = "NEW NAME"
      
      end #of module PMA_INT_TEST
      
      posted in Developers' Forum
      P
      pmagans
    • RE: Intersecting Hollow Objects using intersect_with

      Thanks TIG. I am still working on this and will post my results.

      On a side note:
      I tried to create a function in the module I wrapped everything in and it won't load in Sketchup but works fine outside of the function block.
      ex.

      module PMA_INT_TEST
       ..code here to create geometry
      end #of module
      

      load PMA_INT_TEST.rb into Sketchup works fine

      then I changed:

      module PMA_INT_TEST
      create_geometry()
      
      def create_geometry()
       exact same..code here to create geometry
      end
      end #of module
      

      load PMA_INT_TEST.rb into Sketchup get:
      Error: #<NoMethodError: undefined method `create_geometry' for PMA_INT_TEST:Module>

      posted in Developers' Forum
      P
      pmagans
    • RE: Help Understanding Classes and Class objects

      @dan rathbun said:

      Bookmark that page.

      Done, thanks for the link.

      I remember doing the tutorials when DC's first came out but have forgotton the majority of what I learned so I guess I will be spending some time there first.

      posted in Developers' Forum
      P
      pmagans
    • RE: Help Understanding Classes and Class objects

      @dan rathbun said:

      But of course the coding means is not documented because the Free license users are not supposed to do it. (... or at least use a wizard interface.)

      That's a bummer. I like the concept of dynamic tools for locking up variables and documenting the components, but I hate the user interface! It would just take me too long through traditional means to create a workable library. And of course if I wanted to change something I would have to do it in multiple places. I will do a more active search for creating/modifying dynamic components through Ruby. So far what I have found has not been that helpful besides holding/setting attributes. Any tips on where to start?
      Thanks!

      posted in Developers' Forum
      P
      pmagans
    • RE: Intersecting Hollow Objects using intersect_with

      Thanks for the plugins, TIG! Those are awesome starting points for me. I will need to modify them so that they work for any plane that is non-orthogonal to the orgin. But I think that's just a matter of creating a "plane" through code and not choosing it like the plugin. Thanks again!

      intersect_with_plane.jpg

      posted in Developers' Forum
      P
      pmagans
    • RE: Intersecting Hollow Objects using intersect_with

      Thanks TIG,
      I will definitely give that a go. I'll have to start up my work computer to give it a try though. I use the "free" version on a mac at home and the Pro windows version on my work laptop.

      Dan your thoughts are exactly where I wanted to go with being able to pick a direction for the cut. I envisioned a future user prompt to pick a side. I still think I could make it look like a plane being cut using TIG's described method by creating the geometry after the pick. But as a tool it would only be usable on a Pro machine it sounds.

      I thought using the array comparisons would be a quick check of the entities created, but actually it didn't work out well because it looks as though Sketchup "redraws" entities like lines and faces when the intersect_with happens even if it's basically the same location. That's why I started down the checking edges, then checking vertices, etc.

      posted in Developers' Forum
      P
      pmagans
    • Intersecting Hollow Objects using intersect_with

      So I am attempting to use planes to cut a hollow object. I am having trouble with the weird conditions such as:
      Plane cutting a line in the object
      intersect.pngintersect2.png

      The array comparisons don't seem to work on faces and entities reliably? any thoughts?
      I did some Array math to help myself out but I think I'm confusing how Sketchup creates entities.

      array1 = [1,2,3,4,5]
      array2 = [1,3,5,6]
      
      array3 = array1 | array2
      array4 = array1 & array2
      array5 = array1 - array2
      array6 = array1 + array2
      array7 = array2 | array1
      array8 = array2 & array1
      array9 = array2 - array1
      array10 = array2 + array1
      array11 = (array1 | array2) - (array1 & array2)
      
      puts "array1 = " + array1.to_s
      puts "array2 = " +array2.to_s
      puts "UNION 1&2 = " +array3.to_s
      puts "INT 1&2 = " +array4.to_s
      puts "Diff 1-2 = " +array5.to_s
      puts "Add 1+2 = " +array6.to_s
      puts "UNION 2&1 = " +array7.to_s
      puts "INT 2&1 = " +array8.to_s
      puts "Diff 2-1 = " +array9.to_s
      puts "Add 2+1 = " +array10.to_s
      puts "UN 1-2 - int 1-2 = " +array11.to_s
      
      =begin
      ARRAY MATH EXAMPLE
      array1 = 12345
      array2 = 1356
      
      UNION 1&2 = 123456 same but order changed UNION 2&1 = 135624
      INT 1&2 = 135 and INT 2&1 are SAME!
      Diff 1-2 = 24
      Add 1+2 = 123451356 same but order changed Add 2+1 = 135612345
      
      
      Diff 2-1 = 6
      
      UN 1-2 - int 1-2 = 246
      =end
      
      module PMA_Intersect
      	require 'sketchup.rb'
      
      	mod = Sketchup.active_model
      	ents = mod.entities
      	
      	#Just test geometry
      	pt1 = [0,0,0]
      	pt2 = [10,0,0]
      	pt3 = [10,10,0]
      	pt4 = [0,10,0]
      
      	group = ents.add_group
      
      	face = group.entities.add_face pt1,pt2,pt3,pt4
      
      	off = 1
      	pt1_in = [0+off,0+off,0]
      	pt2_in = [10-off,0+off,0]
      	pt3_in = [10-off,10-off,0]
      	pt4_in = [0+off,10-off,0]
      	face2 = group.entities.add_face pt1_in,pt2_in,pt3_in,pt4_in
      	face2.erase! 
      	face.reverse!
      	face.pushpull 20
      	
      	#Creating Test Cutgroup
      	cut_group = ents.add_group
      	cut_group.entities.add_face pt1,pt2,pt3,pt4
      	t1 = Geom;;Transformation.translation [0,0,10]
      	t2 = Geom;;Transformation.scaling [5,5,0], 3
      	tr1 = Geom;;Transformation.rotation [0, 0, 16.5], [1, 0, 0], 10.degrees
      
      	cut_group.transform! t1 * t2 * tr1
      
      	cut_tran = cut_group.transformation
      	group_tran = group.transformation 
      
      
      #Entity to cut will be transformed based on the cutting cut_group
      #provided. Both entity and cut_group need to be a group passed
        original_faces = []
        original_edges = []
        group.entities.each do |e|
          original_faces << e if e.is_a? Sketchup;;Face
          original_edges << e if e.is_a? Sketchup;;Edge
        end
      
        cut_trans = cut_group.transformation
        entity_trans = group.transformation
        
        #entities.intersect_with recurse, trans1, entities1, trans2, hidden, entities2
        result = ents.add_group(cut_group.entities.intersect_with( true, cut_tran, group, group_tran , true, group))
      
      	cut_group.erase!
        result.erase!
      
        new_faces  = []
        group.entities.each do |e|
          new_faces << e if e.is_a? Sketchup;;Face
        end
      
      # Array Union and subtraction to find the unique faces
        unique_faces = []
        unique_faces = (original_faces | new_faces) - (original_faces & new_faces)
        
        face_selection = []
        new_faces.each do |e|
          unique_faces.each do |eo|
            if eo.vertices == e.vertices
              face_selection << e
            end
          end
        end
      
        face_selection.each do |e|
         e.erase!
        end
      
        left_faces  = []
        left_edges = []
        group.entities.each do |e|
          left_faces << e if e.is_a? Sketchup;;Face
          left_edges << e if e.is_a? Sketchup;;Edge
        end
       
        to_erase = []
        left_edges.each do |e|
          if e.faces[0] == nil
            e.erase!
             #to_erase << e
          end
        end
      
      end #of PMA_Intersect module 
      
      posted in Developers' Forum
      P
      pmagans
    • RE: Help Understanding Classes and Class objects

      I will check into the mixin module approach also the dynamic components. Are dynamic components "create-able" through Ruby code or only through the Sketchup interface?

      The only info/tutorial I could find was:
      http://sketchucation.com/forums/viewtopic.php?f=180&t=17888&p=145120&hilit=dynamic+component+tutorial#p145120

      posted in Developers' Forum
      P
      pmagans
    • RE: Help Understanding Classes and Class objects

      Dan you are correct. Adding the .group gave me access to the "group" objects that were created.

      As for my thought process I am not sure that it is valid so let me describe my thoughts.

      I don't want to code "like" things so I assumed that using classes would allow me to inherit class attributes things without having to copy a bunch of code it multiple places. For example classes would be:

      1. FUNCTIONAL AREAS
        [list:11tc2ay1]1. CONVEYOR
      • CONVEYOR_COMPONENTS

      • END_PULLEY

      • DRIVE

      • INTERMEDIATE_BED

      • PAN_GUARD

      • BEARINGS

      • ETC.

      • BUILDING_MODSETC.[/*Ⓜ11tc2ay1][/list⭕11tc2ay1]Later I could write Customer specific code for each of the classes and inherit all of the functionality that I wrote in the "General" Classes

      One customer's end_pulley may contain different bearings, pulleys, profiles etc. Also there are many types of end pulleys. That being said they do have some similarities especially attribute definitions, layer structure, basic functionality.

      Am I on the right track or am I way off the rails?

      posted in Developers' Forum
      P
      pmagans
    • RE: Help Understanding Classes and Class objects

      Same message No change - its dying on the puts statements?

      posted in Developers' Forum
      P
      pmagans
    • RE: Help Understanding Classes and Class objects

      This is the output - Doesn't get to the puts statements

      load 'Conveyor/CONVEYOR2.rb'
      true
      conv = CONVEYOR;;Conveyor.new([0,0,0], [0,120,0])
      end_tp details...
      Error; #<NameError; undefined local variable or method `end_tp' for #<CONVEYOR;;Conveyor;0xb8a563c>>
      C;/PROGRA~2/Google/GOOGLE~1/Plugins/Conveyor/CONVEYOR2.rb;43
      C;/PROGRA~2/Google/GOOGLE~1/Plugins/Conveyor/CONVEYOR2.rb;27;in `initialize'
      (eval);435;in `new'
      (eval);435
      
      posted in Developers' Forum
      P
      pmagans
    • RE: Help Understanding Classes and Class objects

      So I added the return @group per your recommendation TIG however I am having some confusion as to how Sketchup sees the newly created groups. It doesn't seem like you can manipulate the returned groups as per the example code below returns undefined method transform!
      It seems as though Sketchup is treating the groups st_ep and end_ep as objects not groups. I have been creating "dummy-container groups to bypass this like Conveyor but I'm guessing from your comment there is an easier way to access the groups that I am creating in the EndPulley class?

      module CONVEYOR #CONVEYOR.rb
         # Type in Console
         # load 'Conveyor/CONVEYOR2.rb'
         # ex. conv = CONVEYOR;;Conveyor.new([0,0,0], [0,120,0])
         
         require 'sketchup.rb'
         
         class Conveyor
            #make the @group var and .group()instance
            attr_reader(;group)
            
            #private #why does this need to be private?
            
            def initialize(st_point, end_point)
               ents = Sketchup.active_model.entities
               #t1 = Geom;;Transformation.translation [0,0,-5]
               
               @st_point = st_point
               @end_point = end_point
               
               #hold reference to group;
               @group = ents.add_group()
               cpt = @group.entities.add_cpoint(ORIGIN)
               @group.name = "CONVEYOR ASSY"
               #@group.transform! t1
               
               self.create_geometry
               cpt.erase!
               
            end #of initialize()
         
            def create_geometry()
               ents = Sketchup.active_model.entities
               t1 = Geom;;Transformation.translation [0,0,-5]
               #pulley 1
               st_ep = EndPulley.new(@group, @st_point)
               #puts st_ep
               st_ep.transform! t1
               
               #pulley 2
               end_ep = EndPulley.new(@group, @end_point)
               end_ep.transform! t1
               
            end #of create_geometry()
         
         end #of Conveyor class
         
         
         
         class EndPulley
               attr_reader(;group)
               
            def initialize(conv_group, ins_pt)
               #TODO; add *args if a group not passed to EndPulley just "create_geometry"
               @conv_group = conv_group
               @ins_pt = ins_pt
               
               self.create_geometry
               
            end #of initialize()
            
            def create_geometry()
               pts = @ins_pt
               width = 36
               length = 18
               
               ents = Sketchup.active_model.entities
               pt1 =[pts[0] - (width/2),pts[1],pts[2]]
               pt2 =[pts[0] - (width/2),pts[1]+length,pts[2]]
               pt3 =[pts[0] + (width/2),pts[1]+length,pts[2]]
               pt4 =[pts[0] + (width/2),pts[1],pts[2]]
         
               @group = @conv_group.entities.add_group()
               face = @group.entities.add_face pt1,pt2,pt3,pt4
               face.reverse!
               face.pushpull 5
               @group.name = "END PULLEY"
               
               return @group
                     
            end #of create_geometry()
            
         end #of EndPulley class 
         
      end #of module CONVEYOR
      
      posted in Developers' Forum
      P
      pmagans
    • RE: Help Understanding Classes and Class objects

      I'm not sure if my last post went through. I wanted to thank everyone though. Also I got everything working and kept the two classes seperate for future inheritence. I had to remove the "private" so that the methods for the Conveyor class could be accessed. I'm not really sure why?

      module CONVEYOR #CONVEYOR.rb
      	# Type in Console
      	# load 'Conveyor/CONVEYOR2.rb'
      	# ex. conv = CONVEYOR;;Conveyor.new([0,0,0], [0,120,0])
      	
      	require 'sketchup.rb'
      	
      	class Conveyor
      		#make the @group var and .group()instance
      		attr_reader(;group)
      		
      		#private #why does this need to be private?
      		
      		def initialize(st_point, end_point)
      			ents = Sketchup.active_model.entities
      			t1 = Geom;;Transformation.translation [0,0,-5]
      			
      			@st_point = st_point
      			@end_point = end_point
      			
      			#hold reference to group;
      			@group = ents.add_group()
      			cpt = @group.entities.add_cpoint(ORIGIN)
      			@group.name = "CONVEYOR ASSY"
      			@group.transform! t1
      			
      			self.create_geometry
      			cpt.erase!
      			
      		end #of initialize()
      	
      		def create_geometry()
      			ents = Sketchup.active_model.entities
      			puts ents.length
      			
      			#pulley 1
      			st_ep = EndPulley.new(@group, @st_point)
      			
      			#pulley 2
      			end_ep = EndPulley.new(@group, @end_point)
      			
      			puts ents.length
      			
      		end #of create_geometry()
      	
      	end #of Conveyor class
      	
      	
      	
      	class EndPulley
      			attr_reader(;group)
      			
      		def initialize(conv_group, ins_pt)
      			#TODO; add *args if a group not passed to EndPulley just "create_geometry"
      			@conv_group = conv_group
      			@ins_pt = ins_pt
      			
      			self.create_geometry
      			
      		end #of initialize()
      		
      		def create_geometry()
      			pts = @ins_pt
      			width = 36
      			length = 18
      			
      			ents = Sketchup.active_model.entities
      			pt1 =[pts[0] - (width/2),pts[1],pts[2]]
      			pt2 =[pts[0] - (width/2),pts[1]+length,pts[2]]
      			pt3 =[pts[0] + (width/2),pts[1]+length,pts[2]]
      			pt4 =[pts[0] + (width/2),pts[1],pts[2]]
      	
      			@group = @conv_group.entities.add_group()
      			face = @group.entities.add_face pt1,pt2,pt3,pt4
      			face.reverse!
      			face.pushpull 5
      			@group.name = "END PULLEY"
      					
      		end #of create_geometry()
      		
      	end #of EndPulley class 
      	
      end #of module CONVEYOR
      
      posted in Developers' Forum
      P
      pmagans
    • RE: Help Understanding Classes and Class objects

      First of all I would like to thank you guys for all of the help. My thought process was skewed in the wrong direction and I don't think I would've come up with the passing the group object. Also starting with the group and then adding the entities is now clear in my head. I had read that before in other posts but could never quite understand the "how". That was where I was hopelessly stuck for the past day. I have re-written the previous code and module-ized it and it works perfectly.

      I kept the classes for Conveyor and EndPulley seperate so that I can use both seperately for inheritance in the future.

      I still need to check into "Wrapper" classes further for how I can implement them effectively.

      The only snag was I had to remove the private designation for the methods under the Conveyor class to work. I'm not really certain why.

      module Pmagans
      	# Type in Console
      	# load 'Conveyor/CONVEYOR2.rb'
      	# conv = Pmagans;;Conveyor.new([0,0,0], [0,120,0])
      	
      	class Conveyor
      		#make the @group var and .group()instance
      		attr_reader(;group)
      		
      		#private #why does this need to be private?		
      		def initialize(st_point, end_point)
      			ents = Sketchup.active_model.entities
      			
      			@st_point = st_point
      			@end_point = end_point
      			
      			#hold reference to group;
      			@group = ents.add_group()
      			cpt = @group.entities.add_cpoint(ORIGIN)
      			@group.name = "CONVEYOR ASSY"
      						
      			self.create_geometry
      			cpt.erase!
      			
      		end #of initialize()
      	
      		def create_geometry()
      			ents = Sketchup.active_model.entities
      			puts ents.length
      			
      			#pulley 1
      			st_ep = EndPulley.new(@group, @st_point)
      			
      			#pulley 2
      			end_ep = EndPulley.new(@group, @end_point)
      			
      			puts ents.length
      			
      		end #of create_geometry()
      	
      	end #of Conveyor class
      	
      	
      	
      	class EndPulley
      			attr_reader(;group)
      			
      		def initialize(conv_group, ins_pt)
      			#TODO; add *args if a group not passed to EndPulley just "create_geometry"
      			@conv_group = conv_group
      			@ins_pt = ins_pt
      			
      			self.create_geometry
      			
      		end #of initialize()
      		
      		def create_geometry()
      			pts = @ins_pt
      			width = 36
      			length = 18
      			
      			ents = Sketchup.active_model.entities
      			pt1 =[pts[0] - (width/2),pts[1],pts[2]]
      			pt2 =[pts[0] - (width/2),pts[1]+length,pts[2]]
      			pt3 =[pts[0] + (width/2),pts[1]+length,pts[2]]
      			pt4 =[pts[0] + (width/2),pts[1],pts[2]]
      	
      			@group = @conv_group.entities.add_group()
      			face = @group.entities.add_face pt1,pt2,pt3,pt4
      			face.reverse!
      			face.pushpull 5
      			@group.name = "END PULLEY"
      					
      		end #of create_geometry()
      		
      	end #of EndPulley class 
      	
      end #of module Pmagans
      
      posted in Developers' Forum
      P
      pmagans
    • Help Understanding Classes and Class objects

      Hello all,

      I would like to make a class that is a collection of other class objects. I am having a tough time determining exactly how to do this.
      st_ep and end_ep end up as class objects but I can't add them to a group in the the class Conveyor draw method. I can't access the objects at all it seems for grouping, transformations etc. Any help where my thought process is wrong would be greatly appreciated. I have been searching all over for an answer.

      <span class="syntaxdefault"></span><span class="syntaxkeyword">class&nbsp;</span><span class="syntaxdefault">Conveyor<br />&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;initialize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">st_point</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">end_point</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@</span><span class="syntaxdefault">st_point&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">st_point<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">@</span><span class="syntaxdefault">end_point&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">end_point<br />&nbsp;&nbsp;&nbsp;&nbsp;end&nbsp;</span><span class="syntaxcomment">#of&nbsp;initialize()<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">def&nbsp;draw</span><span class="syntaxkeyword">()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">ents&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;st_ep&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">EndPulley</span><span class="syntaxkeyword">.new(@</span><span class="syntaxdefault">st_point</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">st_ep</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">draw<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end_ep&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">EndPulley</span><span class="syntaxkeyword">.new(@</span><span class="syntaxdefault">end_point</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">end_ep</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">draw<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conv_group&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">ents</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_group&nbsp;st_ep</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">en_ep<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conv_group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">name&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxstring">"CONVEYOR&nbsp;ASSY"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">end&nbsp;</span><span class="syntaxcomment">#of&nbsp;draw()<br /><br /></span><span class="syntaxdefault">end&nbsp;</span><span class="syntaxcomment">#of&nbsp;Conveyor&nbsp;class<br /><br /></span><span class="syntaxkeyword">class&nbsp;</span><span class="syntaxdefault">EndPulley<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;initialize</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">ins_pt</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@</span><span class="syntaxdefault">ins_pt&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">ins_pt<br />&nbsp;&nbsp;&nbsp;&nbsp;end&nbsp;</span><span class="syntaxcomment">#of&nbsp;initialize()<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">def&nbsp;draw</span><span class="syntaxkeyword">()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">pts&nbsp;</span><span class="syntaxkeyword">=&nbsp;@</span><span class="syntaxdefault">ins_pt<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;width&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">36<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;length&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">18<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ents&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pt1&nbsp;</span><span class="syntaxkeyword">=[</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]&nbsp;-&nbsp;(</span><span class="syntaxdefault">width</span><span class="syntaxkeyword">/</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">),</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">],</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">]]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">pt2&nbsp;</span><span class="syntaxkeyword">=[</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]&nbsp;-&nbsp;(</span><span class="syntaxdefault">width</span><span class="syntaxkeyword">/</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">),</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">]+</span><span class="syntaxdefault">length</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">]]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">pt3&nbsp;</span><span class="syntaxkeyword">=[</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]&nbsp;+&nbsp;(</span><span class="syntaxdefault">width</span><span class="syntaxkeyword">/</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">),</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">]+</span><span class="syntaxdefault">length</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">]]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">pt4&nbsp;</span><span class="syntaxkeyword">=[</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]&nbsp;+&nbsp;(</span><span class="syntaxdefault">width</span><span class="syntaxkeyword">/</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">),</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">],</span><span class="syntaxdefault">pts</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">2</span><span class="syntaxkeyword">]]<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">face&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">ents</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_face&nbsp;pt1</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">pt2</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">pt3</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">pt4<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">ents</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_group&nbsp;face<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;group</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">name&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxstring">"END&nbsp;PULLEY"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">reverse</span><span class="syntaxkeyword">!<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">pushpull&nbsp;5<br />&nbsp;&nbsp;&nbsp;&nbsp;end&nbsp;</span><span class="syntaxcomment">#of&nbsp;draw()<br /></span><span class="syntaxdefault">end&nbsp;</span><span class="syntaxcomment">#of&nbsp;EndPulley&nbsp;class&nbsp;</span><span class="syntaxdefault"></span>
      
      posted in Developers' Forum
      P
      pmagans
    • 1 / 1