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

    Posts

    Recent Best Controversial
    • 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
    • DHTML dialog boxes

      Where can I find some documentation on getting started creating DHTML dialog boxes?

      What compiler will I need?

      Looking for the easy answer. πŸ˜„

      posted in Developers' Forum
      G
      Gruff
    • RE: Mathematics related problem

      Perhaps I am just a raw beginner myself but it appears that in his original snippet meeta is setting @M = bending.

      Shouldn't that be @M = result?

      Inputbox does not alter the input default value that I can see.
      therefore bending will still be 0.0 after the input.

      posted in Developers' Forum
      G
      Gruff
    • RE: Double Offset tool?

      @unknownuser said:

      if it could go onto different planes, i have a use for it..

      i usually do this with offset for one direction and copy/move the other but a one-shot deal would be nice.. might get weird once more complex shapes are introduced (like a cylinder for instance)

      Jeff,
      I do not know how you are producing this but I would think that push/pull tool with a tap to the control key, value enter. Would create the side band. Then Offset tool, value to create the top. All in all a couple of clicks. Do you really need to automate more than that?

      If you still think so or need to handle tapered sides then I'd contact Fredo6 and ask him to add it to his RoundCorner product as he is already doing what you want in his selection preview. I would think it would be a snap for him.

      posted in Developers' Forum
      G
      Gruff
    • RE: The "Duh!" thread (aka the Doh! thread)

      New Duh. (Sort of)

      Select a face then right mouse and select Align Axis. (Let's call it AA2F) We've all seen it but did you know that what it creates depends on how your face happens to be oriented to the screen?

      In a nut shell AA2F aligns the Axis to the lower left most edge.

      Draw a hexagonal face. Choose the top view and use AA2F. Rotate the view of the hexagon
      reselect AA2F. Your Axis will shift position around the hexagon vertices.

      This can actually be used to your advantage when dealing with a face that has different features dependent on different edges. As a case in point see the attached Guitar head where I needed to align and create features parallel to either outside edge as well as the center line of the whole thing.


      Guitar Neck Test

      posted in SketchUp Discussions
      G
      Gruff
    • RE: Double Offset tool?

      @click draw said:

      Thanks TIG,

      I downloaded that recently but not quite what I want. Thanks though.
      Jeff

      How about describing what you want in more detail?

      I know that like some of the other sketchup tools the offset tool will repeat the last operation with the last input value on a double click. You can happily duplicate as many offsets as you like. Is this what you mean?

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

      Tell you what xrok1,

      Here is a small Ruby script Calculator that binds to the Tools menu.
      Bind it to a shortcut key and your in business.

      [Edit]
      See the attached zip file two posts down...
      [/Edit]

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

      Ah! that would be the problem then. Definite version issue.
      Since I do not have Windows7 I cannot say that it will ever work for you.

      Are there modifications you can do to get it to run as though it were launched from WinXP? XP has tools to run older OS products through it's shortcut options.

      Looks nice though. πŸ˜„

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

      A4chitect:
      Thanks! It works on my PC now as well.

      Chris:
      There you go. You can write a calculator with a Web page front end that uses code like that in 'test_me.rb' to drive the VCB. That would be a better solution as it would be native to SketchUp for Windows. Much much better than my Compiled app.

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

      Hmmm there is a User32.dll sendkeys function but why not use ruby entirely.

      I tried this code but it fails on the: require 'win32ole'
      I downloaded and installed full ruby but it doesn't seem to make a difference.

      Perhaps you can get this to work?

      
      require 'Sketchup'
      require 'win32ole'
      #---
      
      def drive_vcb  
        wsh = WIN32OLE.new('Wscript.Shell')
      
        # Do not know if we need to put the focus on SU since we are in SU.
        if wsh.AppActivate('- SketchUp')
          sleep(1)
      
          # Push Test keystrokes into SU
          wsh.SendKeys('100.00{ENTER}')
      
        end
      end
      if( not file_loaded?("test_me.rb") )
          add_separator_to_menu("Draw")    
          UI.menu("Draw").add_item($exStrings.GetString("test_me")) { drive_vcb }
      end
      #---
      
      file_loaded("test_me.rb")
      
      
      posted in Developers' Forum
      G
      Gruff
    • RE: ? [Question] - A Ruby Calculator ?

      Chris:
      This one was coded in VB6. I find it best for quick development.
      If you want to look at the Source code I could post it for you.

      Rather than write my own equation parser I made use of the MS Scripting Control to evaluate text expressions. While this supports a wide range of functionality it also opens the door to user input errors. It is extensible. In fact for this implementation I swapped out the Trig functions so that they work with Decimal Degrees instead of Radians. i.e. SIN(30) = 0.50

      This means conversion functions as the original poster asked about could be added fairly easily.
      I suppose I could write it such that it imports a text file that contains user defined conversion procedures. (Of course they would have to be written in VBScript.)

      This brings up a possiblity that this might be written as a Web form.
      As I see it the only missing elements for you would be the VB Sendkeys() command and some way of setting the focus to SU while Sendkeys does the job. Hey! I believe there is a Win32API equivalent.
      I'll root around for it.

      xrok1:
      The App was compiled under WinXP. I suspect you are using some other OS.
      This might also account for how it looks on your system.

      Run-Time Error 5 (Invalid Procedure Call or Argument) can be attributed to an out of range floating point error or more likely an incompatible OS.

      Just downloaded the zip from the forum and installed it on my other WinXP box.
      Runs fine here.

      As far as how it looks. Could you post a screen shot? I was concerned about size so I made it as compact as possible.

      posted in Developers' Forum
      G
      Gruff
    • 1
    • 2
    • 3
    • 4
    • 1 / 4