sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [Plugin] SurfaceGen (0.9.0b) β€” 28 April 2012

    Scheduled Pinned Locked Moved Plugins
    69 Posts 25 Posters 60.1k Views 25 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      Diggsey
      last edited by Diggsey

      SurfaceGen v0.9 (Beta)

      SurfaceGen is a plugin which allows you to create surfaces from mathematical formulae. There are two modes supported:

      Function Mode
      The Z coordinates of points in a heightmap are specified as a function of X and Y. There can therefore only be one Z value per X, Y coordinate.


      http://i59.photobucket.com/albums/g314/diggsey/th_surfacegen.jpg

      Equation Mode
      An equation relating X, Y and Z is given. This mode can graph any 3D surface for which there is a formula, but may take slightly longer. The marching cubes algorithm (wow that one is a pain to implement!) is used to generate a surface around a 3D grid of data generated from the equation.


      http://i59.photobucket.com/albums/g314/diggsey/th_surfacegen3.jpg

      Instructions

      • Select the SurfaceGen tool from its toolbar.

      • Click to set one corner of the graph.

      • Click again to set the opposite corner on the same level.

      • Click a third time to set the height of the graph.

      • You can transform the resulting group without causing problems.

        http://i59.photobucket.com/albums/g314/diggsey/th_surfacegen2.jpg

      • After creating the graph and it becoming selected, the SurfaceGen Options window should appear.

      • Set the axis ranges, the SurfaceGen mode and enter an equation.

      • Choose if you want to show the graph boundary. This will make a semi-transparent box around the graph. The sides facing the camera will always be invisible as you rotate the camera allowing you to see the surface.

      • Choose if you want the graph to be smooth.

      • Click generate. This may take a few seconds, so be patient. It will happen asynchronously, so you should still be able to move the camera around.

      • You can set the surface material by using the paint bucket on the group. The surface will become the selected material.

      • Opening the group will cause the graph to turn into a normal group. The plugin will ask if you really want to do this before it actually happens.

      Install

      Download and extract the attached zip file to your plugins folder. Please remember this is still in beta! I want to hear about any problems you encounter!

      Update 0.6

      • Updated to work with SketchUp 6

      Update 0.7

      • Updated to be more compatible with Macs
        Now uses built in functions to locate resources and combine paths. Also uses WebDialog.show_modal on macs to get always-on-top behaviour.

      • Added more functions
        abs, min, max, clamp can now be used in an expression.

      • Allowed expressions in axis ranges
        You can now easily graph from -pi to pi etc.

      • More error checking
        You will be notified if an expression is invalid, and hopefully some useful information about why it was invalid will given.

      Update 0.7b

      • Added point validation to getExtents for the graph tool
        The ruby console shouldn't show any errors when drawing a new graph.

      Update 0.7c

      • Fixed expression parsing bug
        Previously, using the same function twice in a row didn't work: sqrt(sqrt(16)) due to the regex used. Now it does.

      Update 0.8

      • Changed use of pt units to px units in WebDialog
        The font should display at the same size in all browsers.

      • Now works from any directory
        Resources are looked for starting with the directory containing surfacegen.rb.

      • Can more easily change WebDialog size
        The width as well as the height are constants in surfacegen.rb

      Update 0.9

      • Increased speed
        Previously "eval" was used to evaluate the expression at each sample point, now it uses "eval" once to create a proc object which is called multiple times.

      surfacegen.zip

      1 Reply Last reply Reply Quote 0
      • mitcorbM Offline
        mitcorb
        last edited by

        Hi, Diggsey:
        This looks interesting. You are off to a good start.

        I take the slow, deliberate approach in my aimless wandering.

        1 Reply Last reply Reply Quote 0
        • D Offline
          d12dozr
          last edited by

          Diggsey, this is neat! I just started learning this week how to generate implicit surfaces using equations in Meshlab, and I've been importing them into SU - now I can do it all in Sketchup πŸ‘ πŸ‘ While I don't really understand the math, I just play around with equations and see what pops up.

          On that note, do you have any ideas I can use as starters/seed equations for generating neat surfaces? What kind of math would I need to brush up on to understand this stuff better?

          For now, I'm just playing, but I have dreams of making some beautiful math sculptures like Bathsheba Grossmanmakes.

          Here is a little test I did, using the settings shown in the screenshot.
          SurfaceGen.JPG

          Did I say thank you, Diggsey? πŸ˜„

          3D Printing with SketchUp Book
          http://goo.gl/f7ooYh

          1 Reply Last reply Reply Quote 0
          • D Offline
            d12dozr
            last edited by

            Heh, here's a truncated sphere, settings shown...this is fun! πŸ’š
            SurfaceGen2.JPG

            Some suggestions:
            -When switching to "Equation", change the default settings to something that will work just by pressing "Generate"
            -Add a random equation/function generator, perhaps using preset equations
            -Add an error message when the equation is invalid, pointing out why its invalid if possible

            Like Jean says, just ideas...

            3D Printing with SketchUp Book
            http://goo.gl/f7ooYh

            1 Reply Last reply Reply Quote 0
            • D Offline
              dedmin
              last edited by

              Diggsey, where have You been so far!! We need You! Keep up surprising Us! Thanks!

              1 Reply Last reply Reply Quote 0
              • D Offline
                d12dozr
                last edited by

                Here's a question for you...is there a way to make the SurfaceGen geometry look like the first Meshlab image? I'm using the same equation, and trying to get results like changing the voxel size in Meshlab, but changing the # of cells in SurfaceGen doesn't seem to have the same effect...am I doing something wrong?
                SurfaceGen1.JPG
                Voxel size 0.05
                Voxel size 0.01

                BTW, I like how the settings are saved for each generated surface!! β˜€

                3D Printing with SketchUp Book
                http://goo.gl/f7ooYh

                1 Reply Last reply Reply Quote 0
                • pilouP Offline
                  pilou
                  last edited by

                  ah very cool! 😎
                  Topmod and K3dSurf in a same place! πŸ‘
                  (you can take some formula from K3DSurf πŸ˜‰

                  @unknownuser said:

                  For now, I'm just playing, but I have dreams of making some beautiful math sculptures like Bathsheba Grossmanmakes.

                  Topmod above is perfect for that πŸ˜‰
                  by me πŸ˜„

                  http://forums.polyloop.net/imagehosting/1964703b3c059111.jpg

                  By Jotero

                  http://www.jotero.com/bilder/topmod/soccer_ball_jotero2007.jpg

                  Frenchy Pilou
                  Is beautiful that please without concept!
                  My Little site :)

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    d12dozr
                    last edited by

                    Great links, Pilou! Thank you πŸ‘ Nice work on the sculpture, too.

                    3D Printing with SketchUp Book
                    http://goo.gl/f7ooYh

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      Very nice plugin. πŸ‘

                      Thomas Thomassen β€” SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • pilouP Offline
                        pilou
                        last edited by

                        In the V6 don't works πŸ˜‰

                        @unknownuser said:

                        Error Loading File surfacegen.rb
                        cannot convert Hash into String

                        Works fine in the V7 πŸ˜‰
                        surfacegen00.jpg

                        Frenchy Pilou
                        Is beautiful that please without concept!
                        My Little site :)

                        1 Reply Last reply Reply Quote 0
                        • D Offline
                          Diggsey
                          last edited by

                          Thanks everyone who commented!

                          @d12dozr
                          I've no idea how to make such complicated structures as those ones you linked to, but you can get some interesting shapes by just mixing up a few of the built in functions:

                          sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, asinh, acosh, atanh, atan2, hypot, sqrt, cbrt, log, log2, log10, ln, exp

                          and constants:

                          e, pi

                          @unknownuser said:

                          When switching to "Equation", change the default settings to something that will work just by pressing "Generate"

                          I'll just make the default equation something that will work for both modes.

                          @unknownuser said:

                          Add a random equation/function generator, perhaps using preset equations

                          That could be interesting. Perhaps the user could choose a level of complexity and it would use that many operations.

                          @unknownuser said:

                          Add an error message when the equation is invalid, pointing out why its invalid if possible

                          Showing an error would be possible, but it might be difficult to point out where. It depends on how much information ruby gives me. For speed, the equation is converted into ruby code, so I can just eval it for each point instead of running my own interpretter.

                          @unknownuser said:

                          Here's a question for you...is there a way to make the SurfaceGen geometry look like the first Meshlab image?

                          I don't know exactly how Meshlab works internally, but it seems like the voxel size is equivalent to the range of values divided by the number of cells. ie:
                          voxelSize = (max-min)/cells

                          I'm surprised it should look so different though, just by changing the voxel size.

                          @Pilou
                          I've found the problem. It won't let me pass a hash to WebDialog.new.

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            @diggsey said:

                            @Pilou
                            I've found the problem. It won't let me pass a hash to WebDialog.new.

                            Additionally, SU6 only accepts one argument for model.start_operation.

                            I've used this wrapper:

                            <span class="syntaxdefault"><br />def&nbsp;self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_operation</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">name</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">model&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br />&nbsp;&nbsp;</span><span class="syntaxkeyword">if&nbsp;</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">version</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">split</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'.'</span><span class="syntaxkeyword">)[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">to_i&nbsp;</span><span class="syntaxkeyword">>=&nbsp;</span><span class="syntaxdefault">7<br />&nbsp;&nbsp;&nbsp;&nbsp;model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_operation</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">name</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">true</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_operation</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">name</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">end<br />end<br /></span>
                            

                            The operation will run slower under SU6 - but at least it runs.

                            Thomas Thomassen β€” SketchUp Monkey & Coding addict
                            List of my plugins and link to the CookieWare fund

                            1 Reply Last reply Reply Quote 0
                            • D Offline
                              Diggsey
                              last edited by

                              Thanks thomthom, but I've just used a rescue statement so it will fallback on the older version if the newer one fails. The first post has the updated version which works with v6.

                              1 Reply Last reply Reply Quote 0
                              • TIGT Offline
                                TIG Moderator
                                last edited by

                                There are also a few error-messages appearing in the Ruby Console that needs traps or begin/rescue forms [e.g. after you explode a special group]...
                                Some of them relate to your 'recurve' too...
                                But it's a neat tool πŸ˜„

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • D Offline
                                  Diggsey
                                  last edited by

                                  I've tried doing everything possible and can't seem to get any output in the ruby console from either plugin. Can you tell me exactly how to reproduce it?

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    d12dozr
                                    last edited by

                                    @diggsey said:

                                    I've no idea how to make such complicated structures as those ones you linked to, but you can get some interesting shapes by just mixing up a few of the built in functions:

                                    sin, cos, tan, sinh, cosh, tanh, asin, acos, atan, asinh, acosh, atanh, atan2, hypot, sqrt, cbrt, log, log2, log10, ln, exp

                                    and constants:

                                    e, pi

                                    Thank you for this, and considering my suggestions too!

                                    3D Printing with SketchUp Book
                                    http://goo.gl/f7ooYh

                                    1 Reply Last reply Reply Quote 0
                                    • TIGT Offline
                                      TIG Moderator
                                      last edited by

                                      @diggsey said:

                                      I've tried doing everything possible and can't seem to get any output in the ruby console from either plugin. Can you tell me exactly how to reproduce it?
                                      For example...

                                      @unknownuser said:

                                      Error: #<NoMethodError: undefined method curve' for #<Sketchup::Group:0xa9d06fc>> C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:17:in can_select_curve?'
                                      C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:32:in `can_select_curve_selection?'
                                      C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:352

                                      When right clicking a tagged 'surfacegen-group'.
                                      Explode the special surgfacegen-group and right-click gives

                                      @unknownuser said:

                                      Error: #<NoMethodError: undefined method curve' for #<Sketchup::ComponentInstance:0xb440344>> C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:17:in can_select_curve?'
                                      C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:32:in can_select_curve_selection?' C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:352 C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:17:in call'
                                      C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:17

                                      Erase that 'bounds' Instance then Select the surface...

                                      @unknownuser said:

                                      Error: #<NoMethodError: undefined method curve' for #<Sketchup::Face:0xad7783c>> C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:17:in can_select_curve?'
                                      C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:32:in can_select_curve_selection?' C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:352 C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:17:in call'
                                      C:/Program Files/Google/Google SketchUp 8/Plugins/recurve.rb:17

                                      These all relate to 'recurve' reaction to 'surfacegen' entities ?
                                      I did have a surgacegen error but I can't get it to reproduce now πŸ˜•

                                      TIG

                                      1 Reply Last reply Reply Quote 0
                                      • N Offline
                                        notareal
                                        last edited by

                                        Nice! Can't wait some more complex math sculptures... and naturally even more functionality, like with K3DSurf.

                                        Little test...


                                        Icosahedron_SU.jpg

                                        Welcome to try [Thea Render](http://www.thearender.com/), Thea support | [kerkythea.net](http://www.kerkythea.net/) -team member

                                        1 Reply Last reply Reply Quote 0
                                        • pilouP Offline
                                          pilou
                                          last edited by

                                          In the V6
                                          We can draw the "Box" but dialog's window don't opening πŸ˜‰
                                          No error message, nothing in the Ruby console

                                          Frenchy Pilou
                                          Is beautiful that please without concept!
                                          My Little site :)

                                          1 Reply Last reply Reply Quote 0
                                          • D Offline
                                            Diggsey
                                            last edited by

                                            @notareal
                                            That's really nice! What's the equation you used?

                                            @TIG
                                            Make sure you have the latest version of Recurve. I fixed that bug with the last update which is why I couldn't reproduce the error. If you ever get the SurfaceGen error again let me know.

                                            @Pilou
                                            Just re-select the group with the select tool. It seems that the SelectionObserver doesn't fire when the selection is changed in code.

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 1 / 4
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement