sketchucation logo sketchucation
    • Login
    1. Home
    2. alexmojaki
    3. Posts
    ℹ️ 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

    Posts

    Recent Best Controversial
    • 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
    • RE: How to make a frame/dialog/window always on top?

      So are you saying that in Windows, show() keeps the dialog always on top? I wasn't expecting that, since it certainly doesn't in Mac, and the API didn't seem to suggest that. Or the name of the function. Or just common sense. I thought that it shows it but then it can be hidden again when it goes out of focus.

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

      I want a small frame/dialog/window (showing a color gradient scale) to show in a corner in front of the model. I can't use a Web Dialog because it disappears to the background when I click on the model outside the dialog, and I can't use show_modal because in Windows that would mean (as far as I understand) that no interaction with the model is possible until the dialog is closed.

      I considered wxSU, but then when I tried installing it it didn't work for a while. I realised the problem was that the plugin files had been mysteriously placed inside the newly created folder 'Google Sketchup 7' instead of 8. This is on a Mac.

      This is for a commercial plugin, and I need it to be user friendly. I do not want to have to have installation instructions that say 'download and install wxSU, then maybe move some files from one folder to another.'

      Any suggestions please?

      posted in Developers' Forum
      A
      alexmojaki
    • RE: Complete Crash?

      OK...it doesn't crash if just before showing the savepanel I put a line of code to show a simple messagebox: then the savepanel shows. Although the messagebox is nowhere to be seen.

      Then I tried this code:

      			if UI.messagebox("Save results to file?", MB_YESNO) == 6
      				savePath = UI.savepanel("Save results file",model.path,"Sunlight analysis.csv")
      				# If the user doesn't press cancel;
      				if savePath
      					outfile = File.new(savePath, "w")
      					outfile.write(allResults)
      					outfile.close()
      				end
      			end
      

      Now when the execution reaches this point SU suddenly switches program, i.e. as if someone had pressed Alt+Tab. It's still there, but I have to reopen it. And the messagebox still isn't anywhere, hence neither is the savepanel. I just seem to have gotten the UI very confused in general.

      posted in Developers' Forum
      A
      alexmojaki
    • RE: Complete Crash?

      OK, I've narrowed it down a bit and this seems to be the line that makes it crash:

      savePath = UI.savepanel("Save results file",model.path,"Sunlight analysis.csv")

      If I Process.exit() just before that, SU stays open. Otherwise it crashes. Weirdly, though, not always. On a few occasions it survives. This is on Windows Vista: never had this problem on Mac in a whole lot of testing.

      posted in Developers' Forum
      A
      alexmojaki
    • Complete Crash?

      What can I do to debug a plugin when Sketchup just crashes and closes without any message or chance to see a problem on the Ruby console?
      My guess is that it's having problems colouring some faces, but it really shouldn't.

      posted in Developers' Forum
      A
      alexmojaki
    • RE: Forcing Sketchup to use IE8 and other Web Dialog problems
      1. Thanks, the scroll attribute worked. But what is Standards compliant mode? This is for a plugin that I want to distribute, so will this fix only work for some users?

      @dan rathbun said:

      Because I have caught myself doing this instead:

      I don't understand. What do you mean by this sentence? I can't even see if you're suggesting a solution or just pointing out that you have the same problem.

      posted in Developers' Forum
      A
      alexmojaki
    • Forcing Sketchup to use IE8 and other Web Dialog problems

      I use a Mac, and my Web Dialogs worked great there, but when I tested it on Windows they don't. Firstly, IE7 renders horribly. I installed IE8 and that looks better but I can see Sketchup is still using 7. Can I force it to use 8?

      Secondly, no scrollbars show. The required property in webdialog.new is true, and scrollbars are definitely needed. The content is clearly bigger than the screen.

      3: dialog.get_element_value isn't working. I know the required element ID exists and has a value because I've used javascript to test that it's there. But all I get is an empty string. This worked fine on Mac, it's as though IE is blocking the data from being sent.

      posted in Developers' Forum
      A
      alexmojaki
    • RE: Curved surfaces with Ruby

      @thomthom said:

      If you want to get a Surface - identical to how SketchUp defines with - when Entity Info display Surface - based on faces connected by soft+smooth edges when this snippet works: http://forums.sketchucation.com/viewtopic.php?f=180&t=41211#p365381

      Awesome! That snippet was exactly what I needed and it works great. Also glad to understand what soft and smooth edges are.

      Thanks a lot!

      posted in Developers' Forum
      A
      alexmojaki
    • RE: Offset tool in Ruby?

      Sweet, thanks.

      posted in Newbie Forum
      A
      alexmojaki
    • Offset tool in Ruby?

      How can I use Ruby to mimic the 'Offset' tool in SU? Given a face, I want to get a new face that's 1.5 m from the edges (on the inside), or just have a way of knowing if a given point would be on such a face.

      posted in Newbie Forum sketchup
      A
      alexmojaki
    • 1
    • 2
    • 1 / 2