sketchucation logo sketchucation
    • Login
    1. Home
    2. eneroth3
    3. Posts
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    ⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 5
    • Posts 195
    • Groups 2

    Posts

    Recent Best Controversial
    • RE: Web dialogs stealing focus within my tool.

      I've been thinking about an implementation. In some cases the developer might not want this so it shouldn't always be enabled (and it could break existing plugins). What about an extra argument for creating web dialogs that by default is false?

      There could also be a check on the web side that prevents the key event from being sent to SU in case an input or textarea element is focused.

      One scenario where the developer don't want to send the key events to Sketchup (except for the obvious one of writing in a form) could be custom shortcuts within the web dialog (save, reload etc).

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: Web dialogs stealing focus within my tool.

      Sidenote: when using paint bucket tool and the main window is focused the mouse cursor changes wen pressing and releasing modifier keys as expected. When the material browser is focused the mouse cursor changes when pressing down a key BUT NOT when releasing it. However the mouse cursor updates as soon as you move the mouse so the tool seems to know that the modifier keys aren't hold down, it's just the cursor that doesn't update.

      Tested in SU 2013 and 2014 on Windows7

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: [Info] Allowable Classes for "set_attribute"

      All points and vectors change, even if you add Geom::Point3d.new to the attribute, not just those that refers to a moved vertex.

      I suppose a change in the behavior would affect more plugins than just mine. Also it would break backward compability unless you write separate code for older versions which will be much harder to maintain. Also the bounding box is always aligned with the coordinate axes so rotating entity would break the relation between the bounding box origin and a point relative to the entity.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: Overwritten script!!!

      How can something.html overwrite something.rb? The file names differs.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: Web dialogs stealing focus within my tool.

      To make this script 140% complete you probably need to send those key events directly to the Sketchup main window as Dan says and also make the javascript function check that no form input is currently focused.

      However this seems to solve my issue and the only thing you need to do in my plugin to be able to use all Sketchup shortcuts is to either click in the main window (just as before) or close the web dialog containing the tool settings which automatically activates the select tool.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: Web dialogs stealing focus within my tool.

      I've just written the code and it seems to work nicely.

      External javascript file (loaded by all web dialogs:

      
      function port_key(){
        //Sends the keycode from the event to a Ruby callback.
        //This can be used for web dialogs inside a custom tools to send key events to the tool to change its behavior even when the web dialog is focused.
        //Run "document.onkeyup=port_key;" to initialize. onkeyup is used to avoid overriding calls to onkeydown already in use in the dialog. onkeypress doesn't fire for modifier keys.
        e = window.event || e;
        keycode = e.keyCode || e.which
        
        //It might be wise to only proceed for certain keys here, e.g. modifier keys or whatever keys are used in the tool.
        
        window.location='skp;port_key@' + keycode;
      }
      
      

      In Dialog.show:

      
      js = "document.onkeyup=port_key;"
      @dialog.execute_script js
      
      

      Dialog callback:

      
      #Port key event to tool
      @dialog.add_action_callback("port_key") { |_, callbacks|
        self.onKeyDown callbacks.to_i, false, 0, Sketchup.active_model.active_view#This tool doesn't use flags so it can just be set to 0
      }
      
      

      I haven't really bothered locking into the flags since my tools doesn't use them, just tab, alt, and arrow keys.

      Here's a list of the constants representing key codes in SU and here's the key codes from the javascript events in different browser.

      It's only tested on windows but the key codes seem to match quite well for most of the keys. My code might have some Mac bugs though, idk since I can't test it.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: Web dialogs stealing focus within my tool.

      @driven said:

      @eneroth3 said:

      ... so the shortcuts keys within my tool doesn't work until the main window is clicked.

      thinking out load...

      why send the shortcut when you can send your tool an instruction directly?

      john

      Then I have to make a separate list of what to do with what key. I haven't written any of this code yet but the idea was to have one javascript function for all my different tools that just sends the key code to onKeyDown which differs between the tools and and does different things with different keys.

      @dan rathbun said:

      BTW.. I think Fredo was playing with a way to draw toolbar or setting controls, directly onto the model viewport during a tool's active state.

      I've thought about that but it would require me to recode a lot of stuff. Also some of the web dialogs are quite big so it's good to be able to move them around so they don't cover the part of the viewport where the user currently draws.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • Web dialogs stealing focus within my tool.

      Hi all!

      I'm using web dialogs for providing some settings for some of my tools. The problem is that the web dialogs when used take focus from the main Sketchup window so the shortcuts keys within my tool doesn't work until the main window is clicked.

      I was thinking about making a javascript keypress event that sends key code to ruby where the onKeyDown method can be called. I just wondered if anyone has done something similar or know of some other solution to the same problem.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: [Info] Allowable Classes for "set_attribute"

      My railroad plugin relies heavily on these data being transformed. When a track is manually moved the bezier control points are moved with it and read by the extension so it knows where the track is located and trains can run on it. I was quite worried how to code this until I accidentally ran into this behavior. It can be really useful and if you don't want it it's easy to store the coordinates in an array instead of Point3d or Vector3d (which is what I do in another part of the plugin).

      However this really really really should be documented!

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: [Info] Allowable Classes for "set_attribute"

      After some tests in SU2013 I found out that these classes are not transformed when using move!, transform! or transformation= on the entity, but they are when using the move, rotate or scale tool on it.

      This might be quite useful for custom animations scripts since things like rotation axes etc can be saved as attributes to the entities being transformed without be changed by the animation. When creating the mechanic parts for my railroad plugin I turned these data into normal arrays to avoid them from being transformed but perhaps that wasn't required.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: [Info] Allowable Classes for "set_attribute"

      Perhaps it's worth mentioning that Point3ds and vector3ds are transformed along with the geometry they belong to when using move tool or rotate tool on it.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: Use Sketchup default cursors

      @thomthom said:

      http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/ui.html#create_cursor
      http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/ui.html#set_cursor
      http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/tool.html#onSetCursor

      These links you give me 404 errors 😒 . I know I've read about this somewhere else recently but can't remember where now.

      EDIT:

      It might have been from when I read in TT lib the other day to understand how the win32api works. Found this page now: https://bitbucket.org/thomthom/tt-library-2/src/9ff3a5f08604ed477eb4b17fd63612bfc42832dd/TT_Lib2/cursor.rb?at=Version%202.9

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • RE: Plugin downloads

      You can also install plugins from Sketchup's own site, http://extensions.sketchup.com/. In Sketchup 2013+ you can even reach this from within Sketchup in the Windows menu (on pc, don't know what it's called on Mac).

      posted in Newbie Forum
      eneroth3E
      eneroth3
    • RE: Finding deepest entity in pick path

      Why not πŸ˜„ . It would be nice if more people could find and use the plugins.

      posted in Developers' Forum
      eneroth3E
      eneroth3
    • Finding deepest entity in pick path

      Hi

      First of all sorry if this isn't the right place to ask for help when coding plugins. This is my first post here.

      I'm having some troubles finding the deepest picked element with a pick helper. leaf_at(0) works great as long as the element is a child of the current drawing context (inside a group inside a group etc) but not in parent drawing context.

      I'm writing a custom interference and need to be able to pick any shown edge or construction line, no matter if it's in a group, in parent drawing context, in a group in parent drawing context or anywhere else. For edges inputPoint.edge works great but there is no inputPoint.cline (at least not documented).

      This is what I've got so far in my onMouseMove

      if(@ip.edge)
      	#Line from edge
      	line = @ip.edge.line
      	line.each{|i| i.transform!(@ip.transformation)}
      else
      	#Line from c-line (I wish there was a cline property for input points)
      	@ph.do_pick(x, y)
      	#NOTE; Returns entities in groups/components but not parent drawing context (and not inside groups/components in parent drawing context)
      	picked = @ph.leaf_at(0)
      	puts picked.class#used to see what element is picked, NilClass when hovering c-lines in parent drawing context D';
      	if(picked.class == Sketchup;;ConstructionLine)
      		line = [picked.position, picked.direction]
      		line.each{|i| i.transform!(@ph.transformation_at(0))}
      	end#if
      end
      
      #Do stuff with line...
      
      posted in Developers' Forum
      eneroth3E
      eneroth3
    • 1 / 1