Adding Solid Volume to Attributes
-
TIG, I did as instructed.
- Create a text file called "add_DC_functions.rb"
- Copy code above
- Change file extension to .rb
- place file plugin folder (Should this be place in the Dynamic Component folder instead
- 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.
-
You can use volume() function in an atribute calculation just like facearea(), but it's not in the list, you must write it.
-
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... -
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.
-
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!
-
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,
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?
-
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.
-
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!
-
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
Advertisement