sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Add_faces_from_mesh returns what ?

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 265 Views 2 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.
    • Didier BurD Offline
      Didier Bur
      last edited by

      Hi guys,
      As the API doc says, 'add_faces_from_mesh' is supposed to return an array of newly created faces, if successful.
      I always got 0 or nil as return values (like 'fill_from_mesh').
      If I want to retrieve the newly created faces, do I have to store the number of entities before an 'add_faces_from_mesh', then count the new entities.length after the 'add_faces_from_mesh' call, then iterate through these new entities to retrieve the faces ???
      Any help appreciated πŸ˜„

      DB

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Yea, the docs are wrong.

        To get the new entities:

        entities = Sketchup.active_model.active_entities cache = entities.to_a entities.add_faces_from_mesh( mesh ) new_entities = entities.to_a - cache

        Thomas Thomassen β€” SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • Didier BurD Offline
          Didier Bur
          last edited by

          Thanks ThomThom,
          Here is what I planned to do:

          nEntsBefore=Sketchup.active_model.entities.length
          Sketchup.active_model.entities.add_faces_from_mesh(m)
          nEntsAfter=Sketchup.active_model.entities.length
          arrayOfNewFaces=[]
          nEntsBefore.upto(nEntsAfter-1) { |i| next if ent=Sketchup.active_model.entities[i]; arrayOfNewFaces.push(ent) }
          

          Your code is mush more simple than mine πŸ˜‰

          DB

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

          Advertisement