sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Adding Solid Volume to Attributes

    Scheduled Pinned Locked Moved Dynamic Components
    sketchup
    18 Posts 6 Posters 16.4k Views 6 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.
    • TIGT Offline
      TIG Moderator
      last edited by

      There is not a file of that name. 😕
      You must make a new file with that name in the Plugins folder.
      Use Notepad.exe or another plain-text editor like Notepad++ to make the file.
      A .rb file is just a .txt file with a different file-suffix.
      You can set its associations to open with that application, it is not 'opened' by SketchUp, it's just 'read'...
      SketchUp recognizes any .rb files within the Plugins folder by this suffix, and loads their contents automatically...
      Once you have pasted the code-text into the file and saved the file into the Plugins folder, and you have restarted SketchUp, it should then auto-load the code and make that additional function available in your DCs thereafter...

      TIG

      1 Reply Last reply Reply Quote 0
      • O Offline
        Omarian
        last edited by

        TIG, I did as instructed.

        1. Create a text file called "add_DC_functions.rb"
        2. Copy code above
        3. Change file extension to .rb
        4. place file plugin folder (Should this be place in the Dynamic Component folder instead
        5. Restart SU

        After restart I cannot find the new function. Where and how is the new function accessed. Is it now part of the list of functions in SU attributes such as FACEAREA, or is it in the list where you find Lenz? How do I call this new "volume function" in a calculation.

        All i want to do is to be able to manipulate/vary the thickness of walls and slabs to analyse the impact on overall cost. As I increase the volume of a component wall the cost of that component should adjust automatically. I really need help.

        1 Reply Last reply Reply Quote 0
        • DareDevilD Offline
          DareDevil
          last edited by

          You can use volume() function in an atribute calculation just like facearea(), but it's not in the list, you must write it.

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

            As DareDevil says...
            The new .rb file you have made containing the function's code [that goes into the Plugins folder as instructed!] adds an additional function to the DC tool.
            The new function does NOT appear in the list of standard functions, but if you use it as the instructions in the code block say... type in the function - =volume() that will be used and return the selected DC-instance's volume in cu". You simply need to apply conversion factor to it to convert into other units...
            As explained the 'volume' function is only available to users of the DC who have the .rb loading, so if you want to pass on your DC to others you must also supply the .rb file...

            TIG

            1 Reply Last reply Reply Quote 0
            • O Offline
              Omarian
              last edited by

              Ok guys, it worked beautifully. Thanks a million!

              NEXT PROBLEM

              I pay carpenters by running (lineal) feet to install form ply for pouring concrete walls. I want to calculate running feet along wall components and have them adjust dynamically as I vary walls. Lenx or leny does not work as walls bend and curve. I would have to make each wall a regularly shaped rectanglar component and then add all the length of the base lines in the wall. Is there a script that could do this or a plugin already built.

              1 Reply Last reply Reply Quote 0
              • A Offline
                ArCAD-UK
                last edited by

                Simple maths, if you have the volume and divide by a constant dimension that gives the area, so assuming your curves are in a single direction divide the volume by the base area will give the linear dimension. This is where my reference to facearea() came from. The presence of holes will affect the calculation!

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

                  Are you saying you have 'curved' DC walls ?
                  If so you must be doing some math-ca;cs to make them, from those the inside/outside radius and swept arc are knowable and their partial circumferences can be got - these are the linear lengths of curved shuttering etc for the two faces...
                  You are only supplying partial info, being more specific and perhaps providing some images etc would help us help you so much more easily...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • O Offline
                    Omarian
                    last edited by

                    TIG,

                    I have attached the file with the first floor concrete walls for which I need to obtain running foot. I presently would have to dimension each wall inside and outside and manually add them to come up with total running foot. Is there a way the SU could report the total dimension of a component as distinct from lenx and leny dimensions. Could SU report the length of selected edges at the base running paralell or at an angle to zor y? Could it report the maximum length of every face it recognizes?


                    Concrete wall running foot problem.skp

                    1 Reply Last reply Reply Quote 0
                    • O Offline
                      Omarian
                      last edited by

                      I was thinking, wouldn't it be so much easier in doing lineal measurement to "material" or colour an edge/line and have a function return the length of all coloured edges/lines,in much the same way the the FACEAREA command does? That would be so helpful. I could get the inner and outter running feet by merely colouring the walling footing edges. As I adjust the walls so would the measurements and all the calculations that reference them.

                      1 Reply Last reply Reply Quote 0
                      • P Offline
                        pibuz
                        last edited by

                        Hi guys! I needed exactly this feature and I found this great tip from master TIG! Wonderful! Thanks!

                        Now in 2021 you only have to update a tiny detail: in the script you have to point to "su_dynamiccomponents.rb" instead of "dynamiccomponents.rb", and it works great!

                        WEB (ita) - https://filipposcarso.wixsite.com/ordinentropico

                        1 Reply Last reply Reply Quote 0
                        • simjoubertS Offline
                          simjoubert
                          last edited by

                          Hello
                          Thank you for this code which opens up nice perspectives for me, especially if I manage to debug the following situation!

                          Sketchup does not offer the function to count the number of occurrences of a text string in a text.

                          I have checked in the ruby window the following code and I get the expected result

                          string = 'hello world'
                          string.count('l')
                          # This returns the integer 3 
                          

                          I want to implement a new function but I have the following error

                          [wrong number of arguments (given 1, expected 2)]
                          

                          Here is my code that I added after the one from TIG

                          # add_DC_function.rb
                          # extends DCs functions
                          require('sketchup')
                          require('su_dynamiccomponents.rb')
                          if defined?($dc_observers)
                            # Open SketchUp's Dynamic Component Functions (V1) class.
                            # BUT only if DC extension is active...
                            class DCFunctionsV1
                              protected
                              # DC Function Usage; =volume()
                              # returns the instance's volume [cu"]
                              if not DCFunctionsV1.method_defined?(;volume)
                                def volume(a)
                                  return @source_entity.volume
                                end
                              end
                          	
                          	    # DC Function Usage; =occurence(texte,texte recherche)
                              # returns the number of the occurency of the string
                              if not DCFunctionsV1.method_defined?(;occurence)
                                def occurence(a, b)
                                  return a.count(b)
                                end
                              end
                            end#class
                          end#if
                          

                          Thank you for your help
                          Simon

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

                          Advertisement