Area to text
-
Good day,
I am trying to make a simple plugin to add up the area of selected faces and write them to txt or perhaps xml?
I have no idea where to begin

DOes anyone have a guide or link for me to an example perhaps? will be gladly appreciated!
-
Set up some variables...
@model=Sketchup.active_model @ss=@model.selection
'Collect' the selected faces...
faces=@ss.grep(Sketchup::Face)
add up the areas [in sq"]...
area=0.0 faces.each{|face|area+=face.area}
Now if desired covert to other units [here sqm]...
area=area/1,550.00310000620001
Now add the text [here we'll add it as 'screen-text' aka 'note']
@model.add_note("Area=#{area}sqm", 0.1, 0.1)Obviously there are many ways to do this, e.g. add text with a leader onto one of the faces...
@model.active_entities.add_text("Area=#{area}sqm", faces[0].bounds.center, [11,11,11]) if faces[0]
Alsosprintf()can be used to adjust the displayed decimal places etc... -
Pay attention to the shaded "sticky" posts at the top of the list. There are code snippet indexes, etc. to help you.
-
Note that when computing the area of the faces you want to apply the transformation of the parent context in order to get the correct size. The Face.area method accepts and optional transformation argument.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement