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

    pdonner

    @pdonner

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

    pdonner Unfollow Follow
    registered-users

    Latest posts made by pdonner

    • RE: Add_3d_text height

      Thanks Dan for updating my pointers. I cannot find the corresponding Win32API and win32ole documentation among these neatly structured pages. Could you kindly supply the references so that our thread is completed.

      The Sketchucation thread is very useful indeed. Good work.

      posted in Developers' Forum
      P
      pdonner
    • RE: Add_3d_text height

      Just to clarify this (Ruby programming) topic a few steps further:

      The full documentation for the unpack formatting 'directives' of the referencing string can be found in the 'Programming Ruby' book at:

      301 Moved Permanently

      favicon

      (www.ruby-doc.org)

      Similarly, the documentation for the pack function - which transfers the contents of an array into a binary sequence - can be found at:

      301 Moved Permanently

      favicon

      (www.ruby-doc.org)

      posted in Developers' Forum
      P
      pdonner
    • RE: Add_3d_text height

      The declaration seems to be ok. And David Thomas' and Andrew Hunt's book 'Programming Ruby' seems to contain some helpful advice on how to pack and unpack binary data structures in Ruby. Cf. http://www.ruby-doc.org/docs/ProgrammingRuby/html/lib_windows.html, subtopic ClassWin32API (actually a quotation from the Ruby distribution, in ext/Win32API) - if someone is interested in how this is supposed to work.

      The space for the data structure is reserved by initializing a string, which can then be referenced after using the unpack function.

      lpTextMetrics = " " * 60 # TEXTMETRIC size
      
      GetTextMetrics.Call(hdc,lpTextMetrics)
      tmHeight, tmAscent, tmDescent  = lpTextMetrics.unpack("LLL")
      
      puts "tmHeight = #{tmHeight}"
      

      Thanks Dan and TIG for friendly help!

      posted in Developers' Forum
      P
      pdonner
    • RE: Add_3d_text height

      I got this far on my own:

      require 'sketchup' 
      require 'Win32API'
      
      GetDesktopWindow = Win32API.new("user32", "GetDesktopWindow", [], 'L')
      GetDC = Win32API.new("user32", "GetDC", ['L'], 'L')
      SetMapMode = Win32API.new("gdi32", "SetMapMode", ['L','N'], 'N')
      
      MM_HIENGLISH = 5
      
      hwnd = GetDesktopWindow.Call
      puts "hwnd = #{hwnd}"
      hdc = GetDC.Call(hwnd)
      puts "hdc = #{hdc}"
      
      mapmodeDefault = SetMapMode.Call(hdc, MM_HIENGLISH)
      puts "mapmodeDefault = #{mapmodeDefault}"
      

      Everything looks quite fine to this point. Now I would have to set up the TEXTMETRIC structure. I find the notations a bit difficult to grasp. So how should I declare TEXTMETRIC and pass it as a parameter in my GetTextMetrics call?

      And what about this Ruby declaration:

      GetTextMetrics = Win32API.new("gdi32", "GetTextMetrics", ['L','P'], 'V')

      posted in Developers' Forum
      P
      pdonner
    • RE: Add_3d_text height

      In a Windows program I would select the font and study text extents of a string like 'Åg' or then I could have a look at the textmetric structure of the font. In the TEXTMETRIC structure the measures are in logical units, i.e. they depend on the mapping mode. By selecting a HIMETRIC mapping mode the measure would be fine enough for our purpose.

      This can be achieved with the Win32API module that Dan was referring to, but this would lead to a Windows only solution (which in this particular case would be adequate). I would, however, like to know how the 3D Text height should be calculated regardless of the OS (or monitor brands for that matter).

      posted in Developers' Forum
      P
      pdonner
    • RE: Add_3d_text height

      Thanks Dan for feedback.

      @dan rathbun said:

      3D_text is not a screen font, it's a 3D entity that's why the height is specified in inches. The 3Dtext is actually drawn with Sketchup edges and faces (approximating the given fontface,) then grouped.

      Yes, I already understood all that and I also know how to hide the edges and how to move the group to the correct location etc. But I do fail to calculate the correct height (unless I would fall back on OS dependent Win32 textmetrics).

      @dan rathbun said:

      It gets smaller visually when you zoom out, and larger when you zoom in, so point size is really meaningless.

      In my scenario this wouldn't be the case. I'm writing a converter from PowerPoint to SketchUp. Therefore the dimensions of the 3D text geometry must match other aspects of the conversion which are based on cm (or inch) measures. The PowerPoint TextBox shape is based on a font, where size is indicated in points.

      Cf. the thread 'How to import a PowerPoint slide?'
      http://forums.sketchucation.com/viewtopic.php?f=79&t=37610

      posted in Developers' Forum
      P
      pdonner
    • Add_3d_text height

      In the add_3d_text api documentation there is a parameter specifying the height of the text, 'letter_height' which is defined as "Height of the text in inches."

      Assuming that we know the points of the font we would like to use, I would like to know the correct formula of calculating the letter_height parameter? A point is 1/72 of an inch and I would also be able to calcultate the height by using Win32 calls, but is there a more general way of handling this matter in SU?

      posted in Developers' Forum
      P
      pdonner
    • RE: Interprocess communication

      Thanks, Dan. Your advice was very useful. I could have lost a lot of time on the other schemes which I referred to. The 'Programming Ruby' book by David Thomas and Andrew Hunt looks interesting.

      Downloaded the .so extension modules, installed them and run a Ruby console session:

      >require 'win32ole'
       true
      
      >ppt = WIN32OLE.new("PowerPoint.Application")
      #<WIN32OLE;0x11396c58>
      
      >ppt.Activate
      nil
      

      That's it: PowerPoint was activated, so I'm ready to use PPT automation in a SU script as desired. Really elegant.

      This scheme depends on the WIN32OLE extension written by Masaki Suketa. Can anybody give me advice on standard procedures for installation of such extensions on the machines of SU users.

      My post had another aspect: We are now capable of using Ruby as a client for Windows Automation. What about the other direction. Can SU be extended to become an automation server?

      posted in Developers' Forum
      P
      pdonner
    • RE: How to import a PowerPoint slide?

      Gaius' #1-5 recipee brought the topic back to newbie level. Yes. Wireframe is the correct procedure to choose all edges and then hide them. Something that I didn't think of. Deselecting every face of the 3D letters manually can be tiresome. But I guess that TIG does this with one or two lines in his Ruby script.

      posted in Newbie Forum
      P
      pdonner
    • Interprocess communication

      So... made a jump from Newbies to the forum of the big boys: Developers' Forum. - I'm interested in ways of controlling SU externally and in ways of communicating with another app from SU.

      I would basically like to write a conversion between PPT diagrams and a simple top view of similar SU objects, which would enable me to make nice renderings of the diagrams by using SU styles and 3D rendering methods.

      This kind of interprocess communication can of course be handled by putting out a csv file, which would describe the diagram entities. This file could then be handled by a SU plugin. Someone seems to be writing ruby temp files which are activated as a SU command line argument or a ruby load. Then there is the possibility of embedding scripts in a WebDialog, and so forth.

      Basically I would like to study in what ways SU and Windows automation can work together in an intimate way; ideally in a way whereby changes in one app (now PPT) would be reflected in the other (SU).

      What are the best method of creating this kind of an interconnection?

      posted in Developers' Forum
      P
      pdonner