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

Instructor content

Scheduled Pinned Locked Moved Developers' Forum
84 Posts 8 Posters 7.9k 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.
  • T Offline
    TIG Moderator
    last edited by 22 Sept 2010, 14:17

    I have already written an 'Instructor' set of index.html/css/gif files etc for my new FreeRotate4.1 [not yet released] BUT it simply doesn't work... no matter what I do πŸ˜’
    At the moment it only works if you open the ../FreeRotate/index.html file in your web-browser...
    The Instructor never recognizes the tool as being active/current...
    I was thinking that perhaps you need to add a global_variable - setting it in the activate() and resume() methods, e.g.
    $instructorContentDirectory = self.getInstructorContentDirectory()
    BUT what that global_variable might be is a mystery... πŸ˜•
    I there a way to puts a list of global_variables ?
    If you start FreeRotate whilst in Line tool the Instructor sticks on Line, then if you Orbit it changes to Orbit, until you exit and pick another tool ???
    I've tried tool_id/pop/push et al with no positive results.
    It is as if my tool isn't registering as the active/current tool at all...

    TIG

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 22 Sept 2010, 14:20

      Anyone contacted Google yet?

      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
        TIG Moderator
        last edited by 22 Sept 2010, 14:23

        Not me...
        TT - it's your turn... πŸ˜‰

        TIG

        1 Reply Last reply Reply Quote 0
        • T Offline
          thomthom
          last edited by 22 Sept 2010, 14:26

          I think they still have a backlog on all my issues πŸ˜’ - but I can nag them about this one as well.

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

          1 Reply Last reply Reply Quote 0
          • B Offline
            bentleykfrog
            last edited by 6 Mar 2011, 21:19

            seems like the response is relative to the help directory on pc 😲

            writing the following brings up the eraser tool

            def getInstructorContentDirectory
              return "\\21019\\"
            end
            

            so looks like relative paths it is

            1 Reply Last reply Reply Quote 0
            • B Offline
              bentleykfrog
              last edited by 6 Mar 2011, 21:24

              hmmmm the following works well on pc too

              def getInstructorContentDirectory
                return "../../../../Tools/etc/instructor/"
              end
              
              1 Reply Last reply Reply Quote 0
              • C Offline
                Chris Fullmer
                last edited by 6 Mar 2011, 23:28

                Woohoo! That totally does it. that works in 7.1 also, I did not test anything earlier than that. Here is my code that uses it and points to a directory inside the plugins folder:

                ` class Clf_instructor

                def getInstructorContentDirectory
                return "..\..\..\..\Plugins\doc\"
                end
                end

                Sketchup.active_model.select_tool Clf_instructor.new`

                (that is just a snippet I was running from the webconsole, not actually part of a full file).

                Thanks for coming back and posting that,

                Chris

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

                1 Reply Last reply Reply Quote 0
                • T Offline
                  thomthom
                  last edited by 7 Mar 2011, 01:15

                  The instructor works??? πŸ˜„
                  Nice find!

                  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 7 Mar 2011, 01:15

                    This'll be useful for Bezier Surface. πŸ˜„

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

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      Dan Rathbun
                      last edited by 7 Mar 2011, 02:42

                      Another example of how the API docs (and a poorly written example,) have thrown us all off course for months!

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        thomthom
                        last edited by 7 Mar 2011, 08:29

                        @dan rathbun said:

                        Another example of how the API docs (and a poorly written example,) have thrown us all off course for months!

                        It does smell like a bug though. It doesn't sound right that they intended people to add custom Instructor content to the SU Instructor content folder.

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

                        1 Reply Last reply Reply Quote 0
                        • B Offline
                          bentleykfrog
                          last edited by 7 Mar 2011, 11:03

                          @thomthom said:

                          @dan rathbun said:

                          Another example of how the API docs (and a poorly written example,) have thrown us all off course for months!

                          It does smell like a bug though. It doesn't sound right that they intended people to add custom Instructor content to the SU Instructor content folder.

                          Its unusual that they document absolute paths but only go with relative paths, not that relative paths are bad by any means.

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            thomthom
                            last edited by 7 Mar 2011, 11:08

                            @bentleykfrog said:

                            @thomthom said:

                            @dan rathbun said:

                            Another example of how the API docs (and a poorly written example,) have thrown us all off course for months!

                            It does smell like a bug though. It doesn't sound right that they intended people to add custom Instructor content to the SU Instructor content folder.

                            Its unusual that they document absolute paths but only go with relative paths, not that relative paths are bad by any means.

                            It's awkward though. I run my plugins I develop from custom locations because I use Mercurial for revision control. So providing a path to a custom location from the hard coded instructor folder isn't ideal. (does it even work across drive letters?)
                            And because some OSX users put their plugins in the user folder instead of the default, one can never rely to plugins to be at a fixed relative path.

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

                            1 Reply Last reply Reply Quote 0
                            • K Offline
                              kirill2008
                              last edited by 7 Mar 2011, 11:12

                              Does anyone know how to find out how many slashes and dots are needed at certain end user comp ("..\..\..\..\"). I mean if someone has installed sketchup in a custom subdirectory it is necessary to add/remove one of "..\" I guess.

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                TIG Moderator
                                last edited by 7 Mar 2011, 15:05

                                I have use this successfully to get my FreeRotate Instructor to work

                                <span class="syntaxdefault">def&nbsp;getInstructorContentDirectory</span><span class="syntaxkeyword">()<br />&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">expand_path</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dirname</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">),</span><span class="syntaxstring">"FreeRotate"</span><span class="syntaxkeyword">)).</span><span class="syntaxdefault">split</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'/'</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">0.upto</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">3</span><span class="syntaxkeyword">){|</span><span class="syntaxdefault">i</span><span class="syntaxkeyword">|&nbsp;</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">i</span><span class="syntaxkeyword">]=</span><span class="syntaxstring">'..'&nbsp;</span><span class="syntaxkeyword">}<br />&nbsp;&nbsp;&nbsp;if&nbsp;[</span><span class="syntaxdefault">PLATFORM</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">grep</span><span class="syntaxkeyword">(/</span><span class="syntaxdefault">mswin</span><span class="syntaxkeyword">/)==[</span><span class="syntaxdefault">PLATFORM</span><span class="syntaxkeyword">]&nbsp;</span><span class="syntaxcomment">###&nbsp;PC<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">return&nbsp;</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'/'</span><span class="syntaxkeyword">)+</span><span class="syntaxstring">'/'<br />&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span class="syntaxstring">'/'</span><span class="syntaxkeyword">+</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'/'</span><span class="syntaxkeyword">)+</span><span class="syntaxstring">'/'<br />&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">end</span><span class="syntaxcomment">#if<br /></span><span class="syntaxdefault">end</span>
                                

                                It should work cross platform?

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • T Offline
                                  TIG Moderator
                                  last edited by 7 Mar 2011, 15:32

                                  My method 2 posts before this uses the absolute path of the calling script to construct a relative path to the important folders ?
                                  How do we allow for MAC users with their plugins 'in the wrong place' OR even my uni students who have to install their PC 3rd party scripts in their persona H:/Sketchup_Plugins/ folder, with a script added by their IT guys in the main Plugins to add that path to their $LOAD_PATH array... Would these still work with my idea ??

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    thomthom
                                    last edited by 7 Mar 2011, 15:35

                                    Can we get the path of the resource folder?
                                    If so, then we could add ../ back references until we're back at the root, then apply the absolute path.
                                    Though, how does one deal with different drive letters under Windows?

                                    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 7 Mar 2011, 15:35

                                      @thomthom said:

                                      Can we get the path of the resource folder?

                                      Ah - didn't see bentleykfrog's reply.

                                      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 7 Mar 2011, 15:40

                                        @bentleykfrog said:

                                        def getInstructorContentDirectory
                                        >   plugin_folder = Sketchup.find_support_file test_file.html, "Tools/My Plugin/"
                                        >   plugin_folder = plugin_folder.split("test_file.html")
                                        >   plugin_folder_array = plugin_folder[0].split("/")
                                        >   if(plugin_folder_array[1] == "Library")
                                        >     #so the plugin/tool is stored in the main library
                                        >     return "../../../../Tools/My Plugin/Instructor/"
                                        >   elseif (plugin_folder_array[1] == "Program Files" || plugin_folder_array[1] == "Program Files (x86)")
                                        >     #the operating system is PC, so only 1 location for tools/plugins
                                        >     #there's probably a better way to do this
                                        >     return "../../../../Tools/My Plugin/Instructor/"
                                        >   else
                                        >     #not sure about this, especially since it could be traversing drives
                                        >     return "../../../../../../../../../"+plugin_folder+"Instructor/"
                                        >   end
                                        > end
                                        

                                        plugin_folder = Sketchup.find_support_file test_file.html, "Tools/My Plugin/"
                                        This is not reliable way to find the location of where your plugin is installed. This is what breaks under OSX when users place them in incorrect locations - and it will also throw errors is people install plugins to custom locations, like TIG and I do.

                                        To get the path of your plugin:
                                        plugin_path = File.dirname( __FILE__ )

                                        To get SU Plugins path:
                                        su_plugin_folder = Sketchup.find_support_file( 'Plugins' )

                                        We can get the Resource folder by using:
                                        plugin_folder = Sketchup.find_support_file( 'Resources' )

                                        But then there's a folder named after the current locale...

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

                                        1 Reply Last reply Reply Quote 0
                                        • B Offline
                                          bentleykfrog
                                          last edited by 7 Mar 2011, 15:40

                                          @kirill2008 said:

                                          Does anyone know how to find out how many slashes and dots are needed at certain end user comp ("..\..\..\..\"). I mean if someone has installed sketchup in a custom subdirectory it is necessary to add/remove one of "..\" I guess.

                                          I think that because its relative to [sketchup folder]/Resources/[language]/helpcontent/tool/ that it shouldn't matter where sketchup is installed, as this will be constant. The parent directory "..\" folder just goes back through tool -> helpcontent -> [language] -> resources to get you to the base [sketchup folder].

                                          @thomthom said:

                                          And because some OSX users put their plugins in the user folder instead of the default, one can never rely to plugins to be at a fixed relative path.

                                          You're right this is a huge issue. I'm guessing that on OSX this path will be relative to the main library folder (ie. [primary hard drive]/Library/Application Support/[sketchup folder]/Sketchup/Resources/[language]/helpcontent/tool/). So maybe you can do some comparison between Sketchup.find_support_file "[some_file].html", "Tools/[your_plugin]/" and the main library location, like this:

                                          def getInstructorContentDirectory
                                            plugin_folder = Sketchup.find_support_file test_file.html, "Tools/My Plugin/"
                                            plugin_folder = plugin_folder.split("test_file.html")
                                            plugin_folder_array = plugin_folder[0].split("/")
                                            if(plugin_folder_array[1] == "Library")
                                              #so the plugin/tool is stored in the main library
                                              return "../../../../Tools/My Plugin/Instructor/"
                                            elsif (plugin_folder_array[1] == "Program Files" || plugin_folder_array[1] == "Program Files (x86)")
                                              #the operating system is PC, so only 1 location for tools/plugins
                                              #there's probably a better way to do this
                                              return "../../../../Tools/My Plugin/Instructor/"
                                            else
                                              #not sure about this, especially since it could be traversing drives
                                              return "../../../../../../../../../"+plugin_folder+"Instructor/"
                                            end
                                          end
                                          

                                          I'm not sure about the OSX support, but I'll check after I'm finished with my work on the PC.

                                          What do you guys think?

                                          -niall

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

                                          Advertisement