[Plugin] Scale Face to Target Area - TIG
-
@thomthom said:
na = -na if na < 0
Why not just use#abs
?
na = na.abs
No reason.
I assume you meantna=results[0].abs
as a one-step solution.
I was just writing it on the fly and needed to trap for a negative or zero reply...Incidentally, I noted that you transformed the face while I did the face.vertices, is there any advantage in either way?
Presumably transforming the face changes its vertices and what they are connected to anyway, and conversely transforming the vertices transforms the face and also whatever they are connected to also ? -
@tig said:
Incidentally, I noted that you transformed the face while I did the face.vertices, is there any advantage in either way?
Presumably transforming the face changes its vertices and what they are connected to anyway, and conversely transforming the vertices transforms the face and also whatever they are connected to also ?I'd expect that under the hood, when you feed entities to
#transform_entities
it collects the vertices - so[face]
andface.vertices
should have the exact same effect. I kind of likedface.vertices
instead of wrapping the face in an array - feel it reads better as the brackets isn't so easy to see immediately. -
Actually just
face
should work as well as[face]
because the transformation is the first argument and you can then pass an array OR a series of arguments, so 'face' would be seen as the first one anyway ? ... -
API-doh!
-
You guys both rock! THANKS so much!
-
You see this plugin?
-
@jorge2011 said:
You see this plugin?
That's nice looking. The VCB is a nice way to control it. But I think $10 is too much for such a trivial script.
-
TIG, having an issue with your script loading properly. I copied and pasted the code exactly into a notepad file and named it - TIG-scale_face.rb. Upon loading Sketchup, I get no errors, but none of my toolbars load. When I delete the script, all the toolbars load again.
-
Thom, excuse my ignorance, but how would I going about testing your code?
-
@earthmover said:
Thom, excuse my ignorance, but how would I going about testing your code?
Sorry Adam, I typed it up and posted in a hurry. You'd put it in a .rb file and form the console invoke:
TT_ScaleToArea.scale_face( Sketchup.active_model.selection[0], 4000 )
Didn't have the time to add UI.
-
The code is now tested and working version... I edited the original ! http://forums.sketchucation.com/viewtopic.php?p=419936#p419936
Stupid typounless**.**file_loaded?
instead ofunless file_loaded?
I added the UI as an afterthought and never tested it sorry! -
Thanks TIG. It works as long as I am using a decimal unit type. With fractional units, it deletes everything in the model. Not sure why, just have to remember to switch the units before using the plugin. Thanks again. I'll update the first post with the rb file.
Also it is still stating inches in the dialog even when the units are feet. No big deal though. Works for what I need. Thanks again!
-
I'll adjust the code... I did type it on the fly...
-
If you have time. If not, no worries. I just figured I'd mention the issues in case anyone else needed to use the plugin.
-
I've updated the .rb in your post and edited the post's text to match [hope you are OK with that ]
It now handles all Unit-types/Fractional/Engineering etc properly.
One oddity is that 'Engineering' displays on screen in 'feet', but the API unit-type [LengthUnit] is left in 'inches' [0] - unlike all other types where the 'LengthUnit' matches the displayed-unit.Anyway it now works for all combos... I hope
-
Works great now. Thanks again.
-
@tig said:
I've updated the .rb in your post and edited the post's text to match [hope you are OK with that ]
This plug-in only applies to the quadrangle
-
NO, it works on any face.
The selected face is simply scaled to have the desired area.
The dialog shows the current area in current units.
You enter the new area and OK.
The selected face is made to have that area.
So if it's a square, a star or a circle it doesn't matter... -
This is a great little plugin.
Any chance to make it work in square ft, when my units are set to Architectural?Or do I need to divide by hand first...?
-
Works on almost any face. Faces created by the freehand tool seem to fail to resize properly. Not sure why.
Advertisement