sketchucation logo sketchucation
    • Login
    1. Home
    2. kiesewetter
    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 15
    • Posts 44
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: Deleting a text

      oh, ok, great. thank you!

      posted in Developers' Forum
      K
      kiesewetter
    • Deleting a text

      hallo!

      i tried to delete that text-object:

      taganzeige=ents.add_text "Tag"+status.woche.to_s, [0,0,0]
      

      with the following line:

      taganzeige.erase
      

      but it didn't work...

      how do i have to delete an entity-object?

      thanks for your time.
      tim

      posted in Developers' Forum
      K
      kiesewetter
    • Opening the ruby console

      Hallo!

      Which command opens the ruby console?

      Thanks for your time.
      Bye Tim

      posted in Developers' Forum
      K
      kiesewetter
    • RE: Array doesn't work...

      Works! 😄
      Thank you!

      posted in Developers' Forum
      K
      kiesewetter
    • Array doesn't work...

      Hallo!
      You might laugh because of that post, but I'm not able to find the reason why it doesn't work...

      I just want to create an infobox and safe the input to some variables...

      Here is the code and Sketchup's comment in the debugger:

      prompts = ["Bildhöhe", "Bildbreite", "Bilder pro Sekunde", "Filmdauer in Sekunden", "Ausgabename"] 
      default = [  "800",         "800",           "25",                  "60",             "Ablauf" ]
      aufnahmebox = UI.inputbox prompts, default, "Ablaufsimulation mit statischer Ansicht"
      hoehe = aufnahmebox[0].to_i
      breite= aufnahmebox[1].to_i
      fps=aufnahmebox[2].to_i
      dauer = aufnahmebox[3].to_i
      name = aufnahmebox[4]
      

      load "C:/Users/tim/Desktop/array.rb"
      Error: #<SyntaxError: (eval):4:in `load': C:/Users/tim/Desktop/array.rb:1: syntax error, unexpected tCONSTANT, expecting ']'
      ...pts = ["Bildhöhe", "Bildbreite", "Bilder pro Sekunde", "Film...
      ^
      C:/Users/tim/Desktop/array.rb:1: syntax error, unexpected tCONSTANT, expecting $end
      ...ldhöhe", "Bildbreite", "Bilder pro Sekunde", "Filmdauer in S...
      ^>
      (eval):4
      (eval):4

      Thanks for your time.
      Tim

      posted in Developers' Forum
      K
      kiesewetter
    • RE: Moving 3d text

      works 😄 . thanks a lot.

      posted in Developers' Forum
      K
      kiesewetter
    • RE: Moving 3d text

      The translation should be done with the elments of the array @bauabschnitte exept the first one.
      So y_text is set to 0 at the beginning an gets raised every time the code passes the "each" part.

      Here is the error-message that appears in sketchup every time I load the code:

      Error: #<TypeError: C:/Program Files/Google/Google SketchUp 8/Plugins/klasse_ausgabe.rb:253:in transform_entities': wrong argument type (expected Sketchup::Entity)> C:/Program Files/Google/Google SketchUp 8/Plugins/klasse_ausgabe.rb:253 C:/Program Files/Google/Google SketchUp 8/Plugins/klasse_ausgabe.rb:253:in balkendiagramm'
      C:/Program Files/Google/Google SketchUp 8/Plugins/klasse_ausgabe.rb:249:in each' C:/Program Files/Google/Google SketchUp 8/Plugins/klasse_ausgabe.rb:249:in balkendiagramm'
      C:/Users/tim/Desktop/test_balkendiagramm.rb:5
      (eval):0:in `load'
      (eval):0

      The first 3d-text is created at the origin. So I don't know what to do.

      posted in Developers' Forum
      K
      kiesewetter
    • Moving 3d text

      Hallo!
      I'm trying to write a script that creates a list of 3d texts. One 3d text should be diplayed, then it should be moved (in negative y-direction), then the next 3d text should be created and so on.
      With my code the Translation of the text doesn't work.
      Here is the code:

      
      y_text=0
      zaehler=0 #counter
      textarray=[]
      @bauabschnitte.each{|b|
                           tr = Geom;;Transformation.new [0,y_text,0]
      		     anzeige =  b.getname #the text the should be displayed by the 3d text
                           textarray[zaehler]=ents.add_3d_text anzeige, TextAlignRight,"Arial",false,false,10,5,0,true,1
      		     ents.transform_entities tr, textarray[zaehler] #here the 3d text should be moved...
      		     y_text = y_text-15
      		     zaehler = zaehler+1
      		    }
      
      

      Thanks for your time.
      Tim

      posted in Developers' Forum
      K
      kiesewetter
    • RE: Checking wether material exists before declaring it

      Ok, great. thank you. I'll change it this weekend. Hope you have a nice one 😄
      Bye.
      Tim

      posted in Developers' Forum
      K
      kiesewetter
    • Checking wether material exists before declaring it

      Hallo!

      I want to declare a material in a method, but before it's declared it should checked wether the material already exists to avoid overloading the memory with tons of the same material. Here is the code i used but it doesn't work so far...

      
      def status_anzeigen 
        mod = Sketchup.active_model
        ents = mod.entities 
        sel = mod.selection 
        mats = mod.materials
        unless mats.include?("im_bau")
          bau_mat = mats.add "im_bau"
          bau_mat.color = [255,127,38] 
          fertig_mat = mats.add "fertig"
          fertig_mat.color = [211,211,211] 
          inplanung = mats.add"noch_nicht_angefangen"
          inplanung.color = [176,196,222]  
          inplanung.alpha = 0.3 
        end
      
      #and so on
      
      
      posted in Developers' Forum
      K
      kiesewetter
    • RE: Materials again

      it works. thanks a lot, once more 😄

      tommorow t'll try to declare the material in the constructor of the class anyway, to avoid putting all the trash in the memory.

      bye.

      tim

      posted in Developers' Forum
      K
      kiesewetter
    • RE: Materials again

      it was my mistake. the materials were declared in a tool as a local variable. every time the tool was invoken, the materials werde declared. so to the materials name was a number added, because the material already existed in the materials container. when you only once invoke the tool everything is fine. one more an it didn't work.

      is it possible to declare a material as a constant or to declare it with an "@" in a class to avoid that?

      posted in Developers' Forum
      K
      kiesewetter
    • Materials again

      me again...

      i don't know why, but the attribut "ablauf", "material" always receives a new value, even if the face's material is included in the array called invalid_material. i'll post the code, because i realy don't know how to fix it.

          
      ents.each{|e|
                if e.typename == "Face"
                   start = e.get_attribute "ablauf", "baubeginn"
                   ende = e.get_attribute "ablauf", "bauende"
                   if (e.material)
                     invalid_materials = ['bau_mat', 'fertig_mat', 'inplanung']
                     unless invalid_materials.include?( e.material.name )
                       mat_vorher = e.material.name
                       e.set_attribute("ablauf", "material", mat_vorher)
                     end
                   end
                           
                           
                if @woche.to_i >= start.to_i && @woche.to_i < ende.to_i
                  e.material = bau_mat
                end
                if @woche.to_i >= ende.to_i
                  e.material =fertig_mat
                end
                if @woche.to_i < start.to_i
                  e.material = inplanung
                end
             end
                           
              }
         
      
          #now the code that reloads the material
      
          def mat_back
             mod = Sketchup.active_model
             ents = mod.entities
             mats = mod.materials
             default_mat = mats.add "standardwert"
             default_mat.color = [50,250,50]
             ents.each{|e|
                        if e.typename == "Face"
                          if (e.get_attribute "ablauf", "material")
                            mat_temp=e.get_attribute "ablauf", "material"
                            e.material=mats[mat_temp]
                          else
                            e.material=default_mat
                          end
                        end
                       }
      
      
          end
      
      
      
      posted in Developers' Forum
      K
      kiesewetter
    • RE: Saving an reloading a material from an attribut

      me again...

      i don't know why, but the attribut "ablauf", "material" always receives a new value, even if the face's material is included in the array caled invalid_material. i'll post the code, because i realy don't know how to fix it.

      
      ents.each{|e|
                  if e.typename == "Face"
                       start = e.get_attribute "ablauf", "baubeginn"
                       ende = e.get_attribute "ablauf", "bauende"
                       if (e.material) 
                         invalid_materials = ['bau_mat', 'fertig_mat', 'inplanung']
                         unless invalid_materials.include?( e.material.name )
                           mat_vorher = e.material.name
                           e.set_attribute("ablauf", "material", mat_vorher)
                         end
                       end
                       
                       
                       if @woche.to_i >= start.to_i && @woche.to_i < ende.to_i 
                         e.material = bau_mat
                       end
                       if @woche.to_i >= ende.to_i 
                         e.material =fertig_mat
                       end
                       if @woche.to_i < start.to_i 
                         e.material = inplanung
                       end
                  end
                       
                 }
      end
      
      #now the code that reloads the material
      
      def mat_back 
         mod = Sketchup.active_model
         ents = mod.entities 
         mats = mod.materials
         default_mat = mats.add "standardwert"
         default_mat.color = [50,250,50] 
         ents.each{|e|
                        if e.typename == "Face"
                          if (e.get_attribute "ablauf", "material")
                           mat_temp=e.get_attribute "ablauf", "material"
                           e.material=mats[mat_temp]
                          else
                           e.material=default_mat 
                          end
                        end
                       }
      
      
      end
      
      
      
      posted in Developers' Forum
      K
      kiesewetter
    • RE: Saving an reloading a material from an attribut

      thank you so much.

      posted in Developers' Forum
      K
      kiesewetter
    • RE: Saving an reloading a material from an attribut

      hallo again!
      saving to an attribute and reloading works 😄

      but now another problems appears. i only want the materials name to be stored in the attribute if it is not the name of one of the materials bau_mat, fertig_mat or inplanung.

      i tried to realise it with the following code, but it seems to be stored every time, even the assigned material is one of the before mentioned:

      
       if e.material.name != bau_mat.name && e.material.name != fertig_mat.name && e.material.name != inplanung.name
                mat_vorher = e.material.name
                e.set_attribute "ablauf", "material", mat_vorher
       end
      
      
      
      posted in Developers' Forum
      K
      kiesewetter
    • RE: Saving an reloading a material from an attribut

      oh, ok, when i wrote my last post yours wasn't uploaded. i'll test it tommorrow because it's meanwhile hard to hold the eyes open. thanks once more for the great help.
      good night.
      tim

      posted in Developers' Forum
      K
      kiesewetter
    • RE: Saving an reloading a material from an attribut

      first of all i got to thank you fpr the time youre spending.

      i wrote the last script to test wheter it is possible to assign a material to an entitiy in that way. i wanted to execute it with only one face selected that has a material (the one looking like wood). the name of the material should be saved in the variable mat.

      that should be realised with

      sel.each{|e|
      mat=e.material.display_name
      }

      after that i wanted to assigne every entity in the model with the same material with that part of the code

      ents.each{|e|
      e.material = mats[mat]
      }

      i still don't know how to acces a material, to save an reload it. using the diplay_name and saving it as an attribut didn't work so far.

      posted in Developers' Forum
      K
      kiesewetter
    • RE: Saving an reloading a material from an attribut

      i used some of the materials looking like wood. do they belong to the default materials that return nil?

      another opportunity could be to save the whole model in the script, then to do something in the script an after that to load the old version that was saved before.

      posted in Developers' Forum
      K
      kiesewetter
    • RE: Saving an reloading a material from an attribut

      ok, i assigned a material to a face with the tool in sketchup that is invoken by the icon with the color bucket. after that i loaded a script with the following code (only the face with the material was selected)

      <span class="syntaxdefault">mod&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br />ents&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">mod</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">entities&nbsp;<br />sel&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">mod</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">selection<br />mats&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">mod</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">materials<br />mat</span><span class="syntaxkeyword">=</span><span class="syntaxstring">""<br /><br /></span><span class="syntaxdefault">sel</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">|<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">mat</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">material</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">display_name<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">}<br /><br /><br /></span><span class="syntaxdefault">ents</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each</span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">|<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">material&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">mats</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">mat</span><span class="syntaxkeyword">]<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;</span><span class="syntaxdefault"></span>
      

      the debugger says: #<NoMethodError: undefined method `display_name' for nil:NilClass>

      somehow the material doesn't seem to stored in the materials array...
      that can't be true, or?

      posted in Developers' Forum
      K
      kiesewetter
    • 1
    • 2
    • 3
    • 2 / 3