sketchucation logo sketchucation
    • Login
    1. Home
    2. Gruff
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now
    G
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 11
    • Posts 70
    • Groups 1

    Gruff

    @Gruff

    10
    Reputation
    1
    Profile views
    70
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online
    Age 74

    Gruff Unfollow Follow
    registered-users

    Latest posts made by Gruff

    • RE: Double Offset tool?

      Perhaps this is gravedigging but I hae an AHA moment the other day. The reason the offset tool does not work with a single line is that it does not know what 3D plane you want the offset to be on.

      Two or more non co-linear lines and presto. SU can calculate the plane from any three points. Then determine the side you wish to place the offset on by tranforming the mouse cursor position to the plane.

      Double sided offset would have the same problem.

      posted in Developers' Forum
      G
      Gruff
    • RE: PushPul not removing faces.

      Actually I found I could duplicate the problem manually.

      Create a cube.

      The push manually entered the right distance does not go through the wall.


      Sample

      posted in Developers' Forum
      G
      Gruff
    • PushPul not removing faces.

      I was trying to make the simple chair model shown in one of the tutorials run from a program and ran into a problem with PushPull.

      I started with a rectangular cube based on the overall dimensions.

      1. Pushed the seat down from the cube top. Okay.
      2. Pushed the space between the legs side view through the cube. Okay.
      3. Pushed the space between the legs front view to the intersecting space from step 2. Fail.

      It creates the projected rectangle but does not remove it.
      My numbers look correct. I am creating faces for the PushPull.

      How do I do this?

      #pseudo code

      wt = width
      dp = depth
      ht = height
      stht = seat height
      ss = stock material size (Leg side)

      cube = wt x dp x ht

      Top cube face

      face_1 = [0,0,ht], [0,dp-ss,ht], [wt,dp-ss,ht], [wt,0,ht]
      push face1 -(ht-stht)

      Right side cube face

      face_2 = [wt,ss,0], [wt,ss,stht-ss], [wt,dp-ss,stht-ss], [wt,dp-ss,0]
      push face_2 -(wt)

      Front side cube face

      face_3 = [ss,0,0], [ss,0,stht-ss], [wt-ss,0,stht-ss], [wt-ss,0,0]
      push face_3 -(ss)

      #Fails to remove space at this point.

      posted in Developers' Forum
      G
      Gruff
    • RE: SU to VB6.0 (Or there and back again.) :)

      Update:

      Found we can pass the main Sketchup object to the VB dll.
      (Had to create a variable to contain the Sketchup object first. Duh.)

      This opened up more possibilities. For instance you can load a Ruby script file from your VB program that does not existing in your plugin folder.

      
        Private Sub cmdRunRuby_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRunRuby.Click
          Dim status As Object
      
          With OpenFileDialog1
            .InitialDirectory = "c;\"
            .AddExtension = True
            .DefaultExt = "rb"
            .Filter = "Text files (*.rb)|*.rb"
            .FileName = ""
            .ShowDialog()
            If .ShowDialog() = Windows.Forms.DialogResult.OK Then
              status = g_oApp.load(.FileName.Replace("\", "\\"))
              status = Nothing
            End If
          End With
        End Sub
      
      

      Attached is a flow chart (Poorly made) that attempts to show the process used to drive SU from VB. Also attached is a snapshot of the vb.net testbed from the previous post running.

      Determined that the SketchUp API exposed to Windows is not the SketchUp API that is used internally by Ruby. This is somewhat disappointing as it means we cannot do SU API debugging nor do we have Intellisense for the SU objects.

      On the up side we have both of those features for data typed variable written in VB.


      Snapshot of the testbed app in the previous post


      Flow Chart

      posted in Developers' Forum
      G
      Gruff
    • RE: SU to VB6.0 (Or there and back again.) :)

      Proved out that VB.NET can talk to SU in the same manner provided you start with a (backwards compatible) COM Project.

      As I thought the generic object type may be substituted for the vb6 variant type.

      SU does not complain. πŸ˜„

      Attached is a simple VB.NET dll with a child form that builds a box through the SU API then returns a message to the SU script.

      Have fun!


      Zip containing testbed.rb and a VB.NET 2008 project

      posted in Developers' Forum
      G
      Gruff
    • RE: SU to VB6.0 (Or there and back again.) :)

      SU to VB and Back. Part II

      a) Added a windows form to the dll. Not a big deal.
      b) Made the window a modal dialog. This is to stop the ruby code from falling through to the end of the script.
      c) Added a global module to pass the SU API objects and the dll host object into the form. The form may now process SU API objects directly and/or pass properties back to the host. (Where the ruby script can read them.)

      UI.messagebox( vbdll["propertyname"] )

      Utilizing this method we can have a VB form pop up on top of SU and disallow interaction with the SU environment while still driving the SU API from the form real time.

      No splats, crashes, or blue screens.

      Full power of Visual Basic 6.0 available to SU now.

      posted in Developers' Forum
      G
      Gruff
    • RE: ? [Question] - A Ruby Calculator ?

      Thanks for the advice Jim.

      I updated the Ruby_Calc Zip attachment with your change. For any who get this far there are two calculators in this thread.

      1. TG_Calc.exe which is a Compiled Windows program. It has a number of features.
      2. Ruby_Calc.rb which is just a simple calc with no features.

      Both only work with Windows and require the win32ole.so file.
      both work by pumping keystrokes into the SU environment.

      posted in Developers' Forum
      G
      Gruff
    • RE: ? [Question] - A Ruby Calculator ?

      You are really having a bad day, Huh. Sorry for any confusion.

      Attached is a zip file that contains both ruby_calc.rb and win32old.so.

      Unzip and place them both in your plugins folder under sketchup.

      I found it handy to bind the menu 'Tool/Ruby Calc' to a shortcut key. (I use Alt+Q)

      This calculator doesn't have a history, but it will take any Ruby formatted Math equation and use it to drive the VCB.


      Latest Ruby_Calc. (This is not TG_Calc)

      posted in Developers' Forum
      G
      Gruff
    • SU to VB6.0 (Or there and back again.) :)

      Figured out how to build a bridge finally.

      The answer I came up may not be the only way to go but it is the only one I've found to date.

      In this solution I wrote the VB6 application as an ActiveX dll.
      I use a stub ruby program with win32ole to instantiate the dll.
      I pass whatever instantiated SU object I wish to the dll as a reference through a public sub routine in the dll.

      From the dll I manipulate SU API object.
      A couple of things to note.

      1. Any objects passed back to SU must be passed as variant data types.
        If datatypes cannot be converted implicitly you will have to do it manually.
      2. All objects passed must be destroyed in the dll before the sub routine exits. (Set them to nothing)
      3. if the SU API defines a method as returning a value the VB implementation must do so also.
      4. Variants and UDT's are mutually exclusive so work arounds will have to be used.
      5. I only have the VB.NET 2008 Express version at home so I will not be able to test with VB.NET for now. (I assume that the generic 'Object' datatype will stand in for the Variant data type.

      Listing 1: SU stub code

      
      require 'sketchup'
      require 'win32ole'
      #---
      
      def testbed
        model = Sketchup.active_model
        entities = model.entities  
        tb = WIN32OLE.new('TestSUApp.clsTestSUApp') 
        # Pass the entities object to the DLL   
        tb.createblock(entities)     
      end
      
      #---
      if( not file_loaded?("testbed.rb") )
          add_separator_to_menu("Tools")    
          UI.menu("Tools").add_item($exStrings.GetString("Test Bed")) { testbed }
      end
      
      file_loaded("testbed.rb")
      
      

      Listing 2: VB Dll code (Compile with instancing = multiuse)

      
      Option Explicit
      
      Public Sub createblock(ents As Variant)
        Dim wt As Single
        Dim dp As Single
        Dim ht As Single
        
        Dim sVals As String
        Dim s() As String
       
        Dim rect As Variant
        Dim face As Variant
        Dim vstatus As Variant
        
        
        ' The following dippy dimension entry technique is just for the test.
        ' No error checking is supplied
        
        sVals = InputBox("Enter Width, Depth, Height", "Create Box", "")
        If sVals = "" Then GoTo CleanUp
        s = Split(sVals, ",")
        wt = CSng(Trim(s(0)))
        dp = CSng(Trim(s(1)))
        ht = -CSng(Trim(s(2)))
        
        rect = To_Rect(To_Pt(0, 0, 0), To_Pt(wt, 0, 0), To_Pt(wt, dp, 0), To_Pt(0, dp, 0))
        
        Set face = ents.add_face(rect)
        
        vstatus = face.pushpull(ht, False)
      
      CleanUp;
        Set vstatus = Nothing
        Set face = Nothing
        Set ents = Nothing
      End Sub
      
      Private Function To_Rect(ByVal pt1 As Variant, ByVal pt2 As Variant, ByVal pt3 As Variant, ByVal pt4) As Variant
        Dim v As Variant
        v = Array(pt1, pt2, pt3, pt4)
        To_Rect = v
      End Function
      
      Private Function To_Pt(ByVal x As Single, ByVal y As Single, ByVal z As Single) As Variant
        Dim v As Variant
        v = Array(x, y, z)
        To_Pt = v
      End Function
      
      
      posted in Developers' Forum
      G
      Gruff
    • RE: DHTML dialog boxes

      @thomthom said:

      No compiler is needed.

      Really I thought that was what DHTML was. HTML compiled to a DLL.

      I was just quoting the Web Dialogs Introduction on the SketchUp Ruby API web page.

      http://code.google.com/apis/sketchup/docs/ourdoc/webdialog.html

      Okay... So are there any books that can walk me through creating a simple hello world web dialog for SketchUp ruby.

      I know exactly Zero about web based programming.

      posted in Developers' Forum
      G
      Gruff