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

Auto-complete callout with dimensions

Scheduled Pinned Locked Moved Extensions & Applications Discussions
extensions
10 Posts 4 Posters 5.6k Views 4 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.
  • B Offline
    bsusala
    last edited by 4 Nov 2012, 23:05

    Hi all, could you please help me in finding, if there is, a faster method or plugin which will auto-complete a callout for an object, named group, not only with that name, but also with the dimensions of the group? I am modeling furniture and when passing my sketches to the workshop guys, dimensioning indications helps alot. Thanks!

    1 Reply Last reply Reply Quote 0
    • T Offline
      TIG Moderator
      last edited by 6 Nov 2012, 10:20

      Dimensions as such are not easily accessible through the API. 😞

      BUT you can easily add a text-tag with the group's name/x/y/z [taken from its bounding-box] using a one-liner copy+pasted into the Ruby Console + <enter>, which will add a text label to the top/center of each selected group [ignoring other objects]. The sizes are in 'current units'. It's one step undo-able.

      m=Sketchup.active_model;m.start_operation('t');m.selection.each{|e|next unless e.is_a?(Sketchup;;Group);n='?'if (n=e.name).empty?;b=e.bounds;p=b.center;p.z=b.max.z;m.active_entities.add_text(n+"\nx=#{b.width} y=#{b.height} z=#{b.depth}", p, [11,11,11]);};m.commit_operation;
      

      TIG

      1 Reply Last reply Reply Quote 0
      • B Offline
        bsusala
        last edited by 6 Nov 2012, 19:02

        Thanks TIG! I didn't experiment anything in Ruby yet, hope I will manage to do it this way. Still think though something related to the label tool will be more ergonomic, cause fits any situation of cluttering with other annotations.

        That idea to "label" each piece is still a good thing. Will test and feedback. Thanks again for your excellent and time saving tools!

        1 Reply Last reply Reply Quote 0
        • B Offline
          bsusala
          last edited by 6 Nov 2012, 19:29

          TIG, this tool is doing what I wanted, a text-callout/label with the name and the dimensions. Noticed that I can modify the code by getting rid of the x= etc., so it's almost what I wanted. It even creates these labels for multiple selected objects, all at once. That's excellent, however labels are so cluttered that I would want to move them, but the leader doesn't stick on the object's face, and I don't know how to solve this.

          Moreover, when I want to label an furniture from behind, the text label often is not visible, being created behind the object...

          Would very much love a custom "Text-label" with same behaviour as the standard one: to click whenever I see fit the object, in order to un-clutter the drawing.

          If I can help with anything in solving this, please tell me. Thanks in advance.

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 6 Nov 2012, 20:11

            Feel free to mess on with the 'wording' - I adding X=/Y=/Z= because that expains what's getting reported - I appreciate the sometimes the 'depth' [Z] is actually the 'length' [e.g. for a post] while for others it's a 'thickness' or 'depth'... [e.g. for a rail].
            With a little convolution you can get the largest value to always report first [or last] etc... Have a go using an 'array' for the three 'lengths' with a '.sort' and perhaps a '.reverse' so the biggest comes last [ e.g.
            ;a=[b.width,b.height,b.depth].sort.reverse; ] then
            ...add_text(n+"\n#{a[0]}, #{a[1]}, #{a[2]}"... etc...

            The coded API's access to Text functions is limited, and part of the limitation is you can't 'attach' Text to an object 😞

            However, all is not lost...
            You are probably aware that you can use 'Move' on a Text object you have selected.
            BUT, the Text tool itself has hidden depths...

            Activate the Text tool and single-click*** on any piece of Text [the 'words'], it then selects and you can Move the text-body to a new location [just as with Move].
            [***You almost certainly know that a double-click on the 'words' opens the text-string for editing...]

            BUT now for the best bit...
            The Text tool also allows you to click onto the 'arrowhead' of a Text object and drag it [keeping the mouse button pressed down] to a new location, AND if that location is one that the Text object could be linked onto, then the Text is now locked onto that object; and subsequently it will move with it etc, just as if you had place the piece of text manually...

            It's not too hard to convert coded Text into an object just like it would be it you had made it 'manually'.
            Hopefully one day the coded API will offer access to all aspects of the manual world... but until then this the best I can offer... πŸ˜‰

            TIG

            1 Reply Last reply Reply Quote 0
            • B Offline
              bsusala
              last edited by 6 Nov 2012, 20:22

              He he, I didn't knew Text tool can move labels... Interesting. That solves I think de-cluttering.

              And yes, sorting (and in most cases excluding the smallest dimension) is very useful and usual in cabinet making, where material has by itself a thickness (=the smallest dimension). I'll start playing with coding, that's my first attempt. I've wanted for so long to start playing with Ruby, didn't had the time, so that's a push for me to start eventually πŸ˜„

              Thanks for all, I'll post here my development of the situation πŸ˜„

              1 Reply Last reply Reply Quote 0
              • T Offline
                togethearth
                last edited by 23 Apr 2013, 22:05

                Thanks TIG!
                I followed your detailed posts and successfully ran it. My first ruby console trick.
                But a part placed with an angle throws x,y,z different from l,w,h. How can I get real length, width and height?

                1 Reply Last reply Reply Quote 0
                • T Offline
                  TIG Moderator
                  last edited by 7 Sept 2020, 09:48

                  If you've added the edge you have the 'bounds' of the things ?
                  Then you can use cpt = bounds.center
                  Then use this to set up the text element...
                  You seem to want the number of things e.g. 9, and then the 'length' of them ?
                  So, to get the number [before adding a line etc] use cnt = entities.length
                  To get the 'length' you can get that from the len = bounds.width [in inches] or
                  lenmm = bounds.width.mm etc

                  Now to assemble the text's 'string'...
                  str = "#{cnt} x #{len}"

                  It looks like you want to add some 3d text to the things ?
                  https://ruby.sketchup.com/Sketchup/Entities.html#add_3d_text-instance_method

                  Its arguments are:

                  ` string` (String) β€” The text to create.
                  ` alignment` (Integer) β€” Number that defines the alignment. There are constants called TextAlignLeft, TextAlignRight, and TextAlignCenter that can be passed.
                  ` font` (String) β€” font name.
                  ` is_bold` (Boolean) (defaults to: false) β€” true for bold.
                  ` is_italic` (Boolean) (defaults to: false) β€” true for italic.
                  ` letter_height` (Numeric) (defaults to: 1.0) β€” Height of the text (in inches).
                  ` tolerance` (Numeric) (defaults to: 0.0) β€” Tolerance of the curve creation. Defaults to 0.0, which creates the highest possible curve quality.
                  ` z` (Numeric) (defaults to: 0.0) β€” z position (in inches).
                  ` is_filled` (Boolean) (defaults to: true) β€” true for filled, which will put a face between the edges of the letters.
                  ` extrusion` (Numeric) (defaults to: 0.0) β€” Extrusion depth (in inches).
                  

                  So for example:
                  [ruby:18nsjtjx]ht = 100.mm letter_height
                  zht = bounds.depth # ? so rests 'on top' ?
                  ext = 0.0 # for flat
                  entities.add_3d_text(str, TextAlignLeft, "Arial", false, false, ht, 0.0, zht, true, ext)[/ruby:18nsjtjx]

                  You need to have made a reference to 'entities' being the context of the things we are working on...
                  Adjust the other items as needed...

                  Add the diagonal line after adding the text ??

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • Dav_IDD Offline
                    Dav_ID
                    last edited by 7 Sept 2020, 11:35

                    Thanks a lot TIG!

                    I made the image in 2D with Autocad (or SU), I don't remember ... and the line was drawn by hand.

                    To be honest i'm completely newbie with ruby ​​like as i said and i don't know how i am going to be able to write the script (almost like chinese for me at the moment) πŸ˜„ ... but now i know where to start: D ... again a big thank you TIG.

                    Respectfully

                    PS : to answer you about 3D text About the text, i though about using simple text (not 3d) without Leader ... and putting it in a new layer (with bouding rectangle and a line) that will be creating after selecting the objects.

                    ... but thank you to for your complete informations about 3D text ... IT'S GREAT !

                    1 Reply Last reply Reply Quote 0
                    • Dav_IDD Offline
                      Dav_ID
                      last edited by 17 Sept 2020, 09:15

                      Hi,

                      Really interesting, thanks a lot for this (old) thread πŸ˜‰

                      That's a part of the solution for my (old) problem πŸ˜‰
                      https://sketchucation.com/forums/viewtopic.php?f=80&t=71894

                      now, i know how to write with Ruby X*Y on my unique component.

                      Ideally, i would like to do something like that
                      https://sketchucation.com/forums/download/file.php?id=158092&t=1

                      But as i don't know Ruby ... and i'm absolutely not a developper πŸ˜•
                      I think i can do a small modification of this to do just this

                      but i don't know where to begin,
                      to do this,

                      1. i would like to select my components, so that the extension count the number of instance
                      2. so that it write number * Length (X for horizontal or Z for vertical ... or Y following component axis for inclined plane for example)

                      i think i can find information to draw a line adapted to the bounding box ... (in "Automatic Sketchup" by Matthew Scarpino)
                      ... how to position the leader and the text (in the same book)
                      ... maybe how to draw the rectangle around the bounding box while creating another layer ... ("Automatic Sketchup" by Matthew Scarpino too ?)
                      but i don't now where to find how to write Number * Length with text

                      i found something about it here
                      https://ruby.sketchup.com/Sketchup/Selection.html#count-instance_method
                      it's the beginning, the solution is near ? πŸ˜‰

                      Can you help me please ?
                      Thanks
                      Best regards

                      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