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

    Posts

    Recent Best Controversial
    • Get Current Units

      I was wondering if there was a way to get (in a ruby script) the current units that are being used in the model. The reason is that I want to make a dialog box that asks for dimensions from the user and it would be nice if the user could simply enter a numerical value corresponding to the length in the model's current units set in Model Info>Units.

      Someone please let me know if it is possible to do this or if it is somehow unnecessary.

      posted in Developers' Forum
      T
      TheDro
    • RE: Virtual entities or model

      Sweet. Thanks a lot TIG, that should work.

      posted in Developers' Forum
      T
      TheDro
    • RE: Face.classify_point - compare results?

      I'm running into some pretty weird problems with the classify_point method. Here's the code I'm running:

      puts ii.classify_point(curPoint).to_s
      if ii.classify_point(curPoint)&8
      ...
      

      The value 32 is always sent to the console, yet the if statement executes, even though 32&8 = 0. Can someone help me out with this?

      posted in Developers' Forum
      T
      TheDro
    • Virtual entities or model

      I was wondering if it was possible to create a "virtual" entities or model variable where I can make lines and faces without affecting the model I'm working on. The reason for this is that I want to create a cube like this:

      	def cubecomp(x,y,z)
      		
      		orig = Geom;;Point3d.new 0,0,0
      		pts = []
      		pts[0] = orig
      		pts[1] = orig + x
      		pts[3] = orig + y
      		pts[2] = pts[1] + x + y
      		
      		cubeface = entities.add_face pts
      		cubeface.pushpull - z.length, true
      		cube = cubeface.all_connected
      

      The potential problem I'm afraid of is that if one of the vertices of the cube is on an edge that is already in the model, I will select it with the all_connected method. What I would like to do is something like virtualEntities = Entities.new and use this to build the cube. Later, I want to copy this cube to several different locations.

      Does anyone know if something like this is possible or if there is a safe work around?

      posted in Developers' Forum
      T
      TheDro
    • RE: Call Ruby Script from File

      Thanks a lot guys. The load method is just what I was looking for. Here's what I've written in the first file and it works:

      require 'sketchup.rb'
      
      def drawc
      	load 'cubegrid2.rb'
      	include Cubegrid
      	drawgrid
      end
      
      UI.menu("Plugins").add_item("cubegrid") { drawc }
      
      
      

      Every time I call cubegrid from the Plugins menu, it reloads the cubegrid2.rb file and executes its main method, drawgrid, from the module Cubegrid. I realize that the function names aren't very descriptive and quite uninspired, but that's not important and the moment 😄.

      Again, thanks for the help.

      posted in Newbie Forum
      T
      TheDro
    • Call Ruby Script from File

      Hey everyone! I'm new here on the forums but I've been playing around with sketchup for a solid month now. I'm just starting to look at writing ruby scripts to automate some processes and I've got a couple questions. I've been looking around the web for some information and I've just read through the book of ruby (quickly) and I still can't find a way to call a ruby script from a ruby script. What I mean is call a function (method) called drawcubes in drawcubes.rb from another script, let's say called cubes in the cubes.rb file which contains some header stuff such as adding "drawcubes" to the plugin menu. The reason I want to do this is probably more important and I might not be approaching the problem the right way.

      I'm basically just looking for a way of having the "drawcubes" option in the plugin menu and have it call the function which I'm working on, without having to restart Sketchup every time I make a change. I could just write the function in the webconsole (plugin) without adding the option to the plugin menu but the webconsole doesn't have the syntax highlighting and proper tabbing that my external editor has.

      Hope that's clear enough.

      posted in Newbie Forum sketchup
      T
      TheDro
    • 1
    • 2
    • 2 / 2