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

    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.
    • thomthomT Offline
      thomthom
      last edited by

      Anyone with a non-English SketchUp?

      Sketchup.get_resource_path( 'helpcontent' )
      I'm wondering if the names of files and folders in the Resource folder depends on 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
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        @ThomThom: The base of the help content is:
        Sketchup.get_resource_path( 'helpcontent/tool' )

        I'm not here much anymore.

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

          @dan rathbun said:

          @ThomThom: The base of the help content is:
          Sketchup.get_resource_path( 'helpcontent/tool' )

          The base for which Tool.getInstructorContentDirectory base that paths on is:
          Sketchup.get_resource_path( 'helpcontent' )

          See my earlier snippet: http://forums.sketchucation.com/posting.php?mode=quote&f=180&p=314120#pr314106
          Tried and tested under Windows, English SketchUp locale.

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

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

            @thomthom said:

            Anyone with a non-English SketchUp?

            Sketchup.get_resource_path( 'helpcontent' )
            I'm wondering if the names of files and folders in the Resource folder depends on the current locale.

            The files MUST be the same name, so that the LangHandler class can find them. (see the 'langhandler.rb' script in the Tools folder.)

            Beneath the 'helpcontent/tool' folder, all the subdirs have numerical names corresponding to tool_id, so they should be the same for all locales.

            I cant see Google changing the names of direct subfolders of the locale folder (but who knows... I guess it's best to check. Perhaps PM Didier, he runs in French right?)

            I'm not here much anymore.

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

              Full path on my computer:
              C:\Program Files (x86)\Google\Google SketchUp 8\Resources\en-US\helpcontent

              What I'm wondering is if the folders after en-US, the locale folder, might change. That maybe one needs to query the LangHandler for helpcontent ?

              Just like to get it confirmed by a non-English user that the helpcontent folder remains as it is across locales.

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

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

                @thomthom said:

                @dan rathbun said:

                @ThomThom: The base of the help content is:
                Sketchup.get_resource_path( 'helpcontent/tool' )

                The base for which Tool.getInstructorContentDirectory base that paths on is:
                Sketchup.get_resource_path( 'helpcontent' )

                See my earlier snippet: http://forums.sketchucation.com/posting.php?mode=quote&f=180&p=314120#pr314106
                Tried and tested under Windows, English SketchUp locale.

                Hmmm. why are Chris and the B'frog reporting 4 parent dirs up to the Sketchup dir ?

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • B Offline
                  bentleykfrog
                  last edited by

                  This returns the eraser tool on my system.

                  def getInstructorContentDirectory
                    return "\\21019\\"
                  end
                  

                  Its a long way around but I'm thinking that it would be possible to write the required files and folders to the /temp/ folder on the C:/ drive before the tool loads, then use a relative path to the /temp/instructor/ directory in getInstructorContentDirectory. This would avoid the volume traversal problem but I think it would be a bit of a headache.

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

                    My understanding is that it ia looking in the "tool" folder for content, so it 4 steps back to the base SU directory. This is the path on the machine I am on right now:

                    C:\Program Files\Google\Google SketchUp 7\Resources\en-US\helpcontent\tool

                    That worked for me, are you guys seeing differently?

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

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

                      Man.. I hate these crappy UI.inputboxes in the SU API !!

                      This is ridiculous !

                      UI_inputbox_labelwidth_2.png

                      I'm not here much anymore.

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

                        @chris fullmer said:

                        That worked for me, are you guys seeing differently?

                        The snippet I posted work for me when I added it to Bezier Tools as a working example. I generate a relative path from Sketchup.get_resource_path( 'helpcontent' )

                        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

                          @dan rathbun said:

                          PC:
                          VER = Sketchup.version.to_i USER_PLUGINS = File.expand_path("#{ENV['APPDATA']}\Google\Google SketchUp #{VER}\SketchUp\Plugins")

                          Sorry for the late reply Dan, but on my Windows 7 machine there's no Sketchup Folder, ie. USER_PLUGINS = File.expand_path("#{ENV['APPDATA']}\Google\Google SketchUp #{VER}\Plugins") would work.

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

                            That is also what I have Niall. What is that extra folder you have there Dan?

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

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

                              @chris fullmer said:

                              That is also what I have Niall. What is that extra folder you have there Dan?

                              This is the APPDATA path guys, not the Program Files path (or Program Files(x86) if your on Windows 6+.)

                              In the APPDATA path, below the "Sketchup #{VER}" folder, for PRO, there are 3 applet folders:
                              "Sketchup" (where the session.dat file is kept,) "Layout" and "StyleBuilder" folders. Each one of these folders holds user settings and preference files.

                              On Win7, the path should be:
                              " C:\Users\#{ENV['USERNAME']\AppData\Roaming\Google\Google SketchUp #{VER}\SketchUp\Plugins"

                              As I said, on the Mac the User's APPDATA "Plugins" folder is created by Sketchup, but on PC you need to create it yourself, and push the path onto the $LOAD_PATH array to use it for require() or load() calls.

                              If you wish (on PC,) to have user scripts load from the APPDATA path on Sketchup startup, you need to have a script in the "Shared" Plugins folder (the one in the Program Files path,) that has a call using the require_all() method from the sketchup.rb file.
                              Ex:

                              <span class="syntaxdefault"></span><span class="syntaxcomment"># !appdata_load.rb<br /></span><span class="syntaxkeyword">require(</span><span class="syntaxstring">'sketchup.rb'</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">VER </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">version</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_i<br />USER_PLUGINS </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="syntaxstring">"#{ENV['APPDATA']}\Google\Google SketchUp #{VER}\SketchUp\Plugins"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">require_all</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> USER_PLUGINS </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span>
                              

                              If you use it, the require_all() method will push the APPDATA plugins path onto the $LOAD_PATH array for you.


                              I do have a Win7 machine in the other room, but have not yet installed Sketchup on it, so... I'm going by what "should be" according to published information. (May be that the Sketchup installer has a mind of it's own.)

                              Addendum: On Win7 (linix-like) you may see a symbolic link directly to AppData, in the My Computer tree that hides the "C:\Users#{ENV['USERNAME']}" prefix.

                              I'm not here much anymore.

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

                                Sorry Dan, you lost me at "APPDATA". I never knew there was an alternate folder schema somewhere. I'm really not sure what appdata is.

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

                                1 Reply Last reply Reply Quote 0
                                • B Offline
                                  bentleykfrog
                                  last edited by

                                  @chris fullmer said:

                                  Sorry Dan, you lost me at "APPDATA". I never knew there was an alternate folder schema somewhere. I'm really not sure what appdata is.

                                  +1 on this, sorry for the confusion dan 😳

                                  Time to make a fool out of myself for a second time:

                                  @thomthom said:

                                  @chris fullmer said:

                                  That worked for me, are you guys seeing differently?

                                  The snippet I posted work for me when I added it to Bezier Tools as a working example. I generate a relative path from Sketchup.get_resource_path( 'helpcontent' )

                                  In the snippet you posted earlier, doesn't parts = origin.split( File::SEPERATOR ).size include the separator in the drive name (ie. C:/), so you get x+1 slashes to the root C:/ from helpcontent instead of x, which negates the /tool folder?

                                  Also, just to double-check, is there meant to be an escaping character for w in /^w:/ (ie. /^\w:/) or is something weird going on?

                                  sorry for the noob questions, I really appreciate the responses.

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

                                    @bentleykfrog said:

                                    In the snippet you posted earlier, doesn't parts = origin.split( File::SEPERATOR ).size include the separator in the drive name (ie. C:/), so you get x+1 slashes to the root C:/ from helpcontent instead of x, which negates the /tool folder?

                                    That is a possibility... I might very well be wrong about where it base the path from. But the positive side-effect of my little bug is that it works. 😄

                                    @bentleykfrog said:

                                    Also, just to double-check, is there meant to be an escaping character for w in /^w:/ (ie. /^\w:/) or is something weird going on?

                                    You're right. And it's there in my original code - it seems that the forum ate the escape character! 😮

                                    Lemme try again:

                                    Without PHP formatting:

                                    
                                      # Get Instructor Path
                                      #
                                      # Tool.getInstructorContentDirectory expects a path relative to SketchUp's
                                      # Resource/<locale>/helpcontent/ folder, despite the documentations use an
                                      # absolute path.
                                      #
                                      # This method is a wrapper that generates a path to the actual help content
                                      # which SketchUp can use.
                                      #
                                      # The given path must be under the same drive as SketchUp's help content.
                                      #
                                      # This quick exist in all current SketchUp versions.
                                      # Current; SketchUp 8 M1
                                      def self.get_instructor_path( path )
                                        path = File.expand_path( path )
                                        origin = Sketchup.get_resource_path( 'helpcontent' )
                                        # Check if drive matches
                                        origin_drive = origin.match( /^(\w);/ )
                                        if origin_drive
                                          origin_drive = origin_drive[1].downcase
                                        end
                                        path_drive = path.match( /^(\w);/ )
                                        if path_drive
                                          path_drive = path_drive[1].downcase
                                          path = path[2...path.size] # Trim drive letter
                                        end
                                        if path_drive && origin_drive
                                          return nil unless origin_drive == path_drive
                                        end
                                        # Build relative path
                                        parts = origin.split( File;;SEPARATOR ).size
                                        path_to_root = "..#{File;;SEPARATOR}" * parts
                                        relative_path = File.join( path_to_root, path )
                                        return relative_path
                                      end
                                    
                                    

                                    With PHP formatting:

                                    <span class="syntaxdefault"><br />&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;Get&nbsp;Instructor&nbsp;Path<br />&nbsp;&nbsp;#<br />&nbsp;&nbsp;#&nbsp;Tool.getInstructorContentDirectory&nbsp;expects&nbsp;a&nbsp;path&nbsp;relative&nbsp;to&nbsp;SketchUp's<br />&nbsp;&nbsp;#&nbsp;Resource/<locale>/helpcontent/&nbsp;folder,&nbsp;despite&nbsp;the&nbsp;documentations&nbsp;use&nbsp;an<br />&nbsp;&nbsp;#&nbsp;absolute&nbsp;path.<br />&nbsp;&nbsp;#<br />&nbsp;&nbsp;#&nbsp;This&nbsp;method&nbsp;is&nbsp;a&nbsp;wrapper&nbsp;that&nbsp;generates&nbsp;a&nbsp;path&nbsp;to&nbsp;the&nbsp;actual&nbsp;help&nbsp;content<br />&nbsp;&nbsp;#&nbsp;which&nbsp;SketchUp&nbsp;can&nbsp;use.<br />&nbsp;&nbsp;#<br />&nbsp;&nbsp;#&nbsp;The&nbsp;given&nbsp;path&nbsp;must&nbsp;be&nbsp;under&nbsp;the&nbsp;same&nbsp;drive&nbsp;as&nbsp;SketchUp's&nbsp;help&nbsp;content.<br />&nbsp;&nbsp;#<br />&nbsp;&nbsp;#&nbsp;This&nbsp;quick&nbsp;exist&nbsp;in&nbsp;all&nbsp;current&nbsp;SketchUp&nbsp;versions.<br />&nbsp;&nbsp;#&nbsp;Current;&nbsp;SketchUp&nbsp;8&nbsp;M1<br />&nbsp;&nbsp;</span><span class="syntaxdefault">def&nbsp;self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_instructor_path</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">path&nbsp;</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">path&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">expand_path</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">path&nbsp;</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">origin&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_resource_path</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxstring">'helpcontent'&nbsp;</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;Check&nbsp;if&nbsp;drive&nbsp;matches<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">origin_drive&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">origin</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">match</span><span class="syntaxkeyword">(&nbsp;/^(</span><span class="syntaxdefault">w</span><span class="syntaxkeyword">);/&nbsp;)<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;</span><span class="syntaxdefault">origin_drive<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;origin_drive&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">origin_drive</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">downcase<br />&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;path_drive&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">match</span><span class="syntaxkeyword">(&nbsp;/^(</span><span class="syntaxdefault">w</span><span class="syntaxkeyword">);/&nbsp;)<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;</span><span class="syntaxdefault">path_drive<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path_drive&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">path_drive</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">].</span><span class="syntaxdefault">downcase<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">2.</span><span class="syntaxkeyword">..</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">size</span><span class="syntaxkeyword">]&nbsp;</span><span class="syntaxcomment">#&nbsp;Trim&nbsp;drive&nbsp;letter<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">end<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">if&nbsp;</span><span class="syntaxdefault">path_drive&nbsp;</span><span class="syntaxkeyword">&&&nbsp;</span><span class="syntaxdefault">origin_drive<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxkeyword">return&nbsp;</span><span class="syntaxdefault">nil&nbsp;unless&nbsp;origin_drive&nbsp;</span><span class="syntaxkeyword">==&nbsp;</span><span class="syntaxdefault">path_drive<br />&nbsp;&nbsp;&nbsp;&nbsp;end<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;Build&nbsp;relative&nbsp;path<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">parts&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">origin</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">split</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">SEPARATOR&nbsp;</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">size<br />&nbsp;&nbsp;&nbsp;&nbsp;path_to_root&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxstring">"..#{File;;SEPARATOR}"&nbsp;</span><span class="syntaxkeyword">*&nbsp;</span><span class="syntaxdefault">parts<br />&nbsp;&nbsp;&nbsp;&nbsp;relative_path&nbsp;</span><span class="syntaxkeyword">=&nbsp;</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">path_to_root</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">path&nbsp;</span><span class="syntaxkeyword">)<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span class="syntaxdefault">relative_path<br />&nbsp;&nbsp;end<br /></span>
                                    

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

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

                                      grrr.... the PHP formatter broke the code!

                                      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

                                        @thomthom said:

                                        @bentleykfrog said:

                                        In the snippet you posted earlier, doesn't parts = origin.split( File::SEPERATOR ).size include the separator in the drive name (ie. C:/), so you get x+1 slashes to the root C:/ from helpcontent instead of x, which negates the /tool folder?

                                        That is a possibility... I might very well be wrong about where it base the path from. But the positive side-effect of my little bug is that it works. 😄

                                        Its definitely a positive side effect, and consistent across OS's as macs start with '/' instead of 'C:/'

                                        @thomthom said:

                                        With PHP formatting:

                                        PHP & escape characters == no love (not even with double escaping), which sucks with Regex. From my experience there's no telling how many processes a php string has been through on a forum post (ie. as written in your own code or copy-and-paste from another website/forum) so I think the php code goes on the singular escape and doesn't bother to check for doubles, which is wrong even if you're formatting php code. I suppose since sketchucation is in php, they've at least got to make the code mute to prevent some pretty easy hacking, by formatting php code as a string. (I'll stop here since its way off topic)

                                        1 Reply Last reply Reply Quote 0
                                        • B Offline
                                          bentleykfrog
                                          last edited by

                                          Initial testing on the mac works too, though there's no need to copy the instructor files to the temp directory on a mac 🎉

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

                                            @thomthom said:

                                            grrr.... the PHP formatter broke the code!

                                            Good catch!

                                            We best be careful from now on using the [ code = php ] bbtag.

                                            I'm not here much anymore.

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

                                            Advertisement