Sketchup request does not work when called at start but otherwise

In the plugin , on start , if a request is called then response is not returned.
But when the button is clicked and same request is executed , correct response is returned.

PluginName: testsentio (3.3 KB)

you should look at ‘lazy loading’ all of your files, so they don’t load on startup…

you can add an over-ride for debugging, and comment out for deployment…

## Tidied up code below in latter post...


Sorry i do not understand how this will help because flow seems to be same.
Also I have toolbar in the plugin so that should load on startup.

the flow IS different, as it’s deliberately withholding the loading…

you should add cmd’s [so you can add a shortcut key] then use the cmd for menu and toolbar…

I tidied up the first post’s ruby…

you need to change ENV['LOGNAME'] == 'johns_iMac' to your computer…

module TestSolutionario
  module TestSentio

    DEBUG ||= true if ENV['LOGNAME'] == 'johns_iMac'

    def lazy_load
      require 'sketchup.rb'
      require 'net/http'
      require 'json'
      require 'pathname'

      Sketchup.require(File.join(File.dirname(__FILE__), "config"))
      Sketchup.require(File.join(File.dirname(__FILE__), "sentio_logger"))
      Sketchup.require(File.join(File.dirname(__FILE__), "csrf_request"))
      Sketchup.require(File.join(File.dirname(__FILE__), "pluginreloader"))

    def init if DEBUG

      csrfReq =
      csrfReq.get_token { |t| puts "#{t}"}

    unless defined? MENU

			# add a cmd for menu, toolbar or shortcut item...
			title = 'TestSentioVR'
			cmd   = do

			cmd.tooltip = cmd.status_bar_text = 'cmd_message...'

			cmd.large_icon = cmd.small_icon = File.join(__dir__, 'Resources', 'images', 'name')

			MENU ||='Plugins', title)
                       menu = MENU
			# menu item
			# create toolbar
			TBAR ||=
                        tb = TBAR
			# toolbar item
			# showing the toolbar
			tb.get_last_state  == TB_NEVER_SHOWN ? : tb.restore


    if DEBUG


EDIT: made some minor changes to constants…


1 Like

Thank you @john_drivenupthewall for explaining. I will try out these changes.

ENV["LOGNAME"] is Mac only. Windows uses ENV["COMPUTERNAME"]

1 Like

One more thing if on the startup I want to request some information from server.
Can’t I do that like version check or login.

on SU startup there are could be lots of request coming from many extensions…

this can lead to missed conections, loading delays or even crashes…

ALL extensions should do their checks only when the user wants to run them, not on SU startup…

on Extension startup [ using ‘lazy loading’ ], when the user clicks any of your buttons, you have a clear path for your checks…

they’ll happen quicker and have less potential issues…

if they fail, you can let the user know without the risk of your message being swallowed…


I tend to wrap everything in a proxy object, so that references can get passed to other objects, but initialization only occurs when a method is really called.

See for more info on the proxy design pattern.