sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [REQUEST] Automatic drawing of vertical lines

    Scheduled Pinned Locked Moved Plugins
    35 Posts 8 Posters 3.5k Views 8 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.
    • J Offline
      Jim
      last edited by

      @unknownuser said:

      Of course, you have to have created a class, and not just put your tool in a module...

      I think a module-level variable would have sufficient scope as it would be available anywhere within the scope of the module. A module is a class, except that it can not be instantiated. So when you say you need create a class, a module will also work.

      
      module JF
        # Don't initialize if it already has a value
        @my_var = 1 if @my_var.nil?
      end
      
      def JF.test_method
        p @my_var
      end
      
      p JF.test_method
      1
      
      

      This just shows you can't create an instance of a module even though it is a technically a class:

      
      > Module.class
      Class
      > Class.class
      Class
      
      > Module.new.new
      Error; #<NoMethodError; (eval);33; undefined method `new' for #<Module;0x7e4f2b8>>
      (eval);33
      
      > Class.new.new
      #<#<Class;0x7e4e430>;0x7e4e400>
      
      
      

      Hi

      1 Reply Last reply Reply Quote 0
      • Chris FullmerC Offline
        Chris Fullmer
        last edited by

        @Panga ok, I'll aim for that.
        @Jim, someday I hope to understand that πŸ˜„

        I was using instance variables, so I'll just change it over to a class variable. And I think for me right now that will do the trick - at least from activation to activation of the tool.

        Chris

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

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          @Panga, ok the script is working pretty good now. I am going to attempt to write in some code that makes it remember your last setting over SketchUp sessions. So use it, turn off sketchup and then turn it back on and it should still remember the last number you typed. That is the goal. I never did get double click to work. Oh well.

          I should be done soon enough I hope,

          Chris

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

          1 Reply Last reply Reply Quote 0
          • Chris FullmerC Offline
            Chris Fullmer
            last edited by

            ok, script released here:

            301 Moved Permanently

            favicon

            (www.sketchucation.com)

            It does not remember your settings from one SU session to another. I kept getting a lot of errors in trying to implement read_default and write default methods. And I also couldn't figure out how to encode in hex. THat is a new world to me and I didn't find anything useful (or that I understood?) in the ruby rdocs either. I think I'm done for the night, but maybe tomorrow if I get a chance, I'll try it again. Thanks for all the help everyone! Hope its useful Panga and others,

            Chris

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

            1 Reply Last reply Reply Quote 0
            • M Offline
              Matt666
              last edited by

              @unknownuser said:

              @Jim, someday I hope to understand that
              +1 πŸ˜•

              Frenglish at its best !
              My scripts

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @chris fullmer said:

                ok, script released here:

                301 Moved Permanently

                favicon

                (www.sketchucation.com)

                It does not remember your settings from one SU session to another. I kept getting a lot of errors in trying to implement read_default and write default methods. And I also couldn't figure out how to encode in hex. THat is a new world to me and I didn't find anything useful (or that I understood?) in the ruby rdocs either. I think I'm done for the night, but maybe tomorrow if I get a chance, I'll try it again. Thanks for all the help everyone! Hope its useful Panga and others,

                Chris

                You want to convert some data to HEX values?

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

                1 Reply Last reply Reply Quote 0
                • Chris FullmerC Offline
                  Chris Fullmer
                  last edited by

                  Yeah, how would I go about doing that?

                  Chris

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

                  1 Reply Last reply Reply Quote 0
                  • thomthomT Offline
                    thomthom
                    last edited by

                    Do you want to convert numbers to hex? Or do you want to take a string and convert each byte into a hex number?

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

                    1 Reply Last reply Reply Quote 0
                    • Chris FullmerC Offline
                      Chris Fullmer
                      last edited by

                      I have no idea. I think the string idea (unless its harder to implement).

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

                      1 Reply Last reply Reply Quote 0
                      • thomthomT Offline
                        thomthom
                        last edited by

                        Why do you want it as hex anyway?
                        Hex can only be numbers, only way to convert a string is to take each characters, get the character code which is an integer, and convert that into hex values.

                        I'm just wondering if hex numbers is what you want. If you want to store data to disk then you will want to store it as binary instead, as that's how data is stored anyway.

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

                        1 Reply Last reply Reply Quote 0
                        • Chris FullmerC Offline
                          Chris Fullmer
                          last edited by

                          @unknownuser said:

                          Pick a name (a key) wisely, like fullmer_linetool_length and store the value in a hex encoded value for best portability on both platforms. You might encounter a known bug if you don't encode a length value. (I don't remember right know if it is a dot, apost, quote or blank that causes issues on Windows.

                          He recommended using hex so as to not store it as a normal string since there is a chance I'll encounter a bug. I suppose binary would work? Just as long as I can get away from a normal string,

                          Chris

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

                          1 Reply Last reply Reply Quote 0
                          • thomthomT Offline
                            thomthom
                            last edited by

                            hm... ok, you might want to probe Todd as I'm not 100% sure about this.

                            But converting from String to Hex-String to String, I think can be done like this:

                            
                            # Pack the string to a hex string
                            # return value is an array with one entry
                            arrayData = "Hello World".unpack('H*')
                            
                            

                            Since arrayData is an array, you want to store arrayData[0].

                            Then when you load the string, you have to wrap it into an array again:

                            
                            # storedDataString is the string you loaded
                            arrayData = [storedDataString] # This creates an array with the storedDataString
                            
                            
                            
                            # Convert the Hex String back to a String;
                            myString = arrayData.pack('H*')
                            
                            

                            Let me know if that made any sense at all.

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

                            1 Reply Last reply Reply Quote 0
                            • Chris FullmerC Offline
                              Chris Fullmer
                              last edited by

                              Yup, that made sense (surprisingly, I'm sort of dense at times). Thanks very much Thom, I'll play with that when I get back to that part of the script. Currently trying to figure out how to average the normals of 2 planes to find a middle normal. Not having much luck so far 😞

                              Chris

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

                              1 Reply Last reply Reply Quote 0
                              • thomthomT Offline
                                thomthom
                                last edited by

                                I think this will work:

                                
                                vector1 = face1.normal
                                vector2 = face2.normal
                                vector3 = Geom;;Vector3d.linear_combination(0.5, vector1, 0.5, vector2)
                                
                                

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

                                1 Reply Last reply Reply Quote 0
                                • Chris FullmerC Offline
                                  Chris Fullmer
                                  last edited by

                                  Thanks Thom. I had tried using that earlier and it did not produce what I thought I was looking for. Seems to be working just great right now. Thanks!

                                  Chris

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

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

                                  Advertisement