sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Ruby Architecture concerning Deleted Entities

    Scheduled Pinned Locked Moved SketchUp Discussions
    sketchup
    1 Posts 1 Posters 528 Views 1 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.
    • P Offline
      pipman
      last edited by

      Sketchup deletes and replaces entities as it desires - sometime from one ruby line to the next.

      I am trying to build fast routines avoiding to to manipulations which would necessarily lead to new entities (however - if SU decides to do so I obviously can't stop it from doing so).

      sumod = load_skp_entities_from_file("xxx.skp")

      lets assume, ents is loaded as a Sketchup::ComponentInstance, then the reference to its entities is:

      ents = sumod.definition.entities

      now I need to work with those entities in order to make changes to the loaded model.

      at one point in the code I run into the following part:

      return if ents.deleted? # ents.deleted? is false
      puts ents.length

      and sketchup breaks with "undefined method `length' for #<Deleted Entity:0xef91fd8>"
      in THE VERY NEXT LINE after having checked that it is NOT deleted.
      and there is no chance to get information on how why when or how to avoid this

      the only comments I found were: "why work with entities, create new ones right away as you need them". this is not how my code works for many good reasons (like not having to model and especially correctly texturize from scratch). It really needs to load entities and work with them.

      Are there any guidelines, help on how to keep entity references (or meta references) valid in a fast and efficient way?

      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