sketchucation logo sketchucation
    • Login
    1. Home
    2. eneroth3
    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 5
    • Posts 195
    • Groups 2

    Posts

    Recent Best Controversial
    • RE: Eneroth Townhouse System

      @jql said:

      Eneroth, can we create our own templates?

      Yes! All the templates hipped with the extension are created with the tools included. Some instructions are included under Extensions > Eneroth Townhouse System > Template Editing > Documentation. I migth also record an example video if I find the time.

      If you have any questions or if anything is confusing, feel free to post about it so I can answer and document it better.

      posted in Plugins
      eneroth3E
      eneroth3
    • RE: Eneroth Townhouse System

      My Townhouse plugin is now updated.

      This is a big release with several improvements to how buildings can be drawn.

      Link Preview Image
      SketchUp Extension Warehouse

      Your library of custom third-party extensions created to optimize your SketchUp workflow.

      favicon

      (extensions.sketchup.com)

      [youtube:2oxuf9sx]http://www.youtube.com/watch?v=nKlRHrDYC5k[/youtube:2oxuf9sx]

      Previously the elements on each facade could only be evenly spread across it. Now users can replace specific elements from Building Properties, e.g. a specific window by a door. Some replacements can even take up multiple slots, e.g. a wide bay window.

      There's also a gable feature that allows the user to add pre-drawn parts to the short sides of the building. This is typically used to replace the firewall with a facade but can also be used for side risalits/avant-corps or for a rear wing as shown in the video.

      Finally there's a corner feature that can be used e..g to add corner turrets.

      Enjoy!

      posted in Plugins
      eneroth3E
      eneroth3
    • RE: Eneroth Townhouse System

      2016-07-07_16h23_55.png
      Here's a screenshot from the upcoming version. The new replacement method finally allows for some more complex buildings with entrances, bay windows, balconies and other elements that brings life o the facades.

      2016-07-07_16h26_50.png

      This is how the UI works.

      posted in Plugins
      eneroth3E
      eneroth3
    • RE: Eneroth Townhouse System

      The most recent version of the plugin is now live on the Extension Warehouse. Enjoy! http://extensions.sketchup.com/en/node/2341

      posted in Plugins
      eneroth3E
      eneroth3
    • RE: Eneroth Townhouse System

      As usual it's the Sketchucation forum that just doesn't work properly. The link I've written and the one I see when trying to edit the post is correct. However the link shown in the saved post goes to an internal page, probably to save statistics or something, where users are supposed to be redirect to the actual location. That script replaces the "+" sign with "#%20" because URL encoding and decoding doesn't match up resulting in a faulty link.

      Simply put, a bug on Sketchucation's side prevent the link from working even though it's a correct link. Try instead just copying this to your addressbar:

      https://plus.google.com/+ChristinaEneroth/posts/J182prPzNhs?pid=6293120779793843890&oid=110985781685543511443
      
      posted in Plugins
      eneroth3E
      eneroth3
    • RE: Eneroth Townhouse System

      A new update will soon be released. The potentially biggest new feature is how components and groups now can cut openings onto multiple faces as the ground floor windows in this video.

      https://plus.google.com/+ChristinaEneroth/posts/J182prPzNhs?pid=6293120779793843890%26amp;oid=110985781685543511443

      The next release will hopefully have a way to replace certain groups/components, e.g. a row (or is it called a line? or axis?) of windows to another type of windows or balconies as in the image Dean shared previously in this thread.

      posted in Plugins
      eneroth3E
      eneroth3
    • RE: [Code] Material picker

      This was a quite sloppy made proof of concept.

      In my current big project I use Gem::Version to check compare versions witch supports minor releases too. However to_i seems simpler when only comparing mayor versions so I might use that instead.

      Gem;;Version.new("2.1.2.4") > Gem;;Version.new("2.1.37")
      

      The restyled material buttons looks much better! The background color looks a little dark though. I usually use the values defined by the system. It has been deprecated in css3 specification but all browsers I've tried still supports it.

      Link Preview Image
      How to Use Operating System Styles in CSS โ€” SitePoint

      Read How to Use Operating System Styles in CSS and learn with SitePoint. Our web development and design tutorials, courses, and books will teach you HTML, CSS, JavaScript, PHP, Python, and more.

      favicon

      (www.sitepoint.com)

      Also a button should have the default cursor and not the pointer.

      Regarding the pipe assignment a ||= b does not mean a = a || b. The later raises an error when used on for class variables while the former doesn't. This article explains ||= more: http://www.rubyinside.com/what-rubys-double-pipe-or-equals-really-does-5488.html.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: [Code] Skew Transformation from axes

      @fredo6 said:

      ...and there is the magic formula by thomthom to check if two faces are coplanar (actually have parallel planes)

      face1.normal % face2.normal > 0.9999999991

      Fredo

      That's a nice one! When making my upright extruder I first tried the samedirection? method but it has some issues with the precision and see faces as co-planar sometimes when they aren't (just as the built in Soften Edges feature). Instead I looped the vertices on one face and used classify_point on the other face to see if any vertex position were considered not on plane. In the future I'll use this instead!

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: [Code] Skew Transformation from axes

      @fredo6 said:

      Thanks for posting. Good to know. I think I may have come across this case some time ago, but did not think of encapsulate it as a Transformation, which is an elegant solution.

      One small remark: you can check the orientation of 2 vectors by
      (xaxis*yaxis) % zaxis > 0
      which is equivalent, but faster than
      xaxis*yaxis).angle_between(zaxis) < 90.degrees

      Fredo

      Thanks!

      I had the feeling there had to be a more idiomatic way but didn't know it. It's at times like these I wish I had studied more math. There is no math at my school of architecture despite it being a part of the faculty of engineering at the university ๐Ÿ˜• . All I know about cross products and matrices have I learned by making plugins and I don't think I've ever used a dot product before ๐Ÿ˜ฒ .

      Well, at least I'm making progress. Before I even know of cross multiplication I used to offset the origin point in one axis and apply a 90 degree rotation transformation using the other axis to get a new point that I then could subtract the origin from to get a perpendicular vector. ๐Ÿ˜›

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • [Code] Material picker

      Hi all

      I've experimented with this material picker interface mimicking the behavior the color and pattern picker in layout. It's not entirely finished and I don't know if I'll use it myself so I thought I could just as well share it here and see if anyone has any use of it.

      Similarly to in Layout you first click a button in the dialog to start pick a material. Then the material browser opens and fetches the clicked materials back to the dialog until the dialog is closed.

      One quite mayor difference from the Layout pikers is how they bring the user's attention to the relevant panel by changing the color of its title bar. There's no such feature in SU so if the material browser is already opened it's not very clear what the user is supposed to do.

      Also I'm not 100% sure the material browser opens up at all on Mac, especially in older SU versions, since I can't test it myself. On Windows the code should work from SU 2015.

      Note: If the script is not loaded on Sketchup start a model must then be opened or a new model created for the observers to kick in.

      To test the example dialog run "MaterialSelectorTest.example".

      # UI for picking material, typically used for web dialogs.
      # Behavior inspired by Layout color or pattern selection.
      #
      # NOTE; When loading this example from console, not on Sketchup start, a model
      # must be opened or a new model created for observer to be initialized.
      #
      # To test dialog, run "MaterialSelectorTest.example".
      
      
      module MaterialSelectorTest
      
        # Interface for picking material from material browser.
        class MaterialSelector
      
          # Block to call when a material is selected.
          # TODO; store blocks as hash indexed by calling Model to function better in multi document view?
          @@callback = nil
      
          # Public; Open the material browser to let user choose a material.
          # Typically called when user clicks a button for making material input in
          # web dialog.
          #
          # old_material - Material to be selected when material browser starts
          #                or nil to not select any specific material in browser
          #                (default; nil)
          #
          # Yields Material whenever a material is selected.
          #
          # Returns nothing.
          def self.pick_material(old_material = nil, &callback)
          
            # Disable callback if any so current material first can be set to
            # old_material.
            @@callback = nil
            
            Sketchup.active_model.materials.current = old_material if old_material
            self.open_material_inspector
            @@callback = callback
            
            nil
            
          end
          
          # Public; Stop executing callback when materials are selected.
          # Typically called when the web dialog containing the material selection
          # input is closed.
          #
          # returns nothing.
          def self.done_picking_material
          
            @@callback = nil
            
            # REVIEW; If possible, maybe reset material inspector view state to what
            # it was before calling select_material.
            
            nil
            
          end
          
          # Internal; Open the material inspector.
          def self.open_material_inspector
          
            # TODO; Look up how these function on MAC.
            # TODO; If material browser is already opened it should somehow be focused to attract the user's attention.
            if Sketchup.version >= "16" # REVIEW; won't work for 1 or 3 digit mayor version numbers
              # In 2015 this toggles the material browser instead of showing it.
              UI.show_inspector "Materials"
            elsif Sketchup.platform == ;platform_win
              # Windows only for opening the inspector.
              Sketchup.send_action 21074
            else
              # Select paint bucket tool.
              # Has the drawback that the tool is selected.
              Sketchup.send_action "selectPaintTool"
            end
            
          end
          
          # Observer interface.  
          
          # Internal; Current material has changed.
          def self.onMaterialSetCurrent(clicked_material)
                
            @@callback.call(clicked_material) if @@callback
            
          end
          
          # TODO; If such an observer is ever implemented, implement this.
          # Internal; Material inspector was closed
          def self.onClosingMaterialInspector
          
            @@callback = nil
            
          end
      
        end
        
        
        # Example web dialog.
        def self.example
        
          html = <<EOF
      <!DOCTYPE HTML>
      <html>
        <head>
          <meta charset="utf-8">
          <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
          <title>TITLE</title>
          <script>
            function pickMaterial(inputId) {
              window.location= 'skp;pick_material@' + inputId;
            }
            function setPreview(inputId, colorString) {
              var input = document.getElementById(inputId);
              var span = input.getElementsByTagName('span')[0];
              span.style.backgroundColor = colorString;
            }
          </script>
          <style>
            button span {
              display; inline-block;
              width; 22px;
              height; 22px;
            }
          </style>
        </head>
        <body>
          <p>
            Example material picker. Behaviour is copied from color picking in Layout.
            Click a material button in this dialog and the material browser lets you
            select a material.
          </p>
          <label>
            Material 1;
            <button type="button" id="material1" onclick="pickMaterial(this.id)"><span></span></button>
          </label>
          <br />
          <label>
            Material 2;
            <button type="button" id="material2" onclick="pickMaterial(this.id)"><span></span></button>
          </label>
          <p>
            For this example only the material color is previewed in the button, not
            the texture.
          </p>
        </body>
      </html>
      EOF
      
          dlg = UI;;WebDialog.new(
            "Pick Material Example",
            false,
            "ene_pick_material",
            500,
            400,
            100,
            100,
            false
          )
          dlg.navigation_buttons_enabled = false
          dlg.set_background_color dlg.get_default_dialog_color
          dlg.set_html html
          Sketchup.platform == ;platform_win ? dlg.show ; dlg.show_modal
      
          # Start picking material.
          dlg.add_action_callback("pick_material") do |_, input_id|
          
            MaterialSelector.pick_material(nil) do |new_material|
            
              # Set material preview in dialog.
              # For this example only the color is used but texture could be saved to
              # file using write_thumbnail.
              if new_material
                color = new_material.color
                color_string = "rgb(#{color.red},#{color.green},#{color.blue})"
              else
                # When material is an image similar to the one inside Sketchup showing
                # front and back color could be used.
                color_string = "transparent"
              end
              js = "setPreview('#{input_id}', '#{color_string}');"
              dlg.execute_script js
              
              # Save the given material reference and the relation to the given
              # input_id.
              puts "Material #{new_material} was selected for input #{input_id}."
              
            end
          
          end
          
          # Stop picking material.
          dlg.set_on_close do
          
            MaterialSelector.done_picking_material
            
          end
          
        end
      
      
        # Observer stuff.
        class MyMaterialsObserver < Sketchup;;MaterialsObserver
      
          def onMaterialSetCurrent(_, material)
          
            MaterialSelector.onMaterialSetCurrent material
            
          end
         
        end
      
        class MyAppObserver < Sketchup;;AppObserver
      
          def expectsStartupModelNotifications
          
            true
            
          end
          
          def onNewModel(model)
          
            model.materials.add_observer MyMaterialsObserver.new
            
          end
          
          def onOpenModel(model)
          
            model.materials.add_observer MyMaterialsObserver.new
            
          end
      
        end
      
        @@app_observer ||= nil
        unless @@app_observer
          
          @@app_observer = MyAppObserver.new
          Sketchup.add_observer @@app_observer
          
        end
      
      end
      
      
      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: [Code] Skew Transformation from axes

      Thanks TIG!

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • [Code] Skew Transformation from axes

      In some of my plugins I've needed skewed Transformations (where all axes aren't perpendicular to each other) and so far just created a Transformation from an array where I needed it. However now I finally did what a programmer is supposed to do and made a separate method for it. Thought you guys could have use for it too!

      Note that enable_skewing is by default false and must be set to true for the method not to generate identical result as the native Transformation.axes.

      # Creates a Transformation defined by an origin and three axes.
      # Unlike native Transformation.axes this also allows optional scaling and
      # skewing to be enabled.
      #
      # origin         - The origin as Point3d.
      # xaxis          - The X axis as Vector3d.
      # yaxis          - The X axis as Vector3d.
      # zaxis          - The X axis as Vector3d.
      # enable_scaling - Use lengths of axes for scale (default; false).
      # enable_skewing - Do not force axes to be perpendicular (default; false).
      #
      # Returns a Transformation.
      def transformation_axes(origin, xaxis, yaxis, zaxis, enable_scaling = false, enable_skewing = false)
      
        if xaxis.parallel?(yaxis) || yaxis.parallel?(zaxis) || zaxis.parallel?(xaxis)
          raise ArgumentError, "Axes must not be parallel."
        end
        
        # Create new Vectors instead of manipulating existing.
        xaxis = xaxis.clone
        yaxis = yaxis.clone
        zaxis = zaxis.clone
      
        # Mimic behavior of native Transformation.axes when skewing is disabled.
        # Behavior found through trial and error.
        unless enable_skewing
          if (xaxis*yaxis).angle_between(zaxis) < 90.degrees
            # Right handed coordinate system.
            yaxis = zaxis*xaxis
            xaxis = yaxis*zaxis
          else
            # Left handed coordinate system.
            xaxis = zaxis*yaxis
            yaxis = xaxis*zaxis
          end
        end
      
        unless enable_scaling
          xaxis.normalize!
          yaxis.normalize!
          zaxis.normalize!
        end
        
        Geom;;Transformation.new([
          xaxis.x, xaxis.y, xaxis.z, 0,
          yaxis.x, yaxis.y, yaxis.z, 0,
          zaxis.x, zaxis.y, zaxis.z, 0,
          origin.x,  origin.y,  origin.z,  1,
        ])
      
      end
      

      EDIT: Since Sketchucation can't display white spaces in code properly I attach the script as a file too.


      transformation axes.rb

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: [Plugin] Eneroth Railroad System (v 0.1.21)

      @ralle said:

      Hallo Eneroth.
      Now that I'm back from a bad cold the last weeks, i'm follow your instructions.
      But without a good result, with exeption, SU doesn't crash anymore after useing
      the streets. How ever, i don't have any primitves of the streets, only the leadinglines.

      Greetings ..

      Ralph

      That's odd. Can you send me a zipped copy of the streets' track folders?

      posted in Plugins
      eneroth3E
      eneroth3
    • RE: [Plugin] Eneroth Railroad System (v 0.1.21)

      Finally there's a new version published. Version 0.1.21 adds back the translation support. It also has a completely new feature for listing certain parts of structure (for now the pillars of the JPods structures) and lets users reposition them accurately. This feature is found under Extensions > Eneroth Plugin System > Structure Part Info. There's also a security notification added when models load if they contain potentially harmful executable code used by the balise feature. Finally there are some bugfixes regarding how missing templates are handled.

      Download

      posted in Plugins
      eneroth3E
      eneroth3
    • RE: Axis and geolocation

      When using geo-location in my hometown there's a difference between Google Maps north and green axis by about 1,47 degrees. When planning infrastructure in a city each meter is important and for a physically big model that angle sets thing off quite far.

      If I've understood everything correctly the angle interpreted as clockwise in parts of the program and counter clockwise in other parts which means all latitudes and longitudes from a model are off by twice that angle.

      posted in Newbie Forum
      eneroth3E
      eneroth3
    • RE: Axis and geolocation

      After looking into this all more it seems as the latitude and longitude from model.point_to_utm(point).to_latlong depends on the solar north value, not the GeoReferenceNorthAngle attribute. However it seems as the angle is measured in the wrong direction.

      The point other than origin in the first 2 images should have the same latitude and longitude since both the point and solar north are rotated 45 degrees cw. However the point actually has the same latitude and longitude in the first and third image where the point is rotaded 45 degrees cw and solar north 45 degrees ccw.

      I'll contact the devs about this, maybe they have seen it before.


      1.


      2.


      3.

      posted in Newbie Forum
      eneroth3E
      eneroth3
    • RE: Axis and geolocation

      I have no idea, that's what confuses me now. I thought geodetic was the one being used but I'm not sure anymore. What's set as solar north and written to the GeoReferenceNorthAngle attribute of the GeoReference dictionary of the model is the angle between green axis and what's upwards on Google maps anyway. Changing the attribute or solar north to another angle has no effect on the positioning of new google maps snapshot when going to File > Geo-location > Add more imagery. ๐Ÿ˜ฎ ๐Ÿ˜• ๐Ÿ˜ฎ

      posted in Newbie Forum
      eneroth3E
      eneroth3
    • RE: Axis and geolocation

      Actually green axis isn't north when geo-loating (at least not in Sweden) ๐Ÿ˜• .

      Can anyone tell me why this is? I'm making a plugin where users should be able to through a dialog move objects along the cardinal directions so its very important for the plugin to know exact directions. It seems as if the solar north angle is correct but I really don't understand why it should be required to be taken into account (unless the user manually changes it). Does anyone know if this is by design or a bug?


      y_not_north.png

      posted in Newbie Forum
      eneroth3E
      eneroth3
    • RE: Eneroth Townhouse System

      Something like this is planned but I haven't had the time to work on it yet.

      posted in Plugins
      eneroth3E
      eneroth3
    • RE: Adding attributes help

      @driven said:

      @unknownuser said:

      'he's good bad', but he ain't evil!

      I tend to agree with this**[anchor= goto=http://www.infoq.com/articles/eval-options-in-ruby:13hbt2pf]article[/anchor:13hbt2pf]**...

      eval has it's uses, that's why it's there...
      john

      There are cases where it's fine to use. I use it myself in my attribute editor plugin for instance to let people assign things such as 1.m or Sketchup.active_model.selection.first.length to an attribute. However executing code saved in a model opens up for people to forge an evil model that causes the code to be executed without the user knowing about it.

      Also arrays are allowed and can be used instead of hashes when it comes to just serializing data.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • 1
    • 2
    • 3
    • 4
    • 5
    • 9
    • 10
    • 2 / 10