sketchucation logo sketchucation
    • Login
    1. Home
    2. RunnerPack
    3. Posts
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 32
    • Groups 1

    Posts

    Recent Best Controversial
    • RE: "AAHHH!! my brother is an evil genius!"

      Great idea and superb execution! ๐Ÿ‘ I agree wholeheartedly with every positive comment posted above (to save me some time repeating them ๐Ÿ’š).

      There's only one thing that I would add: the hydraulic cylinders need hoses! I forgive you for not adding them, since I know how hard it is to model nice hoses/wires/etc., but if you want to take the realism ("epicness"? ๐Ÿ˜†) to the next level, that's my suggestion.

      Thanks for sharing!

      posted in Gallery
      RunnerPackR
      RunnerPack
    • RE: UI.messagebox "beep"

      @thomthom said:

      Use the bitwise And operator to combine flags:
      Messagebox with Yes/No button and question mark icon:
      UI.messagebox('Hello World', MB_YESNO | 32)

      That's actually the Or operator... but you knew that ๐Ÿ˜‰

      Sorry... pedantic mode, off! ๐Ÿ˜„

      @Dan: I've also always wondered what all the obviously-Win32-API-based things did on the Mac version... I always assumed they just translated stuff to the appropriate Mac system-calls/constants, but it would be nice to know for sure.

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: [Plugin] Camera Stats

      Thanks, Martin. Another in a long line of very handy plugins! ๐Ÿ˜„

      Just a couple of bugs to report, and one feature request:

      First, I'm running XP SP3, SU 7.1.6860 (free version), and my IE is version 8.0.6001.18702. It seems to have problems when I use it, (which is rarely ๐Ÿ˜› ) so it could be IE's fault, not yours... Anyway, I get the JavaScript error dialog shown in the attached image when I start the plugin (that is, when I open the window, not when SU starts).

      Also, the "close" button on the Camera Stats window doesn't do anything (possibly related to the JavaScript error?).

      Finally, the feature request:

      It would be very handy if I could "pan" the camera left and right, relative to the viewport, by a specified value. For example, if I panned it right by about 2.5", it would be like I closed my left eye and opened my right (do you see where I'm going with this? ๐Ÿ˜‰ ). I know (for me, anyway) the math would be pretty rough, but if you have the time, (you obviously have the grey-matter ๐Ÿ˜‰ ) I would use this feature ALL OF THE TIME! ๐Ÿ˜„

      Anyway, thanks again for the cool plugin!

      EDIT: I just had another look at the Camera object API, and I think I know how to do this... Take the cross product of Camera#up and Camera#direction, use the resulting vector (or its negative) to transform Camera#target and Camera#eye, and use Camera#set to put it all back together. Am I close?

      EDIT 2: โ˜€ Success! After just a bit of tinkering, I got it working! ๐Ÿ˜ฎ ๐Ÿ˜ฒ ๐Ÿ˜„

      It's pretty much as I said above, but I had to experiment to find out how the API wants things done (plus I was a bit rusty at Ruby ๐Ÿ˜ณ)

      I'm going to clean this up and make a new thread for it, just in case someone can use it, but here it is if you, Martin, want to incorporate it (not that you need my amateurish code ๐Ÿ˜‰ ) or if someone wants to see what I'm blathering about ๐Ÿ˜‰.


      IE JavaScript error dialog


      Stereo Panning Plugin (WIP)

      posted in Plugins
      RunnerPackR
      RunnerPack
    • RE: Removing 2D entities from skp using script

      I think the defacto standard in this forum is that the original poster (e.g. you) edits his/her first post and adds [Solved] to the beginning of the title, to let people know there is a solution in the thread.

      I could be wrong, though, since I'm also quite new here...

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: Removing 2D entities from skp using script

      @venommax said:

      [...] I need this to do a batch update on a set of sketchup images. [...]

      @tig said:

      [...]
      Tip: please stop referring to them as "SketchUp Images" as that would be something quite different, and NOT we are dealing with here !
      โ˜€

      I think he meant "SketchUp Documents" meaning multiple model files. โ˜€ ๐Ÿ‘Š

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: Removing 2D entities from skp using script

      A two step method would catch 99% of cases:

      Step one: just check the bounding box. If it's 2-D, so is its contents. If not, it could still be a flat object rotated relative to the container's axes. So...

      Step two: Loop through the faces in a group/definition and check their normals. If they're all parallel, it's "flat".

      What these wouldn't catch would be something like a deck of 2-D cards, with individual faces - all parallel - on different planes. You could add a third step to check for non-coplanar faces, but the first two would probably be sufficient for what I think venommax's needs are.

      If nobody codes it in a week, I can do it (deadline...).

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: In over my head?

      It looks pretty good, Mike. I do see a couple of problems, though (most of which are quickly found by having the Ruby console open when you try to run it ๐Ÿ˜‰ it's really easy to use with Jim's Ruby Toolbar: http://forums.sketchucation.com/viewtopic.php?f=180&t=1542 ๐Ÿ˜ž

      1. A typo: "rasie" instead of raise.

      2. In that same if block, you should probably abort the rest of the script if there are no point sets... Just put in a "return" with an optional value.

      3. On the same topic, you may want to replace all the message boxes with "puts" statements and use the console. I find it much less annoying than all the clicking ๐Ÿ˜‰

      4. In both "each_with_index" statements, you reuse the name of a local variable for an iterator. This is probably okay, I just like to nit-pick ๐Ÿ˜‰.

      5. Finally, if you ever want to debug by reloading just the script (rather than SU itself), you'll start filling up your "Plugins" menu with "Plot Data File" items. Better to define this in its own method (preferably in its own Module) and point to it with a menu inside a block, like so:

      
      require 'sketchup'
      
      module YourModule
      	def self.plot_points
      	.
      	.
      	.
      	end
      end # Module
      
      unless file_loaded? ( File;;basename( __FILE__ ) )
      	UI.menu('Plugins').add_item('Plot Data File') { YourModule.plot_points }
      	file_loaded File;;basename( __FILE__ )
      end
      
      

      One last thing: Can I have a ride in your plane when you get the wings sorted out? ๐Ÿ˜‰

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: How to read the windows registry?

      Why not just use a plain-text configuration file located in your plug-in's ".../Plugins/pluginname" folder. You could use INI, XML, JSON, RON, etc.

      This would have the advantages of working on both Vista and OSX transparently, and it would probably be more powerful and easier to implement, to boot.

      As a long-time Windows user, I think the registry was a terrible idea that was also quite poorly implemented. I understand that it was designed to make the job of administrators of large corporate networks easier, but as an individual computer user, I tend to prefer programs (and plug-ins ๐Ÿ˜‰ ) that use a human-readable ini file of some kind.

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: Similar Group Finder - Script beginning needs testing

      This is a very cool idea for a plug-in! I've thought of it myself, of course (most people who've worked with SU for very long probably have) but then thought of how hard it would be to write (and how slow it would probably run on my ancient PC ๐Ÿ˜‰ ).

      But, I'm very glad to see the gauntlet has been taken up - especially by someone as talented at plug-in writing as Chris F. ๐Ÿ˜„

      I have been studying the transformations of Groups and the geometry inside for a plug-in I'm making, so I may have something to add to this in later stages (though I'm terrible at math).

      Thom:

      Not to criticize your coding style or Ruby skills (or those of "jeff99"), but I thought I'd point out that, in Ruby, both the "return" statement and the trinary conditional are technically superfluous, in this case.

      Since the condition itself evaluates to either 'true' or 'false', and since Ruby returns the value of the last statement as the method's value, the entire contents of the method could be simply:

      # Compare two floats with some tolerance. (Thanks jeff99 and thomthom)
      def self.floats_equal?(float1, float2, epsilon = 0.00000001)
        ((float1 - float2).abs < epsilon)
      end
      

      (One could also make it easier to use by overriding the === [triple equals] method for floats, but I don't know what the consequences of this would be. Maybe a '====' method, instead?)

      I don't know what impact, if any, this would have on the speed of a plug-in, but one like Chris' would be doing a lot of these...

      Also, is that a loose enough tolerance for this usage? I suppose it would depend on the scale and level-of-detail of each model.

      Well, I'll stop wasting everyone's time now ๐Ÿ˜†

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: How do we view methods, (And their Arguments) of a Class

      You can't show the arguments, but calling the '.methods' method on a class will list its methods and '.instance_methods' will give the same for an instance of it (i.e. an object); or you can just call ".methods" on an actual instance. To make it easier to understand, I usually to do something like:

      puts (MysteryClass.methods - Object.methods).sort
      

      Which lets you ignore the built-in methods inherited from the default parent class (including ".methods" itself ๐Ÿ˜„ ) and displays the result alphabetically.

      By "a compiled class that is 'Required'" I assume you mean a 3rd party (binary) extension. Is that right? If so, some info can be gleaned from the binary itself, but not much (if any) more than using ".methods" and the like.

      You can look at it in a hex editor and usually see the names of classes, methods, etc. Under windows, I prefer this for snooping around ๐Ÿ˜‰

      Well, I doubt if that helps, but there it is...

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: Plugin to move everything inside a group to specific layer?

      To avoid this problem in the future, I suggest turning on the "Layers" tool-bar (if you haven't) and getting in the habit of checking it before you start creating or grouping any geometry/components.

      I also add mine to the recommendations of Chris' PutOnLayer, and I also recommend Todd Burch's layerchange.rb.

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: Vector3d.samedirection? tolerance is not what is expected

      You probably already came up with this, but here's my idea of a method to find SU's tolerance:

      Start with a blank model.

      Start a loop:

      1. Generate a pair of faces joined at angle "theta", which is initially 0 radians.

      2. Delete the common Edge.

      3. If there is one Face in SU.model.entities, repeat. If there are zero, stop because theta is larger than SU's tolerance for coplanar Faces.

      4. Increment theta by some small amount (0.001 radians, or something).

      5. Clear the model and loop.

      You can repeat the test with theta closer to the cutoff and incrementing by smaller amounts to converge on the precise value.

      I wish I had time to do this (I probably shouldn't have taken the time to post this ๐Ÿ’š) so, I hope you do it, 'cause I'd like to know what you find out.

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: Convert MaxScript to Ruby?

      BTW, jms files are meshes for use in the PC game Halo (don't sue me MS! ๐Ÿ˜‰ ).

      If anyone is crazy enough to do this, I found a (supposedly) better plugin called "Bluestreak" here (direct link to script).

      If this much time is to be spent, it should probably at least be used to convert the best example, no? Also, it might help in understanding the code to compare the two...

      I just want to (politely) point out to Arightwizard how incredibly difficult this task is (with very little payoff). You're probably better off just learning to use GMax/3DS...

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: How to assign a material to all selected objects (and faces)

      @thomthom said:

      Mind you, I've been annoyed by the native SU paint bucket that opens the material window every frickin' time. I've been meaning to make a custom paint-bucket that does that. And I figured I could them add functionality to paint front-and-back side. As well as clicking group/components and have the faces inside painted.

      Argh! Don't get me started on how annoying that is! I would be soooo grateful if you made a new paint-bucket tool! Also, some way of showing which material is selected would be handy... (but not in a floating window for obvious reasons ๐Ÿ˜‰ )

      Also, good job on that "copy material to the other side" tool.

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: How to assign a material to all selected objects (and faces)

      @thomthom said:

      @runnerpack said:

      One thing I've found handy when working on "solids" in SU is to have "Hide" assigned to the H key and "Unhide last" assigned to the U key. If you want the back of an inside face, click the front face, 'H'ide it, mess with the back of the other face, 'U'nhide it. You can get quite fast at it with practice. ๐Ÿ‘Š

      Another way is adding a shortcut to the Reverse Face function. Then you can paint the front face, Reverse, Paint the back, Reverse - Bob's your uncle.

      Yes, but I was referring to the face "behind" the face you're looking at. Like getting to the backface of the back of one of AcesHigh's window panes:

      Assuming a pane made of two faces A and B:
      Camera -> Front of A|Back of A <-space-> Back of B|Front of B

      Hide A to get to the back of B.

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: How to assign a material to all selected objects (and faces)

      Here's a one-liner that will paint the backs of any face with a certain material on the front:

      Sketchup.active_model.active_entities.each { |e| e.back_material = e.material if e.material.name == '<put_name_here>' and e.respond_to?('back_material=') }
      

      (NB: The 'name' method returns nil instead of 'Default' for the Default material.)

      Just put the name of your glass material where is says <put_name_here> and paste it into the ruby console to run it. It could be made into a full plugin fairly easily.

      I'm not sure about automatically painting the face on the back of the "pane", though. Maybe a ray-test followed by a comparison of normals and dimensions... sounds quite difficult and slow.

      One thing I've found handy when working on "solids" in SU is to have "Hide" assigned to the H key and "Unhide last" assigned to the U key. If you want the back of an inside face, click the front face, 'H'ide it, mess with the back of the other face, 'U'nhide it. You can get quite fast at it with practice. ๐Ÿ‘Š

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: Combining a plgn that uses a class for the def w/other plgns

      Whenever you want to know how to activate a certain plugin programmatically, look for the place where it adds a tool-bar button or menu item. Here is the code in this particular plugin that does that (it starts on line 56 in my <Plugins dir>/swivelButtonPlugin/swivelButton.rb):
      ` cmd = UI::Command.new(@@title) {handleToolbarButtonPress()}
      cmd.small_icon = tempImgDirectory + "/swivelButtontb.png"
      cmd.large_icon = tempImgDirectory + "/swivelButtontb.png"
      cmd.status_bar_text = cmd.tooltip = "Create a set of images orbiting a model"
      cmd.menu_text = @@title
      swivelToolbar = UI::Toolbar.new(@@title)
      swivelToolbar.add_item(cmd)
      swivelToolbar.show

      UI::menu('Tools').add_item(cmd);`

      As you can see, the menu and tool-bar button both refer to a UI::Command object whose command is "handleToolbarButtonPress()". By calling this method in your code, it will have the same effect as someone manually choosing the button or menu item.

      Remember: Follow the mon... menu! ๐Ÿ˜‰

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: I need help!

      I'm not sure about (a), but all curves in SketchUp are actually collections of straight edges. If you want to make it look smoother, just tell SU to use more edges. For arcs and circles, this can be changed on-the-fly, but imported stuff usually uses uneditable "Curves" which are sort of like Groups but for a string of edges that are attached end-to-end. You'll either have to change how it's imported in the first place, or manually replace all the curves with newer, higher-resolution ones. I suppose the second option could be automated, but I don't think there is currently a script for that.

      These threads might help:
      http://forums.sketchucation.com/viewtopic.php?f=180&t=18963
      http://forums.sketchucation.com/viewtopic.php?f=180&t=19270

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: Are Swig generated Ruby bindings compatible with Sketchup?

      I'm going to provide my "armchair CS major" version of what I think is going on. ๐Ÿ˜‰

      I've had some experience with SWIG and Ruby extensions and, from what I've read, the wrapper/extension has to be linked to the same libruby that was linked with the ruby runtime, i.e. the executable called "ruby" (or "ruby.exe" for the win32 version) in a stand-alone installation.

      In SketchUp's case, the environment is inside the SketchUp executable, and the libruby included (in my SU7.1/win32 install) is 'msvcrt-ruby18.dll'.

      So, what you need to do is find out how to link against a 1.8.0 version of the ruby library. It goes without saying that said library also has to be compiled for the same machine/OS as the one SU is using. Actually, the one extension I compiled for SU was linked against the 1.8.7 version of "msvcrt-ruby18.dll" and still worked (well, it didn't actually work, but that was because it also used OpenGL for graphics, but it didn't crash SU, at least).

      Ideally, you would link to the actual library included in the SU installation. I think on OSX it would be called "libruby-1.8.dylib" (or something like that).

      Of course, having absolutely no experience with OSX, I don't know how to deal with things like multiple processor architecture support and such, or even whether that applies to this situation ๐Ÿ˜†.

      A bit long-winded, but I hope it helps ๐Ÿ˜„

      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • RE: Use Ruby To Apply Materials to Spacific Layers

      @honoluludesktop said:

      Amos, Thanks, I will give it a spin the next time I have a model that I import by component/texture into my model:-) Btw, I am more of a hacker then a Ruby programmer, any hints on "another test for groups" is welcomed.

      I just meant to add another "if" statement to test for Group entities. It's necessary if you use e.definition.name, since Groups don't have definitions. But it would actually take a bit of code refactoring, like so:

      
      module Eric_Erb_and_AJB
      
          def self.paint_by_name
              mod = Sketchup.active_model
              su_materials = mod.materials
      
              begin
                  mod.start_operation("Paint By Layer", true)
              rescue ArgumentError
                  mod.start_operation("Paint By Layer")
              end
      
              # Loop through entities & apply material based on layer name
              Sketchup.active_model.entities.each do |e|
                  begin
                      mat = su_materials[e.definition.name]
                  rescue
                      mat = su_materials[e.name]
                  end
      
                  unless mat.nil?
                      if e.is_a? Sketchup;;ComponentInstance or e.is_a? Sketchup;;Group then
                          e.material = mat
                      end
                  end
      
              end
      
              mod.commit_operation
          end
      
      end
      
      unless file_loaded? File;;basename(__FILE__)
          UI.menu('Plugins').add_item('Paint by Layer') { Eric_Erb_and_AJB.paint_by_name }
          file_loaded File;;basename(__FILE__)
      end
      
      
      posted in Developers' Forum
      RunnerPackR
      RunnerPack
    • 1 / 1