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

    Posts

    Recent Best Controversial
    • How to get transformation.origin of a internal component

      We need to measure the [x,y,z] beetween the red’s circle’s marked in the picture.
      How we need to do that? We have 2 components, one inside another. We need to know how to measure the distance of the x,y,z axis of the inside red block to the zero ground of the model. But to do that, we CAN’T add the values of the big gray box and the values of the red block inside, because we’re going to have too many elements one inside another, and calculate all this can be slow and it’s not a good solution.

      http://us.media.gabster.com.br/Transformation.Origin_of_a_Internal_Componente.png

      ` Sketchup.active_model.entities.each{|ent|
      puts "BigBox #{ent.transformation.origin.to_s}" if ent.is_a?(Sketchup::ComponentInstance) }

      Sketchup.active_model.entities.each{ |ent|
      puts ent.definition.entities.each{ |e|
      puts "RedBox #{e.transformation.origin.to_s}" if e.is_a?(Sketchup::ComponentInstance)
      } if ent.is_a?(Sketchup::ComponentInstance) }`

      posted in Developers' Forum
      romuloigorR
      romuloigor
    • RE: How to count duplicates hash itens in Ruby

      Run this code in Ruby 1.8.5 ( Ruby Console in Sketchup 8 )

      h = Hash.new 0;
      product_list.each {|p| h[p] += 1};
      product_list_result = h.keys.map{|k| k["count"] = h[k]; k};
      

      Result:

      
      [{"x"=>300, "y"=>100, "z"=>18, "product"=>1, "count"=>1},
       {"x"=>200, "y"=>100, "z"=>18, "product"=>1, "count"=>1},
       {"x"=>100, "y"=>100, "z"=>18, "product"=>2, "count"=>1},
       {"x"=>300, "y"=>100, "z"=>18, "product"=>2, "count"=>1},
       {"x"=>200, "y"=>100, "z"=>18, "product"=>1, "count"=>1},
       {"x"=>100, "y"=>100, "z"=>18, "product"=>3, "count"=>1},
       {"x"=>100, "y"=>100, "z"=>18, "product"=>2, "count"=>1}]
      
      

      Run this code in Ruby 1.8.7 ( irb in OSX Terminal )
      Result:

      
      [{"product"=>1, "z"=>18, "y"=>100, "x"=>200, "count"=>2},
       {"product"=>3, "z"=>18, "y"=>100, "x"=>100, "count"=>1},
       {"product"=>2, "z"=>18, "y"=>100, "x"=>100, "count"=>2},
       {"product"=>1, "z"=>18, "y"=>100, "x"=>300, "count"=>1},
       {"product"=>2, "z"=>18, "y"=>100, "x"=>300, "count"=>1}]
      
      
      posted in Developers' Forum
      romuloigorR
      romuloigor
    • RE: How to count duplicates hash itens in Ruby

      Run this code in Ruby 1.8.5 ( Ruby Console in Sketchup 8 )

       product_list.dup.group_by { |h| h }.each_value.map do |value| 
        value.first.tap { |hash| hash['count'] = value.count }
      end
      Error; #<NoMethodError; undefined method `group_by' for #<Array;0x12599cd4>>
      (eval);8
      

      Run this code in Ruby 1.8.7 ( irb in OSX Terminal )

      [{"count"=>2, "z"=>18, "y"=>100, "x"=>100, "product"=>2},
       {"count"=>1, "z"=>18, "y"=>100, "x"=>300, "product"=>1},
       {"count"=>2, "z"=>18, "y"=>100, "x"=>200, "product"=>1},
       {"count"=>1, "z"=>18, "y"=>100, "x"=>100, "product"=>3},
       {"count"=>1, "z"=>18, "y"=>100, "x"=>300, "product"=>2}]
      
      posted in Developers' Forum
      romuloigorR
      romuloigor
    • How to count duplicates hash itens in Ruby

      I need to count the duplicates, they need to be 100% identical to increase my count, but I can not use a nothing out of Ruby 1.8.5, this code will run inside a plugin in google sketchup

      
      product_list = [ 
       { "product" => 1, "x" => 200, "y" => 100, "z" => 18},
       { "product" => 1, "x" => 200, "y" => 100, "z" => 18},
       { "product" => 1, "x" => 300, "y" => 100, "z" => 18},
       { "product" => 2, "x" => 300, "y" => 100, "z" => 18},
       { "product" => 2, "x" => 100, "y" => 100, "z" => 18},
       { "product" => 2, "x" => 100, "y" => 100, "z" => 18},
       { "product" => 3, "x" => 100, "y" => 100, "z" => 18} ];
      
      product_list_result = product_list.count_duplicate();
      
      product_list_result = [
       { "product" => 1, "x" => 200, "y" => 100, "z" => 18, "count" = 2},
       { "product" => 1, "x" => 300, "y" => 100, "z" => 18, "count" = 1},
       { "product" => 2, "x" => 300, "y" => 100, "z" => 18, "count" = 1},
       { "product" => 2, "x" => 100, "y" => 100, "z" => 18, "count" = 2},
       { "product" => 3, "x" => 100, "y" => 100, "z" => 18, "count" = 1}
                            ];
      
      posted in Developers' Forum
      romuloigorR
      romuloigor
    • Tool Scale does not update dictionary. WHY? is Bug?

      Tool Scale does (
      http://sketchup.google.com/crimages/mod-ToolScaleLarge.png
      ) not update dictionary

      1 - Create a Dynamic Component "CUBE".
      2 - Update LenX value and Click "Apply" Button

      Result: Component set new value and Dictionary "dynamic_attributes" is updated.

      1 - Create a Dynamic Component "CUBE".
      2 - (
      http://sketchup.google.com/crimages/mod-ToolScaleLarge.png
      ) Tool Scale Component "CUBE" and Not Click in "Apply" Button

      Result: Component set new value and Dictionary "dynamic_attributes" is NOT updated. WHY?, is Bug?

      I get source code of Apply Button in "C:\Program Files\Google\Google SketchUp 8\Tools\DynamicComponents\js\configurator.js" line 389

      /**
       * Responds to requests (usually initiated via the UI) to apply any changes
       * made to the configuration panel so they appear in SketchUp.
       */
      cfg.doApply = function() {
        var key;
        var parts;
        var entityID;
        var attribute;
        var value;
        var noRedraw;
        var attributeCount = 0;
        var changes;
        var elem;
        var name;
      
        // Current field isn't always picked up if the user didn't tab out but
        // instead just hit return...so grab its value.
        if (su.isValid(elem = document.activeElement)) {
          name = elem.getAttribute('id') || elem.getAttribute('name');
          if (su.notEmpty(name) && (name != 'applyButton')) {
            // Force the blur of the currently selected element to ensure that
            // storeChanges for that value is fired.
            elem.blur();
          }
        }
      
        // If the changed value list doesn't have values then we can simply return.
        if (su.isEmpty(su.getKeys(cfg.changedValues))) {
          return;
        }
      
        // The changed values hash can carry the data to be serialized for
        // transmission over the bridge, we just need to include the entities.
        comp.pushAttributeSet(cfg.entityIds, cfg.changedValues);
        cfg.changedValues = {};
      
      };
      
      

      ![Create a Component "CUBE"](/uploads/imported_attachments/Lcr8_Scale_Bug_01.png "Create a Component "CUBE"")


      ![Update LenX value and Click "Apply" Button](/uploads/imported_attachments/s8DL_Scale_Bug_02.png "Update LenX value and Click "Apply" Button")


      ![Tool Scale Component "CUBE" and Not Click in "Apply" Button](/uploads/imported_attachments/4S7p_Scale_Bug_03.png "Tool Scale Component "CUBE" and Not Click in "Apply" Button")


      I get source code of Apply Button

      posted in SketchUp Bug Reporting sketchup
      romuloigorR
      romuloigor
    • RE: [Plugin] ComponentReporter++ v1.2

      TIG,
      The "full report" is generated by the menu File > Generate Report > CSV file ? ( Only SU 8 PRO ).
      [ How could I generate this report by ruby ?, And saving automatically in my custon directory, silently.]
      if you can not do the "full reporter", I use your ComponentReporter++v1.1, but the need for this option to export values ​​LenX, LenY and LenZ of dynamic component.
      [ Create a Dynamic Component and Call ComponentReporter++v1.1 and view output is not LenX, LenY and LenZ ... ]

         [ Layer ] - My dynamic component has 10 layers and a select in listbox in component options the Dynamic Component user will select a layer and all objects when exporting the model will be in csv file
      

      ( I do not use the option to export only selected ) always full export.

      
      inlist.each{|c|
      dname="'"+c.definition.name ... 
      LenX=c.lenx.to_s ???
      LenY=c.leny.to_s ???
      LenZ=c.lenz.to_s ???
      if c.layer
         layer="'"+c.layer
      end
      
      

      OK?

      [I can not speak english and do not know ruby, I speak portuguese and I know python.]

      posted in Plugins
      romuloigorR
      romuloigor
    • RE: [Plugin] ComponentReporter++ v1.2

      TIG, how could that do to ComponentReporter + + v1.1, export LenX, LenY and LenZ of a component, and the information if the Layer is visible or invisible?

      I await your help!

      posted in Plugins
      romuloigorR
      romuloigor
    • 1 / 1