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
    • Image to Surface Plot

      Hey everyone! I've been thinking about making a cool new background for my desktop and I thought of making something with transparent droplets on a surface rendered with Kerkythea. To do so, I first need to make the droplets and that could be time consuming if I want to make some in large numbers manually in Sketchup. However, I can surely find an easy way to make an image of droplets. Is there a plugin or a method out there to make a surface plot from an intensity map/image?

      Thanks,
      TheDro

      posted in Developers' Forum
      T
      TheDro
    • RE: Is this plugin possible?

      @byrnebm: Did the plugin TIG suggested work for you? If not I might be able to write something up for you to brush up on my ruby skills. Let me know.

      posted in Developers' Forum
      T
      TheDro
    • RE: [Plugin] Voxelize - Updated 2011-04-04

      If you open up Window>>Ruby Console, before running the plugin, the debug information will tell you how many cubes were created, among other things. The other things are the amount of time each step takes to run. This is probably more helpful to me than to you but remember, this is still in beta πŸ˜„.

      posted in Plugins
      T
      TheDro
    • RE: [Plugin] Voxelize - Updated 2011-04-04

      I might eventually get to adding that feature but it's hard to say when. I've been pretty busy this summer and plan to be until September so I might not get to programming any time soon. I just checked out some of the methods of components (instance and definition) and there is a "bounds" method (not found in the api documentation...) which I could use to run my script. This means it should be possible to make it work for components but I might not get to it any time soon.

      Have a great summer πŸ˜„ .

      posted in Plugins
      T
      TheDro
    • [Plugin] MCExport - Updated 2011-04-04

      For those of you who would like to export your greatest Sketchup creations into MineCraft, now you can! MCExport is a plugin that is used in conjunction with my Voxelize plugin in order to transform a solid in Sketchup to a bunch of blocks saved in a .schematic file. The Voxelize plugin can be found here:http://forums.sketchucation.com/viewtopic.php?f=180&t=36063. The .schematic file can then be imported into your MC world using MCEdit. To use the MCExport plugin, you need to put the mcexport.rb file in your plugins folder. Unfortunately, the format of .schematic files requires Zlib which is a compression library. For this you need to actually have a ruby installation on your computer. If you don't have ruby already installed, I would suggest you install version 1.8.6 since this is the version that is used by Sketchup. This would reduce any potential conflicts between versions. Now for the MCExport plugin to see Zlib, there are a couple methods that can be used. For a Windows user with a typical ruby installation, you can place the tdloadpaths.rb file in your Sketchup plugins folder. This is the method I would suggest for users who are less familiar with moving files around or editing ruby code. If that doesn't work, you could modify the tdloadpaths.rb file to reflect the location of your own ruby installation. I think it is also possible to change the "require 'zlib'" line in mcexport.rb to the full path where the file zlib.so is found on your computer (for example: "require 'C:/Ruby186/lib/ruby/1.8/i386-mingw32/zlib'"). Using this method, the tdloadpaths.rb script wouldn't be necessary. Yet another possibility would be to copy the file zlib.so to the Sketchup plugins folder, although I've been advised not to advise people to do this πŸ˜‰.

      Now, to use the plugin, first select the group containing the solid that you want to export to MineCraft (see how to use voxelize) and then select Plugins->MCExport (0.1.0). Next, choose where you want to save the file. The file should be named <filename>.schematic. Next, choose the parameters you would use in voxelize (I would recommend trying out voxelize alone before MCExport). If the export is successful, the .schematic file should appear where you chose to save it and it can be imported using MCEdit.

      The plugin is still an early version and doesn't make sure that the solid is too big to be exported to a .schematic file, nor does it give the user the option to see the voxelized solid in Sketchup, nor does it let the user know if everything was successful... But it's work in progress and these features will be added eventually πŸ˜„.

      Well, have fun!


      MCExport version 0.1.0


      Script written to find Zlib.so


      A sphere imported into MineCraft

      posted in Plugins
      T
      TheDro
    • RE: [Plugin] Voxelize - Updated 2011-04-04

      @Gillman: I'm glad to hear that it was of use to you.

      @Khai: I've been looking at the structure of the .schematic file which is used to import structures into Minecraft using MCEdit. I think I've got it figured out but I still need to write the code and I'm reading the book of ruby to try and figure out the best way to do it.

      @Everyone: I've added a new "spiral" algorithm to prevent interpreting sharp edges of solids as "entrances" to the solids. Basically, I improved the algorithm to work with more solids which is good. I'll upload the new version once I'm not too busy with work/school.

      posted in Plugins
      T
      TheDro
    • RE: [Plugin] Voxelize - Updated 2011-04-04

      Well it's possible to spread out the cubes just by modifying any one of the cubes since they are all instances of the same component. So you can double click on one of the cubes, then use the scaling tool to shrink it, and they will all shrink while remaining in position, and this will produce spacing between them all. As for the plane slicing, I'm not sure I follow. Could explain in more detail, 22curious?

      I'll probably release a new version tonight that calculates the position of the cubes MUCH faster.

      posted in Plugins
      T
      TheDro
    • RE: [Plugin] Voxelize - Updated 2011-04-04

      @Khai Hah! Minecraft is actually what first inspired me to write this plugin since it would be a relatively simple way of creating complicated geometries (building plans). It may have other applications though such as Monte Carlo simulation using Geant4. Geant4 is basically a particle physics toolkit that's used to simulate particles interacting with matter. Making geometry with the toolkit can be quite tedious to do code-wise and is far more difficult than using Sketchup. Making cubes is simple though and the application of my plugin is obvious in this case. Anyways, back to Minecraft πŸ˜›. As for exporting to a compatible format, I would first have to figure out what that format is but I'm sure it wouldn't be too difficult since the plugin already creates a 3D "binary" matrix. I'll get to that ... eventually.

      @Dan Thanks again. I'll get to reading your links concerning modules either tomorrow or the day after.

      posted in Plugins
      T
      TheDro
    • RE: [Plugin] Voxelize - Updated 2011-04-04

      Thanks for the changes, Dan. It's my first time programming in ruby and I'm still a bit iffy about modules and classes and when to use which. I've looked at some documentation about them but haven't had time to read it thoroughly. I've preceded my method names by td_ based on something I read in a thread around here having to do with name conflicts between plugins. Do I need to do that or can I skip it since my plugin is now in its own module?

      posted in Plugins
      T
      TheDro
    • RE: [Plugin] Voxelize - Updated 2011-04-04

      Well to "layerize", if by that you mean look at the model layer by layer, you can use the Section Plane tool. The plugin produces a 3D matrix of 1s and nils which could easily be manipulated, too. As for the lego blocks, that could be implemented by using this matrix in a clever way.

      posted in Plugins
      T
      TheDro
    • RE: [Plugin] Voxelize - Updated 2011-04-04

      @kdasilva: I added the colors manually and arbitrarily just to make it easier to see which faces were in which direction. I thought of an autoscale feature but then thought it was better the way it is now although I could add that relatively easily, I think. It also wouldn't be difficult for the user to do the calculation on his own by setting the cube length to the length of the group divided by the number of cubes he wants. Could you suggest what options I should make available on the message box for such a features?

      @solo: I was actually unaware that faces had a direction but I'll look into flipping them in the definition of the cubes.
      Edit: This has been fixed and will be in the next release.

      Thanks for the input, guys!

      posted in Plugins
      T
      TheDro
    • RE: [Plugin] Voxelize - Updated 2011-04-04

      What do you mean by reverse faces? The cube faces? If you're talking about the image, it's not just a sphere, it's a sphere with a cylinder pushed into the top of it.

      posted in Plugins
      T
      TheDro
    • [Plugin] Voxelize - Updated 2011-04-04

      Hey everyone! I've been working on a plugin for the past couple weeks and I think it's about time I share it with the community. It's still very much in its infancy (beta version) and still runs very slowly for moderately complicated solids but you guys can still try it out and let me know what you think. The script is called voxelize. Basically what it does is transforms a solid (within a group) into a bunch of little cubes. So in the same way as you can for example "pixelize" a circle, that is, transform a smooth drawing into a bunch of pixels, my plugin allows you to voxelize a solid, a voxel being a 3-dimensional pixel (cube).

      When the plugin is called on a group, a pop-up window will ask the user the size of each cube and whether a full solid or a shell should be made.(The three other options aren't quite implemented yet so don't worry about them.) The shell option usually runs a lot faster since it will produce a lot less cubes. As I mentioned, the plugin can take quite a while to compute the position of the cubes and so on. This still causes Sketchup to whiteout and "not respond" for a while, even though it's running fine in the background. There is a way to fix this problem as mentioned in this thread:http://forums.sketchucation.com/viewtopic.php?f=180&t=34205&hilit=not+responding, but I haven't gotten to that yet. One thing to keep in mind, is that the amount of time it takes to run the script is "proportional" to the number of faces in the solid. As a reference though, it takes about 30 seconds to render a full sphere with a radius of 20 cubes and about 4-5 second to render a shell of the same sphere with my 2.4 GHz processor. This rendering time will shorten as I improve the algorithm and just this morning I've thought of two new algorithms which may or may not speed up the process.

      Anyways, enjoy!

      P.S. Almost forgot to mention, the cubes that are produces are all instances of a component which means that by modifying one cube, you can change all of them.

      EDIT: Beta 02

      Alright! The second version is out and it's WAY faster! Here's a list of the major changes:

      • The new algorithm for finding where cubes should be places is much faster now that it doesn't check the whole zy grid for intersections with EVERY face. Each face is probed by a sub grid. If you don't understand what this means, it doesn't even matter πŸ˜›. For a sphere with a radius of 20 cubes, it used to take about 4 seconds to compute the voxelized grid and now it takes about 0.3 seconds.

      • The x-y-z offset options have been removed since they weren't all that useful in the first place.

      • Shell mode has now been made the default since it is the faster mode.

      • Fixed a small bug pointed out by Solo where one face of the cubes was upside down.

      EDIT: Beta 03

      Dan Rathbun helped me out with proper module wrapping, method naming and error checking/catching. This version wasn't released but definitely brought many changes which makes my code more stable. Thanks again, Dan.

      Beta 04

      Another release! Most of the changes won't be noticeable to the common user but there is still much improvement that was made.

      • The new "spiral" algorithm is used to properly address hitting edges and vertices when checking where to place the cubes.

      • It is possible to call voxelize(false) in order to suppress the method from drawing cubes in case the method is just used by another program/plugin.

      • The method now returns the binCubes and cubes arrays. The former can be used to export the binary 3D array. See my new upcoming plugin, MCExport, which exports the array to a .schematic file which can be imported into MineCraft. (There you go, Khai πŸ˜‰ )

      note: No improvements have been made to the algorithm that places the cubes which means that this process is still slow for large models.


      Here's an example of what can be done with the plugin.


      Voxelize version 0.4.0

      posted in Plugins
      T
      TheDro
    • RE: Compound Transformation

      Sorry, I realize how unclear that was since wanting to separate isn't related to the same situation as combining them. In one part of a script I've written, I want to combine two transformations but elsewhere in the script, I would like to get the transformation of a group for example and separate the scaling part of it from the rest. I hope this makes more sense.

      posted in Developers' Forum
      T
      TheDro
    • RE: Compound Transformation

      Ya I got it to work, thanks. Do you know if it's possible to separate the scaling part of a transformation from the translation and rotation parts?

      posted in Developers' Forum
      T
      TheDro
    • RE: Compound Transformation

      Thanks, TIG. So is this missing from the API docs? The * method for transformations only shows its use with a Point3d as an input argument.

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

      Alright so I posted my results on the api but is it possible to edit it in case there is a mistake?(not that I've found one) Oh and it's posted as anonymous.... whatever. πŸ˜›

      posted in Developers' Forum
      T
      TheDro
    • Compound Transformation

      I've been reading the thread "A way to avoid that ?" in order to stop a long script I'm writing to cause Sketchup to "not respond" and I'm starting by speeding up my script by following thomthom's advice here :http://forums.sketchucation.com/viewtopic.php?f=180&t=34205&hilit=not+responding&start=0#p301004

      I was wondering if it was possible to apply one transform to another. For example, I have trans = Geom::Transformation.translation(vect1) and rot = Geom::Transformation.rotation(vect2) (these arguments may not make sense but it's not what's important), and I want to do something like trans.transform!(rot) so that both transformations are in one, which I can then apply to entities.

      Thanks.

      posted in Developers' Forum
      T
      TheDro
    • RE: Get Current Units

      Thanks guys. I love how active this whole forum is.

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

      Alright, let's try to put this one to rest πŸ˜›. I just tested it with a face on the xy plane with a hole in it and here are the results(and code):

      puts "On Face(Inside); " + face.classify_point([0.25,0.25,0]).to_s #1
      puts "On Vertex; " + face.classify_point([0,0,0]).to_s             #2
      puts "On Edge; " + face.classify_point([0.25,0,0]).to_s            #4
      puts "Outside; " + face.classify_point([-0.5,0,0]).to_s            #16
      puts "In Hole; " + face.classify_point([0.6,0.6,0]).to_s           #16
      puts "NotOnPlane; " + face.classify_point([0,0,1]).to_s            #32
      

      So this means that whether the point is in a hole or outside the face, the return value is the same (16). I think that answers TIG's question about the matter. The OnFace constant (which is 😎 is not in the API nor am I able to choose a point that returns the value. It could therefore be obsolete. If someone can think of another case that I missed, let me know (other than an error (0) of course).

      Oh and just a quick note. The return value of the classify_point method will be one of the above values and NOT a sum of multiple values. I mention this because I expected a point on an vertex to return 6 or 7 because a point on a vertex is on the face and an edge at the same time, but this is not the case.

      As for how I'll write my code, well there are two ways of doing and I think this would be the shortest way (syntactically) of doing it:

      if (face.classify_point(point)&(Sketchup;;Face;;PointInside+Sketchup;;Face;;PointOnVertex+Sketchup;;Face;;PointOnEdge))!=0
      

      As long as those constants remain powers of 2, the code should work although to be safe I might just go with if((p==a) or (p==b) or (p==c)), which doesn't require any bitwise operations (I just find the bitwise way of doing cool since I've come to understand it recently πŸ˜›).

      EDIT:
      As requested, here is the definitive list of the constants:

      0: Sketchup::Face::PointUnknown (error)
      1: Sketchup::Face::PointInside (somewhere on the face)
      2: Skethcup::Face::PointOnVertex (on one of the vertices of the face)
      4: Skethcup::Face::PointOnEdge (on one of the edges of the face, vertices do not count since they return 2)
      8: Sketchup::Face::PointOnFace (likely obsolete)
      16:Sketchup::Face::PointOutside (on plane of the face but not on face; this includes holes)
      32:Sketchup::Face::PointNotOnPlane (not on the face's plane)

      Remember that this is for version 8.0 and that the constants should be used instead of the numerical values for forward compatibility.

      posted in Developers' Forum
      T
      TheDro
    • 1 / 1