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

    Reference to entities(id)

    Scheduled Pinned Locked Moved Developers' Forum
    7 Posts 4 Posters 445 Views 4 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.
    • jolranJ Offline
      jolran
      last edited by

      I want to get references to entities for passing strings to webdialog.

      What do one use safely without riscing getting them gb'd ?
      Was gonna use entityID but this got me a tad worried:
      http://sketchucation.com/forums/viewtopic.php?f=180&t=49354&p=443630&hilit=entity+id#p443630

      Although here Dan mention object_id or id
      http://sketchucation.com/forums/viewtopic.php?f=180&t=47845&p=429085&hilit=entity+id#p429085

      I guess one could assign an attribute with a timestamp, but it feels like overkill..

      Further detail. Id does not need to be kept between sessions. And perhaps I'm going to simulate the entities geometry with the drawclass & openGL, = the entities remain unaltered.
      Last part not sure yet..

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        A unique 'tid' [timestamp-id] attached to the object as an attribute should persist across sessions.
        If an object is deleted but then undone the replacement object should be given the 'tid' [as is its layer/material etc], BUT its 'elementID' will then differ.
        The normal elementID, object_id/id etc should persist during a session, but they can be 'lost' during some operations, like undo and operations that create new but otherwise similar looking geometry - like PushPull... where replacement geometry does not keep the original's 'id'...

        It depends what you are doing with any 'id' for and the likelihood of it getting lost in transit...

        TIG

        1 Reply Last reply Reply Quote 0
        • jolranJ Offline
          jolran
          last edited by

          Thank you TIG πŸ˜„

          That sounds reasonable.
          Sounds like [timestamp-id] attribute might be the way to go then.

          Regarding simulating geometry via view.draw OPENGL. I was wrong about avoiding this issue.
          Still run into the same problem with ID's gb'd when altering the same entities
          at a later stage, (as you pointed out).

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

            What are you doing with these entity ids?

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

            1 Reply Last reply Reply Quote 0
            • jolranJ Offline
              jolran
              last edited by

              @unknownuser said:

              I want to get references to entities for passing strings to webdialog.

              I think you have to interpret my question literally Thomthom. Cause I'm not really sure what I need yet. Not in a state yet for testing this proposed solution anyhow.

              A string going back and forth JS <-> Ruby should contain enough uniq information so I can get a hold of the correct entity in Sketchup.

              Now there are some considerations of tolerance to this and altering of geometry,
              (as TIG pointed out).

              At this stage maybe one should try the easiest approach, with attributes.
              Assigning attributes is pretty painless. However theres one extra step to remove the attribute when swithcing or deleting selection.

              I guess it's also possible to store selections in Ruby array or Hash and reference to that by index or key (coming from JS), and have a more general text-represenation in Webdialog?
              Id's are named quite cryptic anyway with <> illegal html characters..
              edit: Doing it this way one still would face the same issue, regarding lost id's from edited geometry.

              I'm open for suggestions, not in a hurry solving this problem..

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                You can always test an object to see if it is still valid ...

                obj.valid?

                But if you are storing ids ...

                new_object_ref = ObjectSpace._id2ref(some_id_integer)
                # test if it's valid;
                if new_object_ref.is_a?(Sketchup;;Entity)
                && new_object_ref.valid?
                  # do something with new_object_ref
                end
                

                πŸ’­

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • jolranJ Offline
                  jolran
                  last edited by

                  Yep, solid tip.

                  Thank you Dan.

                  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