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

    Posts

    Recent Best Controversial
    • RE: Will NOT scramble ??

      @tig said:

      The Ruby __FILE__ won't work inside a compiled .rbs file, so that's probably breaking it.
      ...
      ...

      Something is not right here - you say the "FILE" won't wotk in .rbs files - NOT TRUE !

      Here is an example and it works fine BOTH as rb- and rbs-file:

      
      require 'sketchup'
      
      filename=File.basename(__FILE__)
      if(not file_loaded?(filename))
          UI.menu("Plugins").add_item("Bolte") { Sketchup.active_model.select_tool Bolte.new }
      end
      file_loaded(filename)
      
      class Bolte
      
          # Konstanter til diverse dialoger og statustekster
          DIAMETER  = "Diameter      ;"
          HOVEDTYP  = "Hovedtype     ;"
          SKIVEVED  = "Skive ved     ;"
          PLACER    = "Placer ved    ;"
          KOPI      = "Tilføj kopi   ;"
          
          FORFRA    = " ELLER højre-klik for at starte forfra !"
          NOTONFACE = "Det udprikkede punkt er IKKE på en flade !"
          UDAFEMNET = "Angiv boltlængden ved at klikke, hvor hjælpelinien kommer ud af emnet"
          EVTFLERE  = "Vælg evt. flere boltplaceringer, indtast fast boltlængde"
          
          SEKSKANT  = "6 Kant"
          UNBRAKO   = "Unbrako"
          
          INGEN     = "Ingen"
          HOVED     = "Hoved"
          MOETRIK   = "Motrik"
          BEGGE     = "Begge"
          UDMAAL    = "Krydsstreger"
          KLIKMUS   = "Klik med mus"
          JA        = "Ja"
          NEJ       = "Nej"
          
          
      	def initialize
              UI.messagebox("Hertil !",MB_OK)
      	end
      	
      	
      end # of class Bolte
      

      I beleave the code witch started this posting is structured EXACTLY likewise - but it will ONLY run as a rb-file, NOT as a rbs-file - i can't see the principal difference:

      require 'sketchup'
      
      filename=File.basename(__FILE__)
      if(not file_loaded?(filename))
          UI.menu("Plugins").add_item("Remskive") { Sketchup.active_model.select_tool Polley.new }
      end
      file_loaded(filename)
        
      class Polley
      
          # store bogstaver evt. med _ er en CONST
          MINDIAP = 50.mm
          MINDIAA = 10.mm
          MINKRVD = 25.mm
          MINKRVB = 15.mm
          
          def initialize()
             UI.messagebox("Hertil !",MB_OK)
          end #initialize
      end #class   
      
      

      Can someone pleace tell me why ?

      Both sample codes are cut down to minimal still showing the problem (you can cut out more if you like) - that's why they seems so non sence !

      (>> thomthom: The original files ARE organised as SketchupExtensions - but it's not shown here because I don't think it's part of the problem)

      posted in Developers' Forum
      K
      ksor
    • RE: Will NOT scramble ??

      @tig said:

      The Ruby __FILE__ won't work inside a compiled .rbs file, so that's probably breaking it.
      You would normally only scramble code you want to remain protected and private.
      Making some menu items is not one of those.
      Why do you want to scramble such a 'simple script'?
      You are hardly protecting your intellectual property rights in the code you showed us...
      Can I suggest that you make a 'loader' script that is a .rb file [which has code the menus/toolbars etc, 'require'ing the main script[s] etc which will be inside your own tool's subfolder - any encrypted .rbs scripts are [usually] kept inside such a subfolder - that's also where any webdialog files, images for toolbar buttons etc will reside...
      Then you have no difficulties setting the menu up via the .rb file AND your code in the .rbs file[s] remains confidential... IF you really have to protect it in this way...

      I just want to try to scramble my code because I (thought I !) can !

      This simple sample is just because I tried to eliminate big chunks of code - and by the first try it went wrong.

      And you'r just right - setting up menues is not something you want to protect - and now I know I CAN'T 😉)

      posted in Developers' Forum
      K
      ksor
    • Will NOT scramble ??

      When I run this as a rs-file it "works" fine - it comes up in the menu !

      require 'sketchup'
          
      filename=File.basename(__FILE__)
      if(not file_loaded?(filename))
          UI.menu("Plugins").add_item("Remskive") { Sketchup.active_model.select_tool Polley.new }
      end
      file_loaded(filename)
      
      class Polley
      
          # store bogstaver evt. med _ er en CONST
          MINDIAP = 50.mm
          MINDIAA = 10.mm
          MINKRVD = 25.mm
          MINKRVB = 15.mm
          
      end #class   
      
      

      when I scramble the file - NOTHING comes up in the menu !

      NO CHANGES except that it's scrambled - why ?

      posted in Developers' Forum
      K
      ksor
    • RE: [Plugin] Bolt Maker (Final Update 7-Feb-2012)

      @tig said:

      Most logical authors put the current file download-link on the first post in the tool's thread.
      So look there.

      It's quite easy to add a link to that very page in the post announcing the update - see most of my scripts' threads...

      I allready HAVE that file - so it's OK !

      But normaly you can't place a new posting as the first posting i a thread - right ?

      You have to EDIT the first post

      posted in Plugins
      K
      ksor
    • RE: [Plugin] Bolt Maker (Final Update 7-Feb-2012)

      @sdmitch said:

      OOPS!!!! Sorry Bolt Maker fans. Dispite what I thought was adaquate testing, I found a problem while playing around with the plugin this morning. It has been corrected and a new copy posted.

      Hi younger brother !

      You say it's the file is updated but where is the updated file placed ?

      posted in Plugins
      K
      ksor
    • RE: Inputbox control with while loop

      Yes, you'r SO right !

      About the npp++ and TABs I can only choose Ruby and the "Use standard setting" about the TABs - the "Use spaces is disabled"

      I'll try to let my headlines TELL about the problem in the post

      BUT it IS DRIVING ME MAD !!!!!!!!!! 😉)

      posted in Developers' Forum
      K
      ksor
    • RE: No pushpull when touching ????

      @tig said:

      If you want to build it up in parts you can.
      I suggest you make a container group that holds all of the sub-groups.
      Then when you explode sub-groups the geometry still stays inside the 'container'.
      IF you have a reference to a face or can get a reference to it later [perhaps from face.classify_point()] then creating a circle on the face and pushpulling it through to the other side of the object [you know the 'thickness ?] is quite possible and should then leave the 'hole'...

      Why not do a simple 'practice' on a dead simple box with a smaller square drawn on it, that is then extruded through the box by exactly the box's thickness to leave a hole...

      Yeah,I'll give it a try - thx

      posted in Developers' Forum
      K
      ksor
    • RE: No pushpull when touching ????

      Of cause I do !

      But then I DON'T find out - how to build up a group bit by bit and it could be nice too.

      But I'll finish my pulley script with your idea !

      posted in Developers' Forum
      K
      ksor
    • RE: No pushpull when touching ????

      OK - now I can make those two parts of the pulley - the wheel and the cylinder - as two separate groups !

      Now I want to drill a hole through BOTH of them for the shaft - but I can't because they are different groups !

      I think I'll have to make a third group for the hole because of the pushpull won't work if the "beginning circle" is made on the buttom of the cylinder (like my problems makeing the cylinder under the pulley !) and that's making it all even worse !

      It can't be true it is SO sofisticated to do such trivial things !

      I thing I need a sample code for:

      1. making a hole in a cylinder for a shaft
      2. sort of moving all entities from one group X into another group Y - maybe as a sub-group in group Y or just "entities" in group Y

      I cant find samples out there - do you have any links ?

      posted in Developers' Forum
      K
      ksor
    • RE: No pushpull when touching ????

      @tig said:

      PS: I'm not clear why you need to use diameter.to_f/2 when making the circle, because you can [should] initially set/get/pass ' diameter' as a length so then there's no need to mess on with it later, since halving it as a length will work without changing its class:?

      I get a DIAMETER from the inputbox, but the circle method needs a RADIUS - that's why ...

      but maybe I should call the argument 'radius' and make the calculation in the call instead.

      posted in Developers' Forum
      K
      ksor
    • RE: No pushpull when touching ????

      @tig said:

      In the second method don't add geometry to @entities but rather add it to into a group
      grp1=@entities.add_group()
      gents=grp1.entities
      so then do
      krvFlade = gents.add_face(@entities.entities.add_circle([0,0,0], [0,0,-1],diameter.to_f/2, 48))
      etc
      The cylinder's geometry won't interact with the pulley's geometry.
      You can explode the groups on completion if desired.

      You could in fact add all of your new geometry inside separate groups, with sub-groups for the various pulleys and their parts.
      You could even convert the pulley groups into components and then add new instants of them as needed etc...

      I beleave it should be:

      krvFlade = gents.add_face(grp1.entities.add_circle([0,0,0], [0,0,-1],diameter.to_f/2, 48))
      
      

      or else the circle has no "inner face" - right ?

      posted in Developers' Forum
      K
      ksor
    • RE: Push Pull direction?

      @tig said:

      OK simple typo - simple fix.
      THIS version recalls the dialog on an invalid entry...
      See how I split a 'draw_pulley' method off from the un-callable 'initialize' that I had inadvertently typed....
      You should recognize much of your code/steps in the reworked version - I've just avoided the pitfalls of your while-loop, un-ended if's etc etc...

      Now I'm a little over analytical again 😄 - I think your code here contains a bomb:

      			def draw_pulley()
                      # default MINIMUM values
                      @diaP = MINDIAP if not @diaP or (@diaP < MINDIAP) 
                      @diaA = MINDIAA if not @diaA or (@diaA < MINDIAA) 
                      @krvD = MINKRVD if not @krvD or (@krvD < MINKRVD) 
                      @krvB = MINKRVB if not @krvB or (@krvB < MINKRVB)
      				return nil unless self.dialog()
      				self.draw_beltProfile()
                      self.set_beltProfileOnWheel()
                      self.pull_pulley()
                      self.pull_krave()
      		    end
      			
      		    def dialog()
      					prompts = ["Skivediameter (mm) ;",
                                 "Akseldiameter (mm) ;",
                                 "Kravediameter (mm) ;",
                                 "Kravebredde   (mm) ;"]
                          values = [@diaP, @diaA, @krvD, @krvB]
                          results = inputbox(prompts, values, "Specifikationer")
                          return nil if not results
      					diaP, diaA, krvD, krvB = results
      					if (diaP < MINDIAP) || (diaA < MINDIAA) || (krvD < MINKRVD) || (krvB<MINKRVB)
                              UI.messagebox("Mindsteværdi er genindsat - de(n) SKAL overholdes !", MB_OK)
      						self.draw_pulley()
      						return nil
      					else
      					    @diaP, @diaA, @krvD, @krvB = results
      						return true
                          end
                  end    
      
      

      The call to self.draw_pulley is a sort of recursive - just returning nil would be better and then this in the initializing method:

      				until self.draw_pulley() != nil 
                  end
      
      

      Right ?

      posted in Developers' Forum
      K
      ksor
    • No pushpull when touching ????

      I have these two fully encapsled methods:

      def makePulley(diameter, profile)
                      # rotate profile 90°
                      tr = Geom;;Transformation.rotation([(diameter.to_f/2),0,0], [1,0,0], 90.degrees)
                      @entities.transform_entities(tr, profile)
                      # remskiven laves ud fra profilen
                      profile.followme(@entities.add_circle([0,0,0], [0,0,1],diameter.to_f/2, 48))
                  end
      

      and

                  def pull_krave(diameter, bredde)
                      # En krave til nippelskruer laves efter angivne dimensioner
                      krvFlade  = @entities.add_face(@entities.add_circle([0,0,-0.05.mm], [0,0,-1],diameter.to_f/2, 48))
                      krvFlade.pushpull(bredde)
                  end
      
      

      The first method makes the upper 'half' of the attached picture - the pulley - the second method makes the cylinder under the pulley - they seems to work fine, BUT

      What you can't see on the picture is that there is a small amount of 'air' (0.05.mm) between the pulley and the cylinder. You can see in the second method that the circle has a center in [0,0,-0.05.mm] - I would like to have that center in [0,0,0] BUT if I do that, the pushpull won't work at all - it only makes the circle !

      • why ?

      pulley.jpg

      posted in Developers' Forum
      K
      ksor
    • RE: [Plugin] Ruby Toolbar

      I got it now 😳 !

      • and the toolbar works really fine - nice tool !
      posted in Plugins
      K
      ksor
    • RE: [Plugin] Ruby Toolbar

      Why do I get this load error when I try the "Ruby Toolbar"

      Error Loading File C:/Program Files/Google/Google SketchUp 8/Plugins/rubytoolbar/rubytoolbar.rb
      no such file to load -- Win32APIError Loading File rubytoolbar.rb
      no such file to load -- Win32API

      I have attached my PlugIns and rubytoolbar folders


      Plugins folder


      rubytoolbar folder

      posted in Plugins
      K
      ksor
    • RE: Push Pull direction?

      OK - I see it's for internationalization of the code - I misunderstood this in the first place.

      posted in Developers' Forum
      K
      ksor
    • Inputbox control with while loop

      At least I think so !

      I have this code and it SHOULD show 2 stacked cylinders - see line 79 and 80 BUT...

      I think the pushpull is going in THE WRONG direction - OK, I can then just change the 2.mm to -2.mm in line 80, but with the normal vector [0,0,1] it SHOULD be 2.mm - right ?

      OK - try this: Change the 12.7.mm in line 79 to 12.73.mm - not 12.71.mm or 12.72.mm - abra ca dabra - now the pushpull is going in the same direction as the normal vector - the RIGHT direction - agree ?

      What is wrong ?

      require 'sketchup.rb'
      
          module KSOR
      	
              UI.menu("PlugIns").add_item("Kileremskive"){KSOR;;Polley.new()}
      	   
              class Polley
      
                  # store bogstaver evt. med _ er en CONST
                  MINDIAP = 40.mm
                  MINDIAA = 10.mm
                  MINKRVD = 20.mm
                  MINKRVB = 15.mm
      			
      			Sketchup.send_action("showRubyPanel;")
                 
                  def initialize()
      				@model = Sketchup.active_model
      				@entities = @model.active_entities
      				self.draw_pulley()
      			end
      			
      			def draw_pulley()
                      # secure at least default MINIMUM values
                      @diaP = MINDIAP if not @diaP or (@diaP < MINDIAP) 
                      @diaA = MINDIAA if not @diaA or (@diaA < MINDIAA) 
                      @krvD = MINKRVD if not @krvD or (@krvD < MINKRVD) 
                      @krvB = MINKRVB if not @krvB or (@krvB < MINKRVB)
      				return nil unless self.input_dialog()
      				self.draw_beltProfile()
                      self.set_beltProfileOnWheel()
                      self.pull_pulley()
                      self.pull_krave()
      		    end
      			
      		    def input_dialog()
      					prompts = ["Skivediameter (mm) ;",
                                     "Akseldiameter (mm) ;",
                                     "Kravediameter (mm) ;",
                                     "Kravebredde   (mm) ;"]
                          values = [@diaP, @diaA, @krvD, @krvB]
                          results = inputbox(prompts, values, "Specifikationer")
                          return nil if not results
      					diaP, diaA, krvD, krvB = results
      					if (diaP < MINDIAP) || (diaA < MINDIAA) || (krvD < MINKRVD) || (krvB<MINKRVB)
                              UI.messagebox("Mindsteværdi er genindsat - de(n) SKAL overholdes !", MB_OK)
      						self.draw_pulley()
      						return nil
      					else
      					    @diaP, @diaA, @krvD, @krvB = results
      						return true
                          end
                  end    
                
                  def draw_beltProfile()
                          # Her laves en profil, som svarer til en kilerem
                          # med YDERSIDEN en halv diameter ude af X-aksen
                      pt1 = [0 + (@diaP.to_f/2) - 13.8.mm, 4.22.mm, 0]
                      pt2 = [@diaP.to_f/2, 0, 0]
                      pt3 = [@diaP.to_f/2, 12.7.mm, 0]
                      pt4 = [0 + (@diaP.to_f/2) - 13.8.mm, 8.48.mm, 0]
                      # profilfladen laves
                      @beltProfile = @entities.add_face(pt1, pt2, pt3, pt4)
                  end
                
                  def set_beltProfileOnWheel()
                      # Skive laves
                      @periferi = @entities.add_circle([0,0,0], [0,0,1],@diaP.to_f/2, 48)
                      # rotate beltProfile 90°
                      tr = Geom;;Transformation.rotation([13.8.mm,0,0], [1,0,0], 90.degrees)
                      @entities.transform_entities(tr, @beltProfile)
                      # gruppen exploderes for at lave FollowMe og findes så ikke mere
                      @beltProfile.followme(@periferi)
                      @periferi=nil
                  end
                
                  def pull_pulley()
                      # Nu skal siderne på skiven laves 2 mm på hver side
                      opSideFlade = @entities.add_face(@entities.add_circle([0,0,12.7.mm], [0,0,1], @diaP.to_f/2, 48))    # HERE change to 12.73.mm
                      opSideFlade.pushpull(2.mm)
      =begin                nedSidePeriferi = @entities.add_circle([0,0,0], [0,0,1], @diaP.to_f/2, 48)
                      nedSideFlade = @entities.add_face(nedSidePeriferi)
                      nedSideFlade.pushpull(-2.mm)
      =end                cleanUp
                  end
                
                  def cleanUp()
                      # En cylinderflade fjernes, så der åbnes ind til remprofilen
                     
                  end
                 
                  def pull_krave()
                      # En krave til nippel skruer laves efter angivne dimensioner
                      # og der skal laves hul til akslen med den givne diameter
                 
                  end
                
              end  #class   
          end    # module
      
      posted in Developers' Forum
      K
      ksor
    • RE: Push Pull direction?

      Ha, ha, too analytical - you can't be when working with OOP, I beleave.

      😄 I'm just trying to get a nice structure from begining of my Ruby eara.

      Dan

      ???? I don't know what you mean:
      "$exStrings.GetString("Specifikationer") will NOT work. All LanguageHandler keys are English. The values that are returned, are in the other language."

      It DID work fine, eventhough I can see TIG changed it - in fact it did work.

      My test for Mac or PC was code I found and I thought that code for Mac WAS special so why not make a test - but OK it's obsolete.

      Now I'll try to finish the pulley thing !

      posted in Developers' Forum
      K
      ksor
    • RE: Push Pull direction?

      I'll study the code and compare it with my thinking of Class, Objects, properties ect.

      But I beleave this is "the right! structure or ... ?

      The next Object - let's a a drivebelt - should use this code as "template" (the structure) or ...?

      posted in Developers' Forum
      K
      ksor
    • RE: Push Pull direction?

      @tig said:

      Read my edited post and the attachment...
      The end was because the 'if' aren't properly formed and the first one 'steals' the while's end.
      BUT my example shows how to avoid this 'while' loop altogether !
      There were a number of overlaid issues - it's best to see my alternative reworking on how some things are just avoided/omitted or alternative forms will work as you hope...

      Yeah, but now you took it a little further than I can cope with !

      AND

      😆 you should have tried to input a lower value than the minimum allowed - if you do you get this error:

      Error: #<NoMethodError: private method initialize' called for #<KSOR::Polley:0xa9cd790>> C:/Program Files/Google/Google SketchUp 8/Plugins/RemSkive.rb:43:in dialog'
      C:/Program Files/Google/Google SketchUp 8/Plugins/RemSkive.rb:25:in initialize' C:/Program Files/Google/Google SketchUp 8/Plugins/RemSkive.rb:5:in new'
      C:/Program Files/Google/Google SketchUp 8/Plugins/RemSkive.rb:5

      and NO re-asking of new input but that's surely caused by the error.

      posted in Developers' Forum
      K
      ksor
    • 1
    • 2
    • 3
    • 4
    • 3 / 4