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

    Plugin(export attributes to csv)

    Scheduled Pinned Locked Moved Developers' Forum
    16 Posts 4 Posters 819 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.
    • T Offline
      tetsuyahishida
      last edited by

      Hi!All. I'm a newbie and I'm sorry if I'm in the wrong place.

      Now making a plugin based on TIG's
      "exportvertices2csv"
      "VolumeCalculator2"

      The script it self is uploaded in GITHUB
      https://github.com/tetsuyahishida/export2csv

      <What the Plugin can do>
      the script can output
      1.volume
      2.are of the faces
      3.normal vector of the faces
      to csv

      <The Problem>
      But the problem is that it doesn't work on in some PCs!
      The window with the message
      "uninitialized constant Export2csv::Volume”
      can some body help me?


      snapshot

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        The class method
        def Volume::calculate(fcs)
        should be renamed as
        def volume(fcs)
        and then called in the 'initialize()' code where
        volume=Volume.calculate(fcs)#calculate volume
        becomes
        volume=self.volume(fcs)

        you are making it all too convoluted...

        PS: whilst I don't mind an acknowledgment in the scripts header, please don't make me the (c) author... that's you ! I accept NO blame 😉

        TIG

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          Why do you distro a copy of sketchup.rb ?

          It does not appear to be different from the Google version, and should not be changed anyhow.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • T Offline
            tetsuyahishida
            last edited by

            TIG
            Thank you so much for your reply!
            I'm a fan of you. So excited to be able to get in touch with you.

            The Plugin worked flawlessly after the modification.

            Dan Rathbun
            Thank you for your advice.
            It is the same as the Google version.

            I'll push the changes.
            Since using "git" and push it to GITHUB seems to be a very usefull method I think other sketchup user might like using it.

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              You shouldn't distribute sketchup.rb - all users will already have it in their Tools folder, so giving it to a user who might then put a duplicate [or worse, 'out of date'] version into their Plugins folder could cause all sorts of unexpected complications that can be avoided by NOT supplying it in the zip-file.

              TIG

              1 Reply Last reply Reply Quote 0
              • T Offline
                tetsuyahishida
                last edited by

                TIG

                Thank you for your advise.
                I've removed sketchup.rb from GITHUB.

                Unfortunately, some other people still can't use the plugin.

                <Error message>
                #<NameError: undefined loca variable or method 'export2csv' for main:Object>

                do you have any idea what's wrong?

                Link Preview Image
                export2csv/export2csv.rb at version0.8 · tetsuyahishida/export2csv

                sketchup plugin. Contribute to tetsuyahishida/export2csv development by creating an account on GitHub.

                favicon

                GitHub (github.com)


                screenshot

                1 Reply Last reply Reply Quote 0
                • J Offline
                  Jim
                  last edited by

                  The error message is correct - export2csv is not a variable or function - it is never defined. You get the same error if you enter random characters in the Ruby Console.

                  Enter Export2cvs.new to start the plugin from the Ruby Console (the same as how it is executed from the menu and Toolbar.)

                  Hi

                  1 Reply Last reply Reply Quote 0
                  • J Offline
                    Jim
                    last edited by

                    Also, the Array class already has a .dot method - no need to add one to the Geom::Point3d class.

                    http://code.google.com/apis/sketchup/docs/ourdoc/array.html#dot

                    In fact, it is best not to add or change methods of any of the API classes because those changes may cause other plugins to fail, or worse - to have subtle errors which may go undetected.

                    Hi

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      @jim said:

                      The error message is correct - export2csv is not a variable or function - it is never defined. You get the same error if you enter random characters in the Ruby Console.

                      Enter Export2cvs.new to start the plugin from the Ruby Console (the same as how it is executed from the menu and Toolbar.)

                      ...OR alternatively you could make a 'shortcut' method
                      def export2cvs(); Export2cvs.new(); end
                      outside of the Export2cvs class and then typing export2cvs will also run the tool...

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • J Offline
                        Jim
                        last edited by

                        @unknownuser said:

                        ...outside of the Export2cvs class

                        You don't want to do that either. Adding a top-level method adds it to the look-up chain for all Ruby objects. So there is a minute chance that if another dev happens to have a export2csv method and makes a mistake (a typo, for example) it is possible that the top-level method gets found and executed instead. This can occur even if the other dev's method is correctly namespaced.

                        Hi

                        1 Reply Last reply Reply Quote 0
                        • TIGT Offline
                          TIG Moderator
                          last edited by

                          @jim said:

                          @unknownuser said:

                          ...outside of the Export2csv class

                          You don't want to do that either. Adding a top-level method adds it to the look-up chain for all Ruby objects. So there is a minute chance that if another dev happens to have a export2csv method and makes a mistake (a typo, for example) it is possible that the top-level method gets found and executed instead. This can occur even if the other dev's method is correctly namespaced.

                          I know it IS inadvisable to add new methods directly to the top-level, BUT even the API Ruby Examples show this way... so IF this guy is making a script for limited use and he has few other scripts loading then he's unlike to have a clash... BUT perhaps a less common name would be safer, AND of course even the class itself Export2csv.new() might have been used by someone else too... so then it'd be best to have a module holding that class, as it would then be extra-extra safe ! Then you'd have to type TetsuyahishidaTools::Export2csv.new(), BUT then it is very-very unlikely to have been duplicated by anyone else!!
                          Simply use a module to hold the class like this...

                          module TetsuyahishidaTools
                            class Export2csv
                              def initialize()
                                #...
                              end#methods
                            end#class
                            ###
                            class Export2tsv ### another Tool!
                              #...
                            end#class
                          end#module
                          

                          This way you can have several tools under the 'TetsuyahishidaTools' module...

                          PS: Please remove me [(c) TIG] as the 'blame' for this script in the header 😉

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            tetsuyahishida
                            last edited by

                            Thank you for your reply.

                            jim
                            The user and he said typing"export2csv.new" solved the problem.
                            He was typing "export2csv"

                            TIG
                            I've immedeately modified the authority. Sorry about my insensitiveness.

                            Still I got three questions

                            First, does "::"of "TetsuyahishidaTools::Export2csv.new()"
                            stands for scope resolution operator?If not, what does it stand for?

                            Second, Why does the "TetsuyahishidaTools Module" have to be a "Module"?
                            Is it because in Ruby, a class can only inherit from a single other class?
                            Or something about nesting rule?

                            Third, are there any way to do the same thing using "include"?

                            Sorry for my poor English and ruby skill.
                            Best regards.

                            1 Reply Last reply Reply Quote 0
                            • Dan RathbunD Offline
                              Dan Rathbun
                              last edited by

                              @tetsuyahishida said:

                              First, does "::"of "TetsuyahishidaTools::Export2csv.new()"
                              stands for scope resolution operator?

                              YES

                              I'm not here much anymore.

                              1 Reply Last reply Reply Quote 0
                              • Dan RathbunD Offline
                                Dan Rathbun
                                last edited by

                                @tetsuyahishida said:

                                Second, Why does the "TetsuyahishidaTools Module" have to be a "Module"?

                                Because an instance of class Module, can only be a singleton instance, meaning only ONE copy of the code it encloses, is needed.
                                Think about it. Within your outermost namespace (module), which should be your unique namespace (your company, etc.) you will define nested objects, both of class Class and class Module, and each of those only needs to be defined ONCE.

                                @tetsuyahishida said:

                                Is it because in Ruby, a class can only inherit from a single other class?

                                No. But for your info... class Class, is actually a direct child subclass of class Module, so objects of class Class, will inherit some methods from their superclass (class Module.)

                                Also.. what most people do not realize, is that when you define a module, like ...

                                module SomeCode
                                  # method definitions, etc.
                                end
                                

                                .. that the Ruby parser actually instantiates an instance of class Module like this ...

                                SomeCode = Module.new do |mod|
                                  # method definitions, etc.
                                end
                                

                                ... but it's actually done by C-side function calls.

                                I'm not here much anymore.

                                1 Reply Last reply Reply Quote 0
                                • Dan RathbunD Offline
                                  Dan Rathbun
                                  last edited by

                                  @tetsuyahishida said:

                                  Third, are there any way to do the same thing using "include"?

                                  Only module instances can be mixed-in using the include or extend methods... BUT these 'mixin modules' can be mixed into other modules, classes, or instance objects.

                                  I'm not here much anymore.

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    tetsuyahishida
                                    last edited by

                                    Dan Rathbun
                                    Thank you so much for instruction.
                                    I am now studying "Design Patterns in Ruby"
                                    And just learned about Singlton Pattern.

                                    Does every one use Design Pattern making sketchup plugin?
                                    Or maybe use UML?

                                    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