• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Using view.line_width= ?

Scheduled Pinned Locked Moved Plugins
10 Posts 5 Posters 1.3k Views
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.
  • A Offline
    August
    last edited by 15 May 2010, 12:33

    I am trying to understand what view.line_width= does. The documentation is not much help. To me is says the method draws lines of the desired width, but does not tell how. The sample code is no help.


    %(#000000)[**View.line_width=**] [floatr:tdmbx52s]SketchUp 6.0+[/floatr:tdmbx52s]
    The line_width= method is used to set the line width to use for drawing. The value is a Double indicating the desired width in pixels.

    This method is usually invoked within the draw method of a tool.

    Arguments:
    width - The width in pixels.

    Returns:
    view - a View object

    Example:

    view.line_width = width


    What is not clear from the doc is what "use for drawing" means. I suspect it means the next time the view is refreshed, which could be at a mouse movement. But if it means when I am drawing, then it could apply to some lines and not others.

    Has anyone had a use for this method? What does it really do?

    Thanks,
    August

    “An idea, like a ghost, must be spoken to a little before it will explain itself.”
    [floatr:v1mcbde2]-- Charles Dickens[/floatr:v1mcbde2]

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 15 May 2010, 12:35

      It affects the lines you draw using view.draw and view.draw2d. I often use it when I make tools and draw preview and guides on to the viewport.

      Thomas Thomassen — SketchUp Monkey & Coding addict
      List of my plugins and link to the CookieWare fund

      1 Reply Last reply Reply Quote 0
      • T Offline
        thomthom
        last edited by 15 May 2010, 12:40

        Actually, any of the view.draw* methods that draw lines. you have draw_line, draw_lines and draw_polyline that are aliases for view.draw, just with various GL_* commands.

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • T Online
          TIG Moderator
          last edited by 15 May 2010, 12:52

          What the docs don't make clear at all for new users is that there is a 'draw' method available to a tool that adds temporary lines, points etc to the screen based on what's there or what might be there as you enter parameters or adjust things: e.g. see my EEbyVector or EEbyLathe tools - these preview the shape that will be made as a 'ghost' outline of edges, and as you pick new points the shape changes; or if you enter a new segment count as say 24s that changes too... The various methods available within 'draw' let you change the width, stipple-style and color of the lines etc etc.
          These 'drawn things' only last as long as you allow them to - e.g. you can tell the tool to 'draw' them only if certain conditions prevail - often in the form if @state==1 ..., or 'draw' different things at different stages in the operation...
          To add geometry permanently to the model you use the entities.add_... - as you already know - e.g. entities.add_line(p1,p2). If you are adding a large mesh, for example in my EEbyLathe tool, you make the collection of points based on the current cursor or picked locations and 'draw' the parts to shown an outline of what might get made [say as dashed thin scarlet lines, without faces], once the user has double-clicked or cmd-key or whatever the 'enter' action is designed to be - then that set of points - usually saved as an array[s] that updates as you go - and which is finally used to actually make some real geometry in the entities collection at the end... 🤓

          TIG

          1 Reply Last reply Reply Quote 0
          • C Offline
            Chris Fullmer
            last edited by 15 May 2010, 14:46

            Here is a very simple example of how to implement the draw method so you can draw things to the screen. And the line_width method can be called from inside the draw mtheod. Just change the specified width and re-run to see the changes.

            class Clf_draw_corners
            
            	def onMouseMove(flags, x, y, view)
            		@cursor = [x,y]
            		view.invalidate
            	end
            	
            	def draw(view)
            		view.line_width = 5
            
            		@pt1 = view.corner(0)
            		@pt2 = view.corner(1)
            		@pt3 = view.corner(2)
            		@pt4 = view.corner(3)
            		view.draw2d GL_LINES, [@cursor, @pt1, @cursor, @pt2, @cursor, @pt3, @cursor, @pt4]
            	end
            	
            end
            
            Sketchup.active_model.select_tool Clf_draw_corners.new
            

            Chris

            Lately you've been tan, suspicious for the winter.
            All my Plugins I've written

            1 Reply Last reply Reply Quote 0
            • B Offline
              Builder Boy
              last edited by 15 May 2010, 15:56

              Can you use this method to draw a 3D edge that is thicker in pixels than regular edges? If so, please post an attachment with the ruby script.

              All my plugins

              1 Reply Last reply Reply Quote 0
              • T Offline
                thomthom
                last edited by 15 May 2010, 15:58

                @unknownuser said:

                Can you use this method to draw a 3D edge that is thicker in pixels than regular edges? If so, please post an attachment with the ruby script.

                "3D edge" - the edge is 2D but in 3D space.
                And Chris' sample in the previous post demonstrates how to draw with these methods.

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • T Online
                  TIG Moderator
                  last edited by 15 May 2010, 17:14

                  @unknownuser said:

                  Can you use this method to draw a 3D edge that is thicker in pixels than regular edges? If so, please post an attachment with the ruby script.

                  As explained all of the 'draw' graphics are only 'transitory' - they are used as 'guides' in a tool - they vanish when that stage of a tool's use ends or another tool is invoked...
                  To change the edge thickness in regular geometry 'edges' you have to use 'trickery' - like my 2D Line Style Tool [which works in 3D too]. You can call up a dialog [right-click] to set your requirements - thickness [50mm etc], color [red etc], line-style [dash/dot/center etc] etc and you then pick the line[s] to 'style' - they are moved to a hidden layer, and an instance with a 'face' the correct width/color/style etc is placed in its stead - it's centered on the line if it's unfaced or coplanar with two faces, or stepped in onto the face if lone faced [if two-faced the face 'squarest' to the camera gets the new edge]... Selecting already Styled Line[s] gives a right-menu lets you Edit it/them and change thickness/color/style as desired...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • B Offline
                    Builder Boy
                    last edited by 18 May 2010, 02:08

                    @tig said:

                    To change the edge thickness in regular geometry 'edges' you have to use 'trickery' - like my 2D Line Style Tool [which works in 3D too]. You can call up a dialog [right-click] to set your requirements - thickness [50mm etc], color [red etc], line-style [dash/dot/center etc] etc and you then pick the line[s] to 'style' - they are moved to a hidden layer, and an instance with a 'face' the correct width/color/style etc is placed in its stead - it's centered on the line if it's unfaced or coplanar with two faces, or stepped in onto the face if lone faced [if two-faced the face 'squarest' to the camera gets the new edge]... Selecting already Styled Line[s] gives a right-menu lets you Edit it/them and change thickness/color/style as desired...

                    I would like to see this plugin. Can you post it?

                    All my plugins

                    1 Reply Last reply Reply Quote 0
                    • T Online
                      TIG Moderator
                      last edited by 18 May 2010, 08:29

                      The 2D Tools set is available in the Plugins forum here do a search for it and by author 'TIG'...
                      I could give you a direct link but it's good that you learn to find things yourself - 'give a man a fish or teach a man to fish' etc...

                      TIG

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

                      Advertisement