Screen display text

When loading the model, the screen will be gray and prompt text will be displayed on the screen. After loading, the screen will exit the gray function and text will be cleared.I tried draw_text but it didn’t work and add_note wasn’t what I wanted。I tried transparent HTML to do this but I don’t know why transparent styles don’t work

Can you attach some screenshots and/or example models that demonstrate what you’re referring to?

This would modify the model by adding a leaderless Sketchup::Text object to the model’s entities, which would not be possible whilst it was loading.

This is meant for drawing non-entity graphics while a tool is running.

Since the tools collection for a model is destroyed and in the process of being initialized for the loading model, this probably would also not be helpful.

The WebDialog and HtmlDialog classes do not have the option of hiding their window frames nor background.

The best you could do is display a dialog as large as the model area with a gray background and the text message.

However, this is not really a workflow that SketchUp users will be accustom to. Ie, it would deviate from the normal user interface behavior.

First of all thank you for your attention

Thank you for your attention,I’ll think about your method and I’d like to ask you about the status bar text(“set_status_text()”) will flash when the model is loaded after it is set. It seems that the status bar text is refreshed at the time the model is loaded.Is there any way to synchronize it with the model loading time?

I’m sorry, I misunderstood you.This is the rendering of this function.

I’m not sure if understood right and if this make sense… here is my concept (without deep check) just for fun…:innocent:

module Dezmo
  module MyFancyModelOpener
    extend self

    class MyAppObserver < Sketchup::AppObserver
      def onOpenModel(model)
        puts "onOpenModel: #{model}"
        filename = model.path.split("\\").last
        return unless filename
        Sketchup.active_model.tools.push_tool( DrawScreenText.new(filename) )
      end
    end
    
    class DrawScreenText
      def initialize(text)
        @text = text
        @to_draw = true
        drawtext()
      end
      
      def drawtext
        view = Sketchup.active_model.active_view
        view.invalidate
        UI.start_timer(3, false) {
          @to_draw = false
          Sketchup.active_model.tools.pop_tool
          view.invalidate
          Sketchup.set_status_text("Loaded: " +@text)
        }
      end
      
      def draw(view)
        if @to_draw
          view.drawing_color = [128,128,128, 128]
          points = [
            view.corner(0),
            view.corner(1),
            view.corner(3),
            view.corner(2)
          ]
          view.draw2d(GL_POLYGON, points)
          view.draw_text(points[0], "Loaded: " +@text, color: "Red")
        end
      end
    end
    
    def start
      stop()
      @obs = MyAppObserver.new
      Sketchup.add_observer(@obs)
    end
    
    def stop
      Sketchup.remove_observer(@obs) if @obs
    end
    
  end
end
Dezmo::MyFancyModelOpener.start

fancymodelopener

1 Like

The status bar text is synchronized with the active tool. So it cannot be relied upon to display messages for utility tasks. If the user moves the mouse the status bar text for the active tool will be redisplayed and wipe out your message.

The refreshing you see during model loading is because the old model’s tool stack is destroyed, the status bar text for whatever tool was active is erased and the new loading model’s tool stack is initialized with the (default) Select Tool active, and status text telling how to make a selection.


I tried @dezmo’s example and it seems to work, but I think the gray screen is loaded after the new model loads not before.

And as I noted above, as soon as the mouse is moved, the status bar text is reset for the Select Tool.

1 Like

You are right, it is “unfortunate” (in this case) that is fire after, and not when it is start to load…

We have open issues about this …

Thank you for your attention. Your method looks very good. I can use it for reference

Thank you for your answer, which gives me a deeper understanding of this problem

I tried your method. It is good, but the status bar text still cannot be displayed when loading the model.

Yes, actually my method above - as Dan pointed out - is a little “cheat”, because the “overlay text” is displaying AFTER the model is loaded, and - to be able to see it there is a fixed timer (3 sec). :wink:

I don’t think we can have any observer to detect when the loading of the model starts… :frowning_face:

I think loading starts after using “import(‘filename’)”, and ends when it returns.But,I don’t know if it’s right.

That is entirely different story than the “When loading the model”…

So, Model #import-instance_method

  1. You can set the status bar text before importing, then during import it will stay, then the Place component will occur:
model = Sketchup.active_model
filename = "c:/test.skp"
Sketchup.set_status_text("Loading: " + filename)
model.import(filename)
  1. You can do it in a fancy way too:
    In this case there will be an overlay background with text in a corner until the import ready to place:
module Dezmo
  module MyFancyImporter
    extend self

    class DrawScreenText
      def initialize(filename)
        @filename = filename
      end
      
      def deactivate(view)
        view.invalidate
      end
      
      def activate
        model = Sketchup.active_model
        model.active_view.invalidate
        UI.start_timer(0, false) {
          model.import(@filename)
        }
      end
      
      def draw(view)
        view.drawing_color = [128,128,128, 128]
        points = [
          view.corner(0),
          view.corner(1),
          view.corner(3),
          view.corner(2)
        ]
        view.draw2d(GL_POLYGON, points)
        view.draw_text(points[0], "Loading " +@filename, color: "Red")
      end
    end
    
    def start(filename)
      Sketchup.active_model.select_tool( DrawScreenText.new(filename) )
    end
    
  end
end
Dezmo::MyFancyImporter.start("c:/test.skp")

.
Alternatively to load skp file you can use the DefinitionList #load method + Model #place_component-instance_method

model = Sketchup.active_model
filename = "c:/test.skp"
Sketchup.set_status_text("Loading: " + filename)
definition = model.definitions.load(filename)
model.place_component definition

Moreover:
The DefinitionList #import method is used to import a (non-SketchUp) 3d model file as a definition.

1 Like

Thanks again for your answer, I will try it