sketchucation logo sketchucation
    • Login
    1. Home
    2. Anton_S
    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
    A
    Offline
    • Profile
    • Following 0
    • Followers 7
    • Topics 52
    • Posts 1,261
    • Groups 2

    Posts

    Recent Best Controversial
    • RE: Sketchup Source Files

      @thomthom said:

      If you are interested in how 3d apps work, have a look at Blender for instance, complete 3d package fully open source with available source code.

      Besides that, searching for various 3d functions and you'll find examples. Raytracing you will find for sure. I came across a video the other day where the guy was writing a raytracer 3d render in 30 minutes or so.

      Thank's πŸ˜„ , The first time I took a look at blender's source was yesterday, but I didn't thought about examining it and now I will!!!!!

      posted in SketchUp Discussions
      A
      Anton_S
    • RE: Sketchup Source Files

      lol.. Ok, but they wrote functions somehow and then compiled them to dlls

      posted in SketchUp Discussions
      A
      Anton_S
    • Sketchup Source Files

      Sketchup it self was writen on some program, probably on c++. I'm introsted in getting the source files. I just wanna learn/examine how its writen. πŸ€“ Ex: Examine raytest function, Sketchup::view Class, and many more... So, is there a way I could get the source code, or does even lisence alow that?

      posted in SketchUp Discussions sketchup
      A
      Anton_S
    • RE: Win32 Utils

      @dan rathbun said:

      See: this [ Info ] topic, it should lead you to more information, other topic posts, etc. Be prepared to waste a bunch of time learning...
      [Info] C/C++ Ruby extensions & SketchUp plugins

      Thanks for that info I'll take the time it needs to learn all that πŸ€“ ...

      About win32-api: It is good that they release the source code, but why wouldn't they release the source + the compiled api?

      About Ruby: My Operating System is Windowns XP and it uses .dll file libraries, but why all ruby libraries are writen in .so files(Linux Library)? πŸ˜•

      posted in Developers' Forum
      A
      Anton_S
    • RE: Win32 Utils

      @jim said:

      I would recommend using TT_Lib2, but I don't see what software license it uses. Thomas?

      πŸ˜„ Thanks, I downloaded it and look forward to use it.

      @dan rathbun said:

      Latest ver is 1.4.8, but you have to compile the mswin32 edition. (He does supply a pre-compiled api.so binary for the mingw edition.)

      ADD: win32-api is released under Artistic License 2.0, which ThomThom must abide by for that portion of his library.

      Okay thanks!!! The latest gem is with me now, but how do I compileit? - I have 3 ruby versions: 1.8.6, 1.8.7, and1.9.2

      posted in Developers' Forum
      A
      Anton_S
    • Win32 Utils

      Ok as some of us know Ruby Win32API doesn't support callbacks 😞 and it was writen a long time ago. Read http://forums.sketchucation.com/viewtopic.php?f=180&t=33756&p=296865#p296865 to get familiar with the problem. But Its not the end of the world ❗ - My idea was to get the callback function by using win32 Utilities: http://rubyforge.org/frs/?group_id=85&release_id=37782 πŸ˜„ Actually it wasn't my idea, but I love it. πŸ˜„ My problem: I donwloaded win32-api-1.4.5.zip and don't know which file to use to interact with new module win32 + ::API in this case. Or is there a different way I should do that?

      posted in Developers' Forum
      A
      Anton_S
    • RE: SU9 Ruby Version

      Hmmm... Ok, jst wanted it since the DL includes callback function and the ruby itself is cleaner and better, but I know there's a diff way - I could jst use the Win32::API utility to get/set callbacks. πŸ˜„

      posted in SketchUp Feature Requests
      A
      Anton_S
    • SU9 Ruby Version

      Sketchup is getting newer, but its ruby version is still old as 1.8.6. So, my wish is that SU9 would use latest ruby version, which is like 1.9.2.

      Thanks πŸ˜„

      posted in SketchUp Feature Requests sketchup
      A
      Anton_S
    • RE: Mouse Capture (Win32 API)

      Here is the way to get most of mouse input(no wheel scrool or side-to-side input) and all keyboard inputs.
      http://sketchup.google.com/3dwarehouse/details?mid=e530ef9d408f78ce6a464cb0e6f0895

      It is still not a good way to get the input messages, since it it has to be called all the time to get the input, but its also not that bad for the start. Mouse Wheel Scroll and side-to-side click input, is somewhere in the different function, but it's not really important now. My dad is still writing a script with me that would hook all keyboard and mouse messages and send them to array of active key inputs. So, the mouse wheel function is not important now because when the hoocking script would be active the function could just return us an input message of mouse wheel. Ex: forward scroll, backward scroll, side-to-side click and some more messages that would incounter the mouse wheel usage.

      posted in Developers' Forum
      A
      Anton_S
    • RE: Mouse Capture (Win32 API)

      @unknownuser said:

      Very nice, that works perfectly in SP!
      Is there a way to just get the full array of buttons and not call the function for every button specifically because it seems like a waste.

      Yes there is a way and this is what my dad will be doing. The program would receive the mouse or keyboard signals and send the input signals to sketchy physics operation, preventing them to interupt with SU.

      posted in Developers' Forum
      A
      Anton_S
    • RE: Mouse Capture (Win32 API)

      Well here is what I got for NOW, but it's the way where u allways have to call the function to get the input:

      onstart{
       require "Win32API"
       
       @rc=0 #var preventing release function to be called more than once, just to make the script accurate.
       @getKeyState=Win32API.new('user32', "GetKeyState", "L", "L")
       getForegroundWindow = Win32API.new('user32', 'GetForegroundWindow', [], 'L')
       setCapture = Win32API.new('user32', 'SetCapture', 'L', 'L')
       setCapture.call(getForegroundWindow.Call())
      }
      
      ontick{
       if (frame==1000 or key(" ")==1) and @rc==0 then
        @rc=1
        releaseCapture = Win32API.new('user32', 'ReleaseCapture', 'V', 'L')
        releaseCapture.call()
       end
       model=Sketchup.active_model
       entities=model.entities
       view=model.active_view
       entities[0].text=@getKeyState.call(VK_LBUTTON).inspect + "
      " + @getKeyState.call(VK_RBUTTON).inspect
      }
      
      onend{
       if @rc==0 then
        releaseCapture = Win32API.new('user32', 'ReleaseCapture', 'V', 'L')
        releaseCapture.call()
       end 
      }
      

      The model is here: http://sketchup.google.com/3dwarehouse/details?mid=f0ca091fd0760cfc6a464cb0e6f0895

      Virtual key codes: http://msdn.microsoft.com/en-us/library/dd375731(v=VS.85).aspx

      posted in Developers' Forum
      A
      Anton_S
    • RE: Mouse Capture (Win32 API)

      Mr.k u know that capturing mouse is a very, very, Very good idea! β˜€
      Now Instead of Creating a SketchyPhysicsControllClient we can capture the keyboard and mouse by by hoocking the signals and sending them instead to sketchy physics operation.

      Since my dad is new to Ruby Programing Language, it takes more time for him and me to write this code. His idea is to first write it on Delphi and then me, him, and most likely with ur help would try to convert it to Ruby. πŸ˜„

      posted in Developers' Forum
      A
      Anton_S
    • RE: Mouse Capture (Win32 API)

      So, u need to get the mouse back to react to u. You say that the release function doesn't works or return's errors in ruby console? If thats what you mean, then here is how to get it back to work:

      First when calling the release function(http://msdn.microsoft.com/en-us/library/ms646261(v=VS.85).aspx) You should avoid extra parameters. The script says:

      @unknownuser said:

      • release mouse
        releaseCapture = Win32API.new('user32', 'ReleaseCapture', 'L', 'L') releaseCapture.call()

      The underlined "L", which represent's the number, says that while calling that function you need to add a required parameter>>, but there is nothing required. So you need to change that first "L" to "V", which is void. And then it won't require you any parameters, even though this function still doesn't has any required parameters.

      The reason Win32API was written like that >> there would be a plenty of ways to call the function, and so the user could know in what form the function is required and return its objectives.

      The second "L" is now the user's idea to choose the function's returning mode. Ex: putting "V" would make the function to return nothing.

      In my way the function should sound like that:
      releaseCapture = Win32API.new('user32', 'ReleaseCapture', 'V', 'L') releaseCapture.call()

      Then it will work - I even checked it. The mouse was captured and then released. Ex:

      ` ontick{
      if frame==10
      model=Sketchup.active_model
      entities=model.entities
      view=model.active_view

      getForegroundWindow = Win32API.new('user32', 'GetForegroundWindow', [], 'L')
      window_handle = getForegroundWindow.Call()
      setCapture = Win32API.new('user32', 'SetCapture', 'L', 'L')
      setCapture.call(window_handle)
      end

      if frame==200
      releaseCapture = Win32API.new('user32', 'ReleaseCapture', 'V', 'L')
      releaseCapture.call()
      end
      }`

      Here's the URL what explains some of that: http://phrogz.net/ProgrammingRuby/lib_windows.html#Win32API

      And Here's the windows API reference: http://msdn.microsoft.com/en-us/library/aa383749(VS.85).aspx

      If that was not what u wanted then PLEASE make it more clear!!! - My dad is really good at win32API stuff. πŸ˜„ He's Smart >> πŸ€“

      Thanks for asking!!! πŸ˜„

      posted in Developers' Forum
      A
      Anton_S
    • RE: Changing Command Icons of the Toolbar

      @thomthom said:

      @tig said:

      Bum! 😞
      The best you could do then for something like a 'Play' > 'Stop' button is to have two buttons side by side, with one disabled [grayed-out] if the other one is enabled - using a validation_proc...

      Or for Play/Stop, just make the Play button pressed or not pressed - using MF_CHECKED and MF_UNCHECKED.

      Yeah Thanks!...
      This would not be a bad idea.
      I think changing toolbar icons should be part of SU 9 wishes. πŸ˜„

      posted in Developers' Forum
      A
      Anton_S
    • RE: Changing Command Icons of the Toolbar

      Thanks TIG, but I already tried that way and it didn't work after the command was added to the toolbar, u can refer to the Mr.K post above.

      posted in Developers' Forum
      A
      Anton_S
    • RE: Changing Command Icons of the Toolbar

      Hay, thanks >>>>>>>>>>>>> I will!!!!!!!!!!!!!
      And by the way nice Pen tool, It's much more comfortible to use them!!!! Thanks!!!

      posted in Developers' Forum
      A
      Anton_S
    • RE: Changing Command Icons of the Toolbar

      No u didn't get it, I want to toggle between two or more icon images in the same command button. Like toggling between play and pause icon images. Ex: Click play icon changes to pause image, then click again icon changes back to play image. Is there a way for that?

      posted in Developers' Forum
      A
      Anton_S
    • Changing Command Icons of the Toolbar

      In my 1st post I had a question about if it is posible to change icons after the command already had an icon set to it. I tried many differrent ways to write a script for that, but none of it worked. I've done many tests on that and figured out that once the icon is set for some command, it can not be changed. Here's one example that icon cannot be changed:

      toolbar=UI;;Toolbar.new("Test")
      cmd=UI;;Command.new("clear_selection") { Sketchup.active_model.selection.clear }
      cmd.small_icon = cmd.large_icon = "image01.png"
      toolbar.add_item(cmd)
      # Changing item icon after adding the item doesn't work.
      cmd.small_icon = cmd.large_icon = "image02.png"
      toolbar.show()
      
      

      After Command "clear_selection" was added to the toolbar, another code activated to change the icon of "clear_selection" command, but could not really change it.

      So, my question: Is there a way to change an icon even though i think there isn't?

      posted in Developers' Forum
      A
      Anton_S
    • Getting cursor position while SP simulation is running.

      I post this because of November92's question: http://sketchup.google.com/3dwarehouse/details?mid=c366d4f6b95601de846af18c94f69f1a&prevstart=0

      My Scirpt in previous model is old and is not working now because of different LS.
      November92 basicly wants to get the cursor position while simulation is running, so the script is here.

      Note:
      This script only works in SU8. For some reason SU7 crashes when click play.
      If anybody could make this script work in SU7 too, please post and say what is wrong in the script or what is need to be added or changed.

      Anyway, copy this script to Scripted file:

      onstart{
       #### Variables ####
       $cursor_pos=[0,0]
       
       #### Loading File ####
       if defined?($tempfile_loaded)==nil then #prevent from loading more than once
        directory=Object;;Dir.pwd.split(";/")[0]+";/"
        tempfile=Object;;File.new(directory+"SUtempfile.rb","w+")
        tempfile.puts('module MSketchyPhysics3
       class SketchyPhysicsClient
        def onMouseMove(flags,x,y,view)
         $cursor_pos=[x,y] #Here is our variable
         @mouseX=x
         @mouseY=y    
         if @CursorMagnetBody==nil then return() end
         ip=Sketchup;;InputPoint.new
         ip.pick(view,x,y)
         if ip.valid? then
          if @pickedBody!=nil then
           @simulationContext.doOnMouse(;drag,@pickedBody,x,y) 
           if getKeyState(VK_LSHIFT) then
            #project the input point on a plane described by our normal and center.
            ep=Geom.intersect_line_plane([view.camera.eye,ip.position],[@attachWorldLocation,view.camera.zaxis])
            @attachWorldLocation=ep
            pos=ep
           else
            ep=Geom.intersect_line_plane([view.camera.eye,ip.position], [@attachWorldLocation,Z_AXIS])
            pos=ep
            @attachWorldLocation=ep
           end
           @magnetLocation=pos
           if @CursorMagnet!=nil then NewtonServer.magnetMove(@CursorMagnet,pos.to_a.pack("f*")) end
          end
         end
        end #OnMouseMove
       end #class SketchyPhysicsClient
      end')
        tempfile.close
        load(directory+"SUtempfile.rb")
        Object;;File.delete(directory+"SUtempfile.rb")
        $tempfile_loaded=true
       end
       
       #### Functions ####
       def getCursor(state=0)
        view=Sketchup.active_model.active_view #Shortcut
        case state
         when 0, "coordinates";
          return($cursor_pos) #return's cursor coordinates
         when 1, "position";
          return(view.inputpoint($cursor_pos[0],$cursor_pos[1]).position.to_a) #returns 3d position
         when 2, "best_picked";
          return(view.pick_helper($cursor_pos[0],$cursor_pos[1]).best_picked) #returns entity
        end
       end
      }
      

      Now by calling function getCursor(state) you can get the cursor position and some other.
      Example:

      ontick{
       Sketchup.active_model.entities[1].text=getCursor(1).inspect
      }
      

      Other:
      Writing my scripts I always began using notepad++.
      If anybody need it go here, it's free: http://notepad-plus-plus.org/release/5.9.2

      posted in SketchyPhysics
      A
      Anton_S
    • Cursor Position To November92

      **This is the answer to November92, so don't think that this is a question or something.**First: My mouse command model is very old and now doesn't works, so to get the cursor position here is the new way:

      SP is a tool writen by CPhillips that allows the user to see object in simulation.
      This Tool has the Tool Functions writen into it(http://code.google.com/apis/sketchup/docs/ourdoc/tool.html). One of the functions is
      deactivate- The Tool activated when the different tool is selected. For Example: Lets say you click play and then turned off the SketchyPhysicsTool Dialog. After that lets say you select key("space") and see that SP simulation canceled or discontinued. When you select key space, by default the user should get the black cursor that is the nil tool. Or lets say when select key("q"), the simulation quit's and the user gets the rotate tool. What if you want both tools to activate? - to do that the deactive function should not have a script in it that calls the reset SP Simulation. The tool also has the function "onMouseMove". This is the function that can return you the [x,y] cursor position, which is relative to Sketchup view. SP has a script writen to it that does something, but it doesn't has the variables in it that would record the cursor position and that would be allowed to be called from outside of a class. So to get them we can't write our own tool, because if we will then this tool would not be able to be called while SP simulation is running because the deactive function would be called. To do that we need to edit the SP SketchyPhysicsClient tool. So here is how to do it:

      Copy or write this to the scripted part.

      onstart{
       #### Variables ####
       $cursor_pos=[0,0]
       
       #### Loading File ####
       if defined?($tempfile_loaded)==nil then #prevent from loading more than once
        directory=Object;;Dir.pwd.split(";/")[0]+";/"
        tempfile=Object;;File.new(directory+"SUtempfile.rb","w+")
        tempfile.puts('module MSketchyPhysics3
       class SketchyPhysicsClient
        def onMouseMove(flags,x,y,view)
         $cursor_pos=[x,y] #Here is our variable
         @mouseX=x
         @mouseY=y    
         if @CursorMagnetBody==nil then return() end
         ip=Sketchup;;InputPoint.new
         ip.pick(view,x,y)
         if ip.valid? then
          if @pickedBody!=nil then
           @simulationContext.doOnMouse(;drag,@pickedBody,x,y) 
           if getKeyState(VK_LSHIFT) then
            #project the input point on a plane described by our normal and center.
            ep=Geom.intersect_line_plane([view.camera.eye,ip.position],[@attachWorldLocation,view.camera.zaxis])
            @attachWorldLocation=ep
            pos=ep
           else
            ep=Geom.intersect_line_plane([view.camera.eye,ip.position], [@attachWorldLocation,Z_AXIS])
            pos=ep
            @attachWorldLocation=ep
           end
           @magnetLocation=pos
           if @CursorMagnet!=nil then NewtonServer.magnetMove(@CursorMagnet,pos.to_a.pack("f*")) end
          end
         end
        end #OnMouseMove
       end #class SketchyPhysicsClient
      end #module MSSketchyPhysics3')
        tempfile.close
        load(directory+"SUtempfile.rb")
        Object;;File.delete(directory+"SUtempfile.rb")
        $tempfile_loaded=true
       end
       
       #### Functions ####
       def getCursor(state=0)
        view=Sketchup.active_model.active_view #Shortcut
        case state
         when 0, "coordinates"; #cursor screen coordinates
          return($cursor_pos())
         when 1, "position"; #3d Position
          return(view.inputpoint($cursor_position[0],$cursor_position[1]).position.to_a)
         when 2, "best_picked"; #Entity at which the cursor is pointing
          return(view.pick_helper.do_pick($cursor_position[0],$cursor_position[1]).best_picked.to_a)
        end	
       end
      }
      

      Now We can Use this getCursor Function to get its coordinates, 3d position, and best picked entity.
      Ex: pos=getCursor(0)
      Also Read GoogleSketcup API to understand it's Functions and try examining sketchy Physics Tool File in SP Folder 😐
      Recommend to download notepad++ - It the best,
      go here: http://notepad-plus-plus.org/release/5.9.2

      posted in SketchyPhysics
      A
      Anton_S
    • 1
    • 2
    • 60
    • 61
    • 62
    • 63
    • 64
    • 63 / 64