sketchucation logo sketchucation
    • Login
    1. Home
    2. artmusicstudio
    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!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 84
    • Posts 217
    • Groups 2

    Posts

    Recent Best Controversial
    • RE: Skp8 - saving toolbars

      @dave r said:

      Out of curiosity, did you try the Save toolbar positions option under View>Toolbars?

      hi, yes i did, again thanx for the tip.
      on the local machine with skp8 its perfect.
      since i updated all my computers now to skp 8, the missing function in skp 6 is not really relevant anymore.
      for copyying between the maschines the additional software works well (small curiosity: skp seems to use the 'regional' function names , means translations for the shortcut-table, not the native program variables, so
      cross-copy between german and english installation does not work, funny, but not really a problem...)
      regards stan

      posted in SketchUp Discussions
      artmusicstudioA
      artmusicstudio
    • RE: Variables - issue

      @massimo said:

      Moved to developers forum.

      Hi Stan, would you mind to post such threads in developers section of the forum? Usually the newbie section is about SU's usage.
      Thanks.

      hi massimo,
      sorry, of course, didn't think about that , i'll be carefull in the future!
      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Variables - issue

      hi tig,
      sorry, is this
      "As I said before... please put extracts of code in a 'code' BBCs tag [][/], shorter bits can be unformatted in a 'ruby' tag [][/]"
      ment for the forum syntax? if so, is there a guide? please excuse, when i missed it so far.

      for the ruby:
      what ever i do, i cannot manage it within the loop (weven hith your tips). placing one element after each other works perfect. so i have to go a step back and need some days to study the basic principles of variables and instances (but the ruby grows!!!).
      thanx a lot , i keep on trying...
      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • Variables - issue

      hi,
      i just studied the different variables (@, $), but i cannot find out, why my definition does not work:

      i define certain variables in loop 1:


      for pfosten in 0..2
      pfostenname=[]
      pfostenname[0] = "masterpfostenl"
      pfostenname[1] = "masterpfostenr"
      pfostenname[2] = "mittelpfostenm"

         ..........          
      

      else

      .........

      end
      puts "creating component"
      puts pfostenname[pfosten]
      pfostenname[pfosten] = group.to_component

      end


      after this, the 3 components are created (master elements for further transformation). OK

      BUT

      in the following loop (later in the ruby)


      if (step) / il == podestnr #some conditions

          	componentinstance =
      	entities.add_instance(masterpfostenl.definition, pf1p) # copy to point pf1p
      	    		 		
      		elsif   
      

      ..................

                  elsif
      

      ....................
      end


      the add instance function reports:

      Error: #<NameError: undefined local variable or method `masterpfostenl' for main:Object>

      why does this happen?

      the component with the name "masterpfostenl" exists and is placed on the screen

      so why does the transfer-function not find it?

      thank you a lot. i just ry to understand, how the variable-instances work...
      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Saving a row of variables into a text-file

      hi tig,
      ok, you are right, puts does it automatically.

      the declaration of the variables happens in the beginning of the ruby,
      first loaded from the default file and then possibly changed by the user...

      these settings then create the geometry and are saved to a separate file (later as function : reload last user parameters).

      will just try the puts-version.

      stan

      EDIT: IT WORKS

      parameters are saved at the end of ruby
      and
      automatically reloaded on start

      πŸ˜„

      wonderful!

      posted in Newbie Forum
      artmusicstudioA
      artmusicstudio
    • Saving a row of variables into a text-file

      hi,
      with this code i can save a row of my variables to a text - file, but in one line

      file = File.open("C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/zf/partemp.txt", "w") { |f|
      f << lines[0].to_f
      f << lines[1].to_f
      f << lines[2].to_f
      }

      when i try to separate the values by \n, there is a syntax error:

      file = File.open("C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/zf/partemp.txt", "w") { |f|
      f << lines[0].to_f\n
      f << lines[1].to_f\n
      f << lines[2].to_f\n
      }

      no tips about this on the net.

      any tips for the syntax?

      thanx stan

      posted in Newbie Forum sketchup
      artmusicstudioA
      artmusicstudio
    • RE: Find the location of an object using Ruby

      hi dan & tig,
      thanx a lot, though this is a different approach than mine, but very useful. i will try to implement thiscurslr functionality , too, if i manage it.
      for my idea i will let the user draw 1 line, which can maybe be selected for the ruby call and give the ruby the vector to transform the object.
      so the ruby-fight continues...
      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Soften-Edges using by ruby

      YEAP!

      smooth like a sup of tea with milk on a sunny afternon......

      smoothing works perfect , thanx a lot ("again what learned", as we say here in bavaria)

      lost a ot of time today with fighting again coordinate systems, whatever i do, the elements don't place themselves sometimes , where i expect them to, it seems, that within groups and components the time & space works different sometimes.....
      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Soften-Edges using by ruby

      hello,
      this piece of code is very helpful.
      in my case this works:

      SMOOTH LEFT

      model=Sketchup.active_model
      ss=group20.entities

      You can assemble any collection of edges

      Here it's from the model's current selection

      edges=[]
      ss.to_a.each{|e|
      edges << e if e.class==Sketchup::Edge
      e.entities.each{|ee|edges << ee if e.class==Sketchup::Edge}if e.class==Sketchup::Group
      }
      edges.each{|edge|
      if edge.faces[1]
      edge.soft=true
      edge.smooth=true
      end
      }

      BUT THIS ONE (smoothing with angle limit)
      model=Sketchup.active_model
      ss=group20.entities

      You can assemble any collection of edges

      Here it's from the model's current selection

      edges=[]
      ss.to_a.each{|e|
      edges << e if e.class==Sketchup::Edge
      e.entities.each{|ee|edges << ee if ee.class==Sketchup::Edge}if e.class==Sketchup::Group
      }
      edges.each{|edge|
      ang=edge.faces[0].normal.angle_between(edge.faces[1].normal)
      if edge.faces[1]
      edge.soft=true if ang < 45.degrees
      edge.smooth=true if ang < 45.degrees
      end
      }

      is quit by following:

      VAR. 0.1 k
      load '01.rb'
      Error: #<NoMethodError: undefined method normal' for nil:NilClass> C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:1516:in draw_stairs'
      C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:1515:in each' C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:1515:in draw_stairs'
      C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:973:in `each'

      any idea about the "normal" problem?

      thanx stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Find the location of an object using Ruby

      hi tig,
      exactly that is my problem.

      if i was defining the position for the object placement myself, i of course could transformate myself to a desired x,y,z-position.

      but

      what do i do, when the desired x,y,z is defined by the user (set coordinates axis) before he starts the script?

      so the question is, is it possible to 'read' the user-defined axis-offset from some global variable?

      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Find the location of an object using Ruby

      hi tig,
      the situation is the following.

      when i calculate coordinates for the parts of my geometry to be created by the ruby, i have all measures related to 0,0,0.

      but this is always the global zero.

      what i would like to achieve is, that the user sets the axis at the point, where the new geometry is to be generated, with x-axis defining the orientation (the ruby would only take the temporary 0,0,0 , the direction of the horizontal compoment of the x-axis and place the object - always horizontal at X).

      so if there are global variables showing the offset from global zero to temp-zero, i could place the object at global 0
      and transform it (move).

      πŸ˜„
      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Find the location of an object using Ruby

      hello gentlemen,
      now the question is:

      how can i place my own object per ruby on

      user defined coordinates (means: where the user definies per axis-position)

      so the object's X-coordinate would be the AXIS's X and the 0,0,0 of the object
      would be 0,0,0 of the USER's axis (temp.)

      i cannot find anything about axis-positioning in the api....

      thanx & regards stan
      thanx stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Load text file and assign to variables

      hi tig,
      that's it .
      my logic was ok, your tip for the conversion of string to float was the point.

      basicly it works like this:

      i have menues for parameters

      then the geometry is created

      before the end of the ruby i save all parameters to a text file (by the way still looking for the syntax to save more of them line by line)

      then the user can recall the ruby and select
      -my last parameters
      -defaults

      and so on and so on

      again another step!!!!

      regards stan ( i'll report , when i get further)

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: PROBLEM WITH PUSHPULL VECTOR

      hi tig,
      you are the greatest, as always.
      it works.
      it's funny, that "my" wrong syntax works at the beginning of the ruby...god knows....will correct all of them.

      again a step nearer to my first ruby (for everyone then, of course)

      regards and thax
      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • PROBLEM WITH PUSHPULL VECTOR

      hi,
      with this code (the FAKTOR is only fpr inch/cm recaltulation )


      model = Sketchup.active_model
      entities = model.active_entities
      rl1 = [-50/faktor/100,0/faktor/100,20/faktor/100]
      rl2 = [-50/faktor/100,10/faktor/100,30/faktor/100]

         group40 = entities.add_group
                       entities2 = group40.entities
                       new_line = entities2.add_line rl1, rl2
                       length = new_line.length
                       
                           centerpoint = rl2
                                                      # Create a circle perpendicular to the normal or Z axis
                           vector = rl1
                           vector2 = vector.normalize!
                       
                           edges = entities2.add_circle centerpoint, vector2, 3
                        
                           kreis = entities2.add_face edges
                    kreis.pushpull length
      

      i normally (and even in the beginning of this ruby-script (other cylinder)
      can pushpull along the line without any problem.

      BUT

      at the end of the script the same code lets the circle turn to an undefined angle.
      absolutely crazy.
      any idea how to fix it? >> screenshot
      thanx.
      stan


      131013-PROBLEM VECTORt.jpg

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Load text file and assign to variables

      hi tig,
      thanx a lot, i inserted the new import routine and tried different variantion.
      ruby gives back:
      load '01.rb'
      true
      Error: #<NameError: undefined local variable or method lines' for #<Object:0x3d31654 @v_b="90", @v_a="300", @v_c="100">> C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:96:in draw_stairs'
      C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:48
      C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:96:in call' C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:96 load '01.rb' true Error: #<NoMethodError: undefined method /' for "300":String>
      C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:173:in draw_stairs' C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:48 C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:96:in call'
      C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/01.rb:96

      so the situation is:

      i am created an object in skp, which can be controlled in diverse dimension by an input menue (parameters)

      when the object is created, i save the parameters in a text file (parttemp2.txt):

      content of parttemp2.txt now for testing:
      300
      90
      100

      it seems, that reloading these numbers gives back STRINGS and not numbers

      as <ou also said, i would like to handle these imported parameters by

      parameter01 = lines[0]
      parameter02 = lines[1]

      and so on.

      but it simply does not work now for me. have to study more about formats (you know, i am on ruby since few days)

      this is the whole pert of the code: (where WIDTH shall become the value of line 0 in the text-file)


      require 'sketchup.rb'
      #require 'offset.rb'
      #require 'makesoftsmooth.rb'
      .
      Sketchup.send_action "showRubyPanel:"

      #Add a menu item to launch our plugin.
      UI.menu("PlugIns").add_item("01-ZF-Stairs"){
      UI.messagebox("Outdoor-Stairs - Script - 131011-V 0.1j - Zdenek Fajfrlik")

      #result = UI.messagebox "New Definition?", MB_YESNO
      #if result == 6 # Yes

      UI.messagebox("New Definition")

      end

      #count = 0

      #File.open('C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/zf/partemp.txt', 'r') do |f1|
      #while line = f1.gets
      #puts line

      #width = f1.gets  
      #end  
      

      #end

      file = 'C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/zf/partemp2.txt'
      lines=[]
      IO.readlines(file).each{|line|
      line.chomp! ### removes the '\n' from the end of the line
      next if line.empty? ### this traps for empty lines
      lines << line
      }

      you need to set up instance variables, @v_a etc, so they get referenced outside of the {} block, plain v_a won't be referenced outside and would therefore be inaccessible...

      v='@v_a'
      lines.each{|e|
      eval("#{v}='#{e}'")
      v.next!
      }

      Call

      draw_object
      }

      def draw_object

      #***************************************************************************
      #delete previous model

      model = Sketchup.active_model
      entities = model.active_entities
      entities.to_a.each { | entity| entity.erase! }

      #***************************************************************************

      set start default values for MENUE 1-4

      width          =  @v_a
      lwidthplus     =  @v_b
      rwidthplus     =  @v_c
      
      #width          = 500
      #lwidthplus     = 10
      #rwidthplus     = 10
      
      stairs         = 10      
      run            = 30
      rise           = 13
      thickness      = 3
      fill           = 4
      overlap        = 6
      il             = 6
      rc             = 3
      re             = 0
      stepdevidex    = 1
      
      sl             = 100
      sr             = 100
      mr             = 80
      pmod           = 3
      pradius        = 15
      thradius       = 20
      mhradius       = 4
      lines          = 4
      ro             = 4
      rol            = 5
      ror            = 5
      
      wangenbreitel  = 30
      wangenhoehel   = 10
      wangeslopel    = 45.0
      rampoffsetl    = 50
      rampoffsetly   = 30
      rampoffsetlz   = 99.0
      
      wangenbreiter  = 30
      wangenhoeher   = 10
      wangesloper    = 45.0
      rampoffsetr    = 50
      rampoffsetry   = 30
      rampoffsetrz   = 99.0
      

      #***************************************************************************

      thank you very very much for your time and helping!
      STAN

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Load text file and assign to variables

      hi tig and hello again,
      this is great and worked inmedialtely in the ruby console.
      so:
      i counts the lines
      line gets the value per line

      maybe a small tip (i still think too much in macro-basic)

      when i retrieve those values form the file,
      this syntax makes problems:

      assign variables from file (like reading an array from a loop)

      a = line[1]
      b = line[2]
      c = line[3]

      how could i build an array within the import routine? i tried so many ways and can#t get it...
      thanx stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • Load text file and assign to variables

      hi,
      when i reopen my text-file with parameters (1 parameter per line)

      by


      count = 0

      File.open('C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/zf/partemp2.txt', 'r') do |f1|
      while line = f1.gets
      puts line

      end  
      

      end


      i can see the values listed in the console // OK

      BUT

      when i try


      count = 0

      File.open('C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/zf/partemp2.txt', 'r') do |f1|
      while line = f1.gets
      puts line

      value[count]=f1.gets
            count = count + 1
      end  
      

      end


      it does not work

      ma question is:

      how can i assign the result of f1.gets to a row of variables in this loop?

      thanx you

      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Best way to delete entities

      yes sir,
      it works perfectly. so this deletes the master-component.
      i just wonder, how then can be identified the ,daughter'-components.

      per x,y,z ?

      anyway, thank you very much for this solution.
      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • RE: Best way to delete entities

      hi tig,
      probably i have a mistake in the component-description.

      i define a master component (two tubes).

      #DEF PFOSTEN MASTER COMPONENT

         model = Sketchup.active_model
         entities = model.active_entities  
      
         pfm1 = [0, 0, 0+thickness]
         pfm2 = [0, 0, 0+thickness+sl-((5/faktor)/100)]
         pfm3 = [0, 0, 0+thickness+sl-((5/faktor)/100)]
         pfm4 = [0, 0, 0+thickness+sl]        
         
         group = entities.add_group
         
         entities2 = group.entities
                
         new_line = entities2.add_line pfm1, pfm2
                      length = new_line.length
                      centerpoint = pfm1
                      vector = pfm2
                      vector = vector.normalize!
                       
                      edges = entities2.add_circle centerpoint, vector, pradius
                      kreis = entities2.add_face edges
                      kreis.pushpull length
           
           
         new_line2 = entities2.add_line pfm3, pfm4
                      length2 = new_line2.length 
                      centerpoint2 = pfm4
         	            vector2 = pfm3
                  vector2 = vector.normalize!
      		                     
      	    edges2 = entities2.add_circle centerpoint2, vector2, pradius/3
      	    kreis2 = entities2.add_face edges2
                      kreis2.pushpull -length2
                      
         masterpfostenl = group.to_component
      

      and then copy it to different places to ponits pf1,2,3:

      componentinstance =
      entities.add_instance(masterpfostenl.definition, pf1)
      componentinstance =
      entities.add_instance(masterpfostenr.definition, pf3)
      componentinstance =
      entities.add_instance(mittelpfostenm.definition, pf5)

      after all components are placed, i will try the

      defn.instances.first.erase! (have still to find out, how to point the right "instances-group"

      thanx
      stan

      posted in Developers' Forum
      artmusicstudioA
      artmusicstudio
    • 1 / 1