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

    Posts

    Recent Best Controversial
    • RE: Pass array to a c/c++ ruby extension

      Anton thank you very much, your code worked very well when I entered it in SUEX_HelloWorld.cpp from the HelloWorld example of the repository, I just changed some names in the project to match everything and it worked perfectly πŸ˜„ .

      Thanks a lot for the pdf Dan, it's very interesting.

      I still have one question, how could I do this in the example called SUEX_UsingSWIG ?, I observed the Swig documentation and the pdf that shows Dan, but I could not see how this is done. Any idea?

      posted in Developers' Forum
      D
      dacastror
    • Pass array to a c/c++ ruby extension

      Hi, I am creating my first c / c ++ ruby extension with the help of the examples found in: https://github.com/SketchUp/ruby-c-extension-examples
      I have been able to modify these examples successfully. But now I want to pass an array of ruby to C ++ like the following:

      [ [1, 2, 3], [2 ,3, 4], [4, 5, 6], ... ]

      That correspond to the 3d coordinates of some points, and I want to bring back to ruby another similar array. For the moment I have only been successful with strings and with floats using the example of the repository called SUEX_UsingSWIG, but I do not know how it is done for arrays. Thank you in advance for your help.
      (I use google translator, sorry for the mistakes in the translation)

      posted in Developers' Forum
      D
      dacastror
    • Send mail from Sketchup

      Hello everyone

      In time being I am doing some processing in batch in SU, what I want to know is if you can send an email from SU when the process is complete, you can do this? Thanks in advance for your comments

      posted in Developers' Forum
      D
      dacastror
    • RE: [Plugin] SketchUV - now free

      mistakes like this are appearing on the console

      Error: #<NameError: uninitialized constant DM_SketchUV::DM_UVTool::Set>

      I'm using Sketchup 2015. When you use version 1.0 works fine, but there are flaws in version 1.0.1

      posted in Plugins
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      where you learn to do these wonderful things?

      posted in Developers' Forum
      D
      dacastror
    • HoloLens and SketchUp

      (google translator)
      plans between Micrisoft and Trimble look really cool, I publish here because some developer interesting ideas can happen when he sees the plans that they exist for Sketchup.

      http://www.engineering.com/DesignerEdge ... tchUp.aspx

      http://www.trimble.com/news/release.aspx?id=042915a

      posted in Developers' Forum
      D
      dacastror
    • HoloLens and SketchUp

      (google translator)
      Micrisoft plans between Trimble and look really cool, do not know if someone already publish the same in this forum

      Link Preview Image
      Page not found - Engineering.com

      favicon

      Engineering.com (www.engineering.com)

      http://www.trimble.com/news/release.aspx?id=042915a

      posted in SketchUp Discussions sketchup
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      I just installed extesion and open sketchup, works great !!
      these observers are perfectly suited to my need πŸ˜„

      posted in Developers' Forum
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      β˜€ 😍 Anton thank you very much, this is great, Christmas had never come so early for me, I am very happy. I am examining every part of this and I'm downloading "visual studio 2010," I'm trying to absorb all this.

      posted in Developers' Forum
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      Anton you're great, I will be attentive to what you show me to make a extension.

      posted in Developers' Forum
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      Anton thank you very much, I'll get to study this πŸ€“

      posted in Developers' Forum
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      I want to keep as a surprise, When I finish you will understand why I needed this, however I will seriously Consider Your points.

      it seems that is no longer available the info in this link

      @unknownuser said:

      We're sorry, the page you requested cannot be found.

      you could give me another clue to study this?

      posted in Developers' Forum
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      Anton thank you very much for your explanation and links.

      you have many observers available it is awesome, I have two versions of your library,1.0.9 and 2.2.0, I'm trying to understand how you manage to observe changes in the windows but I can not understand how you do, What is the basis of your observers? Is it a timer that question every so often? or does it work differently? Anton sorry for asking so much, It is that I am interested in the mechanisms behind the clock.

      I want to keep as a surprise, when I finish you will understand why I needed this, however I will seriously consider your points.

      posted in Developers' Forum
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      I'm realizing I have to create a kind of observer of the size and position of the viewport, so that my webdialog is maintained in the corner when the user changes the size or position of the window Sketchup, for now the only option I see is do something with UI.start_timer and UI.stop_timer

      posted in Developers' Forum
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      β˜€ 😍 🀒 It works perfectly, Anton am very grateful that you've taken the time to write this, it's very good.
      I'm studying your code to see how does its magic, I have a question about owner = GetWindow.call (active, 4) I do not quite know who does this
      Other than that, I only see a bug in the code, you wrote D ecastror instead of Dacastror
      πŸ˜† I'm kidding of course.

      @unknownuser said:

      meanwhile I will provide a Win32API reliant version, and then a C extension if decastror wishes

      Build my first extension in C would be wonderful, it would be a good opportunity to dust off my little knowledge of C and most interestingly, could look to the development of faster plugins,
      once, I tried perform the "hello world" with a guide published on GitHub, but I got lost on the way, I do not remember why, I would very much accomplish, Anton that would be awesome.

      thank you very much for the advice Dan. I'll read about that library.

      (translated with google translator)

      posted in Developers' Forum
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      wow! thank you very much Anton, get this Handle seems more sophisticated than I expected

      I'm anxious to see how to do πŸ˜„

      posted in Developers' Forum
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      Driven thanks, I'll look it looks interesting, I wonder if there will be a gem that allows some things like making Win32API so that they can perform on Mac

      Anton would perform similar to yours definitions, but using Win32API
      this is your original definition

      
          def client_rect(hwnd, mode = 1)
            return nil unless valid?(hwnd)
            mode = mode.to_i
            mode = 1 unless mode.between?(1,3)
            lpRect = 0.chr*16
            wins;;GetClientRect.call(hwnd, lpRect)
            crect = lpRect.unpack('l*')
            return crect if mode == 3
            style = wins;;GetWindowLong.call(hwnd, -16)
            exstyle = wins;;GetWindowLong.call(hwnd, -20)
            wins;;AdjustWindowRectEx.call(lpRect, style, false, exstyle)
            arect = lpRect.unpack('l*')
            r = []
            if mode == 1
              wins;;GetWindowRect.call(hwnd, lpRect)
              rect = lpRect.unpack('l*')
              r[0] = rect[0] - arect[0]
              r[1] = rect[1] - arect[1]
              r[2] = r[0] + crect[2]
              r[3] = r[1] + crect[3]
            else
              r[0] = -arect[0]
              r[1] = -arect[1]
              r[2] = r[0] + crect[2]
              r[3] = r[1] + crect[3]
            end
            r
          end
      
      

      and this is what I try to do, I do not know if it is correct

      require "Win32API"
      
      GetClientRect = Win32API.new( 'user32.dll','GetClientRect', 'LP', 'B')
      GetWindowLong = Win32API.new("user32.dll" , "GetWindowLong", "LI" , "L")
      AdjustWindowRectEx = Win32API.new('user32.dll','AdjustWindowRectEx', 'PLBL', 'B')
      GetWindowRect = Win32API.new('user32.dll','GetWindowRect', 'LP', 'B')
      
      def client_rect(hwnd, mode = 1)
        mode = mode.to_i
        mode = 1 unless mode.between?(1,3)
        lpRect = 0.chr*16
        GetClientRect.call(hwnd, lpRect)
        crect = lpRect.unpack('l*')
        return crect if mode == 3
        style = GetWindowLong.call(hwnd, -16)
        exstyle = GetWindowLong.call(hwnd, -20)
        AdjustWindowRectEx.call(lpRect, style, exstyle)
        arect = lpRect.unpack('l*')
        r = []
        if mode == 1
          GetWindowRect.call(hwnd, lpRect)
          rect = lpRect.unpack('l*')
          r[0] = rect[0] - arect[0]
          r[1] = rect[1] - arect[1]
          r[2] = r[0] + crect[2]
          r[3] = r[1] + crect[3]
        else
          r[0] = -arect[0]
          r[1] = -arect[1]
          r[2] = r[0] + crect[2]
          r[3] = r[1] + crect[3]
        end
         r
      end
      

      at this time I do not know how to get "hwnd" for sketchup window

      (google translator)

      posted in Developers' Forum
      D
      dacastror
    • RE: Get the coordinates of the corners of the viewport

      thank you very much for your answers, I really want to do this, Driven interesting that behavior in Mac, I try to do something with it.
      Anton thank you very much, I was just beginning to explore your code is really awesome πŸ˜›, I can see that the coordinates of the viewport are obtained with this AMS::Sketchup::Viewport.rect returns an array like this [74, 120, 1678, 991] that corresponds to what I need πŸ˜›. Although I feel like killing a fly using an atomic bomb, it would be excessive to require the complete library, I'm trying to study their code to accomplish what I need through Win32API, but it is proving difficult. Nevertheless, I can contemplate the beauty and power of your code

      (google translator)

      posted in Developers' Forum
      D
      dacastror
    • Get the coordinates of the corners of the viewport

      Hello everyone, I have a question related to the coordinates of the corners of the viewport relative to the screen, my goal is to create a webdialog and place it in one of these corners. I'm not sure how to get these coordinates, in advance thank you very much for your attention.
      This picture illustrates what I want to get

      coords corner.png

      (I used google translator, sorry for errors)

      posted in Developers' Forum
      D
      dacastror
    • RE: Question about edit_transform

      tip: never use global variables ($)

      I think something like this is what you want

      
      def overall_transformation(instance)
        model = Sketchup.active_model
        path = model.active_path ? model.active_path ; []
        indi = path.index(instance)
        if indi
          return model.edit_transform if indi == path.size-1
          tr = path[0].local_transformation
          for i in 1..indi
            tr = path[i].local_transformation * tr
          end
        else
          tr = instance.transformation
          while (instance.parent.class != Sketchup;;Model)
            instance = instance.parent.instances[0]
            tr = instance.transformation * tr
          end
        end
        return tr 
      end
      
      def find_instances
        instancias = []; instancias.clear
        mod = Sketchup.active_model
        definitions = mod.definitions
        for definition in definitions
          instances = definition.instances
          if instances.length > 0
            entity = instances[0]
            attr = entity.get_attribute "dic", "key"
            instancias << entity if attr
          end
        end
        return instancias
      end
        
      def make_instance(entities,transformation)
        p1 = [0,0,0]; p2 = [50,50,50]
        group = entities.add_group
        group.entities.add_line p1, p2
        group.transform! transformation
        return group
      end
      
      
      def make_2_instances_nested_transformed
        model  = Sketchup.active_model
        return "had been previously created" if find_instances.size>0
        tr1    = Geom;;Transformation.translation [100,0,0]
        tr2    = Geom;;Transformation.translation [0,100,0]
        ents1  = model.entities
        group1 = make_instance(ents1,tr1)
        ents2  = group1.entities
        group2 = make_instance(ents2,tr2)
        group1.set_attribute "dic", "key", "info"
        group2.set_attribute "dic", "key", "info"
        "ok"
      end
      
      def find_instances_and_print_global_positions
        instances = find_instances
        group1 = instances[0]; group2 = instances[1]
        origin1 = overall_transformation(group1).origin
        origin2 = overall_transformation(group2).origin
        puts "Group 1 global origin -> " + origin1.to_a.inspect
        puts "Group 2 global origin -> " + origin2.to_a.inspect
        "ok"
      end
        
      #make_2_instances_nested_transformed
      #find_instances_and_print_global_positions
      
      

      first run make_2_instances_nested_transformed
      and then find_instances_and_print_global_positions on any active context

      this only works if instances are unique, this is just an idea
      for depth greater than 2 I do not think it works, local_transformation seems uncertain when this within instances of interest ...
      (google translator)

      posted in Developers' Forum
      D
      dacastror
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 1 / 7