sketchucation logo sketchucation
    • Login
    1. Home
    2. alexmojaki
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    A
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 8
    • Posts 25
    • Groups 1

    alexmojaki

    @alexmojaki

    10
    Reputation
    1
    Profile views
    25
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    alexmojaki Unfollow Follow
    registered-users

    Latest posts made by alexmojaki

    • Bugsplat in Sketchup 2017 when manipulating groups

      I'm the author of the SunHours extension. Using the extension in Sketchup 2017 causes it to crash. Many users have emailed me about this but there's not much I can do since the bug is in Sketchup. I've narrowed the problem down to a minimal snippet of code which causes the crash:

      
      model = Sketchup.active_model
      model.start_operation("BOOM", true)
      
      entities = model.entities
      face = entities.to_a.select{ |ent| ent.is_a? Sketchup;;Face }[0]
      group = entities.add_group([face])
      group2 = entities.add_group([group])
      group.explode
      face = group2.entities.to_a.select{ |ent| ent.is_a? Sketchup;;Face }[0]
      group2.explode
      entities.add_group([face])
      
      model.commit_operation
      
      

      Creating a model with a single face and running that snippet in the Ruby Console will crash Sketchup with a bugsplat. Removing any single line (I think, I may have missed one) of the snippet will prevent the crash. I know the code looks strange and contrived but it is derived from real code (with lots of things in between removed) and the structure of creating and exploding groups is necessary.

      Please let me know if an update is released which fixes this issue.

      I'm on OSX but I don't think this is OS dependent.

      posted in Developers' Forum
      A
      alexmojaki
    • Save dialog causes bug splat

      Sometimes, when testing my plugin in Windows, it crashes completely as it tries to show the save dialog. It's hard to give specifics as this isn't consistent. In some cases, substituting the save dialog with a messagebox still causes a crash. Are there any tips to avoid the UI somehow causing a crash?

      posted in Developers' Forum
      A
      alexmojaki
    • RE: How to make a frame/dialog/window always on top?

      @alexmojaki said:

      Incidentally, I haven't tested any of this on Windows yet, so we'll see what happens when I try there. This might not be over yet.

      Aaaand...I'm back! Indeed, this solution doesn't really work on Windows, because as soon as window.blur() is called, it doesn't just remove focus from the dialog, but from the whole Sketchup application! Sketchup goes into the background, yet somehow it is the window that is open according to the taskbar, and if you click on it in the taskbar to try and reopen it it minimises it.

      posted in Developers' Forum
      A
      alexmojaki
    • RE: How to make a frame/dialog/window always on top?

      webdialog.execute_script('window.blur()') solves everything instantly. Did not know I could do that. Thanks a lot, driven!

      Thanks also to others for staying with my problem for so long.

      And yes, wxSU is available for Mac.

      Incidentally, I haven't tested any of this on Windows yet, so we'll see what happens when I try there. This might not be over yet.

      posted in Developers' Forum
      A
      alexmojaki
    • RE: How to make a frame/dialog/window always on top?

      Yes, I've seen the lost manual. What was critical to me at the beginning of the thread was that show in Windows kept the dialog on top (which isn't obvious), maybe add that to the manual.

      OK, I edited the wrong file when I was testing show_modal. So it works correctly. Then I discovered that the problem with my code is that for some reason when I reclick on the object to put Sketchup in focus, for some reason onSelectionCleared gets called, and then immediately after onSelectionBulkChange. I have no idea why: as far as I can see the selection never gets cleared. So the dialog was actually being closed, and then it wasn't opened again because I didn't edit @prevSelection when the selection was cleared. But now that I've done that, I'm back to the original problem: each time I click on the object to try and put Sketchup in focus, the dialog is closed and reopened and so regains focus.

      So now it seems my main problem is that the selection is momentarily cleared unnecessarily. In fact, I tested a bit more and found that it seems to get cleared pretty much all the time. It hasn't even got anything to do with the dialog or reclicking, onSelectionCleared gets called whenever I change my selection at all. I need to keep the definition because onSelectionBulkChange doesn't react to clicking an empty space. So I need a way to distinguish between the selection being genuinely cleared and this quirk. I considered InputPoint, but I've never used that before and I don't see how it can be used from the context of a SelectionObserver.

      posted in Developers' Forum
      A
      alexmojaki
    • RE: How to make a frame/dialog/window always on top?

      @thomthom said:

      show_modal will keep the WebDialog on top of the SketchUp window under OSX. But not on top of all other child windows of SketchUp.

      Well, for me it's not even showing on top of the main Sketchup window. I have no other dialogs open, the only other window is Sketchup itself. And when I click on it, the dialog disappears right behind it.

      @tig said:

      Your test
      if #the selection is appropriate# and sel.length>0
      ???
      Presumably you have some 'real code' in there... otherwise the line is
      if
      as everything after the first # is ignored ?
      Then you'll always get 'b'...

      Yes, I replaced the real code with the comment.

      @tig said:

      Also [incidentally] the
      path = Sketchup.find_support_file("scale.html",#...#)
      would be better as
      path = File.join(File.dirname(__FILE__), "scale.html")
      assuming it's in the same folder as the ruby script itself...

      Thanks, I'll give that a try.

      @chris fullmer said:

      No, you can draw it to the screen if you make your own 'tool'. Use the view.draw method of your tool class and you can do some pretty interesting things.

      BUT, that requires the user to be using your tool so they can see the info you've written to the screen. Once they switch to rotate or pan or select, move, etc the data disappears. So it is also flawed.

      Thanks, I'll consider that. But still not ideal, of course. Is that all then?

      posted in Developers' Forum
      A
      alexmojaki
    • RE: How to make a frame/dialog/window always on top?

      So, returning to my original question, since WebDialogs won't work, how do you suggest that I make the scale always show on top? Is wxSU my only option?

      posted in Developers' Forum
      A
      alexmojaki
    • RE: How to make a frame/dialog/window always on top?

      Sigh. OK, thanks. You should probably also note that neither show nor show_modal keeps the window on top in Mac. I've even checked with another case.

      posted in Developers' Forum
      A
      alexmojaki
    • RE: How to make a frame/dialog/window always on top?

      OK, it's not working as I had hoped.

      What I wanted was for the dialog to show when a particular object was selected. It does, but then I want the user to be able ton continue to interact with the model, e.g. orbit the camera, while the scale is still showing, just out of focus. But when the object is selected, and the dialog appears, it of course starts out by being in focus. While I'd like this to not happen, it's acceptable. But when I click on the same object again, onSelectionBulkChange gets called again, even though nothing has changed, and so before it would 'reshow' the dialog, thus keeping it in focus no matter what, and making it impossible to use Sketchup. I tried inserting a conditional to avoid this so that the dialog is only shown when the selection is genuinely changed, but now when I re-click the same selection to try and bring Sketchup into focus, the dialog disappears completely. It's not even in the background, and it's certainly not on top as I thought show_modal would make it. I know from the puts statements that the conditionals are working as expected: only 'b' is output, so the dialog isn't being closed. It's just not staying on top.

      class ScaleSelectionObserver < Sketchup;;SelectionObserver
      	
      	def initialize()
      		@dialog = UI;;WebDialog.new("Color scale", false, "Color scale", 70,160,5,100, true)
      		path = Sketchup.find_support_file("scale.html",#...#)
      		@dialog.set_file(path)
      		@prevSelection = nil
      	end
      	
      	def onSelectionBulkChange(sel)
      		if #the selection is appropriate# and sel.length>0
      			puts 'b'
      			if not sel.to_a==@prevSelection
      				puts 'a'
      				@dialog.show_modal
      				@prevSelection = sel.to_a
      			end
      		else
      			puts 'hi'
      			@dialog.close
      		end
      	end
      	
      	def onSelectionCleared(sel)
      	    @dialog.close
      	end
      end
      
      # Attach the observer.
      Sketchup.active_model.selection.add_observer(ScaleSelectionObserver.new)
      
      posted in Developers' Forum
      A
      alexmojaki
    • RE: How to make a frame/dialog/window always on top?

      Awesome, thanks a lot to both of you!

      posted in Developers' Forum
      A
      alexmojaki