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

    Posts

    Recent Best Controversial
    • RE: Curved surfaces with Ruby

      @tig said:

      selection.to_a should be 'all connected faces' ??

      THAT's what I needed! Thanks! I should have probably spotted that before, but I made a silly mistake in my experimentations with the console and got myself thinking that when I selected a surface, Ruby thought the whole thing was just one face.

      posted in Developers' Forum
      A
      alexmojaki
    • RE: Array of faces attribute all turn to nil ?

      What I've mainly needed is to be able to access the faces given x and y coordinates, hence I needed the cells array to provide the order (so "faces=grid.entities.to_a.find_all{|e|e.is_a?(Sketchup::Face)}" wouldn't have been quite good enough). Since I couldn't pass 'cells' on, my only solution was to recreate the faces in another script and make another cells array there. But this seemed wasteful and inelegant, so I was hoping for a better solution here. You've helped me to think of a better way, thanks.

      Edit: I also wanted an explanation as to why it was acting weird, so thanks for that too.

      posted in Newbie Forum
      A
      alexmojaki
    • RE: Curved surfaces with Ruby

      @tig said:

      Since a surface's faces are all connected and their shared edges are smooth? you can devise ways of getting all of the faces in a surface from one face in that surface...
      What is the intention of your code ?

      I'd like to know:

      All the points/vertices that make the surface.
      All the normals of the faces that make up the surface.

      I also want to be able to take a set of points and project them onto the surface, or rather find the intersection point between a ray and the surface.

      Your suggestion about connected faces is a bit vague. I would still need to be able to get one of the faces in the surface (without help from the user) and I don't know what makes an edge 'smooth'.

      posted in Developers' Forum
      A
      alexmojaki
    • Array of faces attribute all turn to nil ?

      Hi,

      I have a script which takes a face and fits a grid to it. I tried to store information about the grid so that other scripts can analyse it. In particular, I have a 2D (so that the objects can be accessed with x and y coordinates) array called nodes which contains a set of Point3d objects, which I stored with:

      grid.set_attribute("grid_properties", "nodes", nodes)

      This worked fine, but when I similarly try to store a 2D array called cells which contains a lot of faces, i.e. it looks like:

      [ [Face, Face, ...] , [Face, Face, ...] , ... ]

      what gets stored is the array with all faces replaced by nil, i.e.

      [ [nil, nil, ...] , [nil, nil, ...] , ... ]

      The cells array itself is not affected. To demonstrate, I have the following code in my script:

      puts cells
      grid.set_attribute("grid_properties", "cells", cells)
      puts grid.attribute_dictionaries["grid_properties"]["cells"]
      

      The output from the console is then something like:

      #Sketchup::Face:0x1ac7e9fc
      #Sketchup::Face:0x1ac7e984
      #Sketchup::Face:0x1ac7e90c
      #Sketchup::Face:0x1ac7e894
      #Sketchup::Face:0x1ac7e81c
      #Sketchup::Face:0x1ac7e7a4
      #Sketchup::Face:0x1ac7e72c
      nil
      nil
      nil
      nil
      nil
      nil
      nil

      Help?

      posted in Newbie Forum sketchup
      A
      alexmojaki
    • Curved surfaces with Ruby

      Hi,

      I'm trying to understand how to work with curved surfaces in SU using Ruby. I'd like to, for example, get an array of face objects that make up a surface. The API documentation seems very poor as it says that Faces are flat polygons, but when I select the outside of a cylinder, the Ruby console tells me it's a Face object. I tried using add_faces_from_mesh, but it just splits the surface into one of the component faces and the remaining surface, and returns 0.

      posted in Developers' Forum
      A
      alexmojaki
    • 1
    • 2
    • 2 / 2