• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Extract 3D information to regenerate the shape

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 3 Posters 689 Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    Ruts
    last edited by 4 Aug 2015, 11:13

    Hi,

    I am going to expand a piece of software that calculates radiation in a 3D environment. For now we create the 3D environment by using simple basic shapes like boxes,spheres,cylinders,... . All those different shapes which form the complete 3D environment are listed in a database. This database saves which kind of shape it is and some parameters to determine the size, place and rotation in the coordinate system.

    For example if I want to create a simple box I insert following in the database:

    • type:Box* First corner coordinates (X,Y,Z)* Width,Length and Heigth* Rotation from X-,Y- or Z-axis

    We want to expand our software so we don't have to insert every shape in the database, but can draw those shapes in a CAD program. My plan is to find a CAD program that's able to draw a 3D sketch with basic shapes and can give me the parameters according it's geometrical position in the coordinate system. I was wondering if this is possible with Sketchup (Pro)?

    Once I can retrieve the parameters of the shapes I can create a little program that translates those parameters into the parameters that our piece of software understands.

    Kind regards
    Ruts

    1 Reply Last reply Reply Quote 0
    • O Offline
      oceanembers
      last edited by 5 Aug 2015, 09:52

      You can use ruby scripting for this. For instance, if I make a cube of 1m by 1m, and group it, I can print the dimensions to the console by selecting it and using this:

      
      grp = Sketchup.active_model.selection[0];
      puts "Width; #{grp.local_bounds.width}\nDepth; #{grp.local_bounds.depth}\nHeight #{grp.local_bounds.height}";
      
      

      The API can be found here: http://www.sketchup.com/intl/en/developer/index

      1 Reply Last reply Reply Quote 0
      • R Offline
        Ruts
        last edited by 6 Aug 2015, 06:27

        Thanks for your respons oceanembers,

        So let's say I have drawn a cube with a random rotation somewhere in the coordinate system. Is it possible to extract all the information like centeroid of the cube, width/length/heigth and rotation matrix or angles with ruby scripting? If this is the case this seems very intresting.

        It would also be nice if it detects which space figure it is by itself.

        Kind regards
        Ruts

        1 Reply Last reply Reply Quote 0
        • D Offline
          Dan Rathbun
          last edited by 6 Aug 2015, 21:54

          SketchUp is a surface modeler. Everything in SketchUp is basically made up of edges, vertices, and faces.

          There are no complex built-in 3D shape classes in the SketchUp Ruby API.

          Instead primitives are either grouped into Group class instances, or ComponentInstance class instances. (Each have a defining ComponentDefinition class instance.)

          These mentioned classes are all sub-classes of Entity, and inherit it's functionality (as well as the intermediate Drawingelement class functionality.)

          Any Entity subclass instance can have any number of AttributeDictionary instances attached to them. You can put whatever custom data you wish into attributes in a custom dictionary, usually named the same as your plugin. (Ex: "Ruts_Shaper_Properties")

          Back to the grouped 3D shape. Groups and components have a built-in definition name and each instance of them can have a separate more unique instance name. Group and component instances have built-in transformation property, from which you can query all the translational, rotational, scaling and axial subproperties. See the Geom::Transformation class.

          All Drawingelement subclasses (the objects that can be seen in the model,) have an invisible boundingbox, from which you can get the corners and the center. See the Geom::BoundingBox class.

          It would be more efficient to create the basic shapes as an external SKP component library, and insert them into the model, rather than draw each using code, but drawing them adhoc can be done.

          You should most likely install the SketchUp Team's example Shapes plugin , and study the code.
          http://extensions.sketchup.com/en/search/site/Shapes

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          1 / 1
          • First post
            1/4
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement