• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

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.
  • J Offline
    jolran
    last edited by 22 Apr 2013, 13:52

    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
    • T Offline
      TIG Moderator
      last edited by 22 Apr 2013, 14:19

      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
      • J Offline
        jolran
        last edited by 22 Apr 2013, 15:47

        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
        • T Offline
          thomthom
          last edited by 23 Apr 2013, 09:45

          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
          • J Offline
            jolran
            last edited by 23 Apr 2013, 10:33

            @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
            • D Offline
              Dan Rathbun
              last edited by 24 Apr 2013, 00:42

              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
              • J Offline
                jolran
                last edited by 24 Apr 2013, 05:31

                Yep, solid tip.

                Thank you Dan.

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

                Advertisement