sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Validate points for planar faces.

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 366 Views
    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.
    • D Offline
      Djarlo
      last edited by

      Hey all, im pretty fresh to this forum, so i'll start with introducing myself πŸ˜„
      So yah, Im Djarlo, currently living in the Netherlands.
      Cause i have a light form of autism Some coding languages are extremely easy for me to learn and others really difficult. with Ruby being one that is rather difficult.

      I have several SketchUp related Application projects.

      1. An application for making Skeleton hierarchies and animating them. (Alpha)
      2. An Application to weight parts of the mesh to different Skeleton bones. (Beta)
        And im working on an Importer currently.

      All of the apps contain very little Ruby, and are handled by an external process.

      I have an issue with the importer im working on, it works dine with xmf files exported with 3DS-Max and Blender, but not too well with files exported with SketchUp. unfortunately the creator of that exporter suddenly dissapeared years ago without ever finishing it 😞 and its a rbs, so theres nothing to be done there.

      The problem is it wrongly exports certain lines as faces, ofc. those are not planar faces.

      My plugin does this:

      exe = Sketchup.find_support_file "xmftorb.exe", "Plugins/"
      plugins_menu = UI.menu("Plugins")
      menu = plugins_menu.add_submenu('XMF Importer')
      xmfReload = menu.add_item('Import xmf') {
      	File.delete(ENV["TMP"] + '\mesh.rb') if File.exists?(ENV["TMP"] + '\mesh.rb')
      	UI.openURL exe
      	until File.exists?(ENV["TMP"] + '\mesh.rb')
      		sleep 10
      	end
      	load ENV["TMP"] + '\mesh.rb'
      	File.delete(ENV["TMP"] + '\mesh.rb') if File.exists?(ENV["TMP"] + '\mesh.rb')
      	}
      

      The program lets you open a file and and creates a ruby script with the info from that file, the script looks like this:

      i = Sketchup.active_model.entities.add_group
      i.name = "Car[0]"
      i.entities.add_face [-349.200000.mm, -658.578644.mm, 135.616973.mm], [349.200000.mm, -658.578644.mm, 58.578644.mm], [-349.200000.mm, -658.578644.mm, 58.578644.mm]
      i.entities.add_face [349.200000.mm, -658.578644.mm, 58.578644.mm], [-349.200000.mm, -658.578644.mm, 135.616973.mm], [349.200000.mm, -658.578644.mm, 135.616973.mm]
      i.entities.add_face [349.200000.mm, -658.578644.mm, 58.578644.mm], [349.200000.mm, -941.421356.mm, 185.453688.mm], [349.200000.mm, -941.421356.mm, 58.578644.mm]
      i.entities.add_face [349.200000.mm, -941.421356.mm, 185.453688.mm], [349.200000.mm, -658.578644.mm, 58.578644.mm], [349.200000.mm, -658.578644.mm, 185.453688.mm]
      i.entities.add_face [-349.200000.mm, 800.000000.mm, 341.421356.mm], [-349.200000.mm, 658.578644.mm, 185.453688.mm], [-349.200000.mm, 658.578644.mm, 341.421356.mm]
      i.entities.add_face [-349.200000.mm, 658.578644.mm, 185.453688.mm], [-349.200000.mm, 800.000000.mm, 341.421356.mm], [-349.200000.mm, 658.578644.mm, 135.616973.mm]
      

      Witch gets loaded and deleted again.
      Obviously it error's out on non-planar faces.
      I tried to ignore non-planar faces by adding an error handler in the exe.
      if all Y is the same AND all X is the same = Ignore
      if all Y is the same AND all Z is the same = Ignore
      if all X is the same AND all Z is the same = Ignore

      But that just takes care of the straight lines and not the diagonal ones 😞

      Is there any way of error handling available in Ruby?
      or maybe theres some calculation on the points that can verify whether or not those points make a valid planar face.
      Or perhaps some command in SketchUp that can check/verify the points?

      thanks.

      1 Reply Last reply Reply Quote 0
      • GaieusG Offline
        Gaieus
        last edited by

        Hi Djarlo and welcome!

        There are already some nice examples of skeleton animation, see this post for example:
        http://forums.sketchucation.com/viewtopic.php?f=323&t=34530

        Also, we have a Developers' Forum - your ruby topic would rather belong there. If you wish, I can move it and there, with the other scripters, you could improve your importer easier I believe.

        Gai...

        1 Reply Last reply Reply Quote 0
        • D Offline
          Djarlo
          last edited by

          @gaieus said:

          Hi Djarlo and welcome!

          There are already some nice examples of skeleton animation, see this post for example:
          http://forums.sketchucation.com/viewtopic.php?f=323&t=34530

          Also, we have a Developers' Forum - your ruby topic would rather belong there. If you wish, I can move it and there, with the other scripters, you could improve your importer easier I believe.

          Hi, thanks for your reply, thats an interesting thread, very different as what i'm working on though.
          And yes if you could move my thread to the correct forum that would be great.)

          1 Reply Last reply Reply Quote 0
          • D Offline
            Djarlo
            last edited by

            Anyone has any suggestions?

            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