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

    Erase a single unused Definition

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 414 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.
    • J Offline
      Jim
      last edited by

      I would like to delete a specific unused Definition from a model, but all I can find is Definitionlist#purge_all which deleted all unused Definitions. Is there a way?

      Hi

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

        Yes πŸ˜„
        This way erases individual component [and group] definitions rather than the heavy handed model.definitions.purge_all...
        Use this
        model.start_operation('DeleteDefn') defn.entities.erase_entities(defn.entities.to_a) model.commit_operation
        If it's within a broader 'start/commit' block then it works too...
        The 'operation' is needed to refresh the Component-Browser's contents...
        Warning - IF the definition has instances it will erase them all too, so check with !defn.instances[0], unless of course you want it to do that !

        TIG

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jim
          last edited by

          Thanks, TIG.

          This is of course in reference to Trim and Keep Plugin.

          I didn't try that specifically, but I did try using Definition.entities.clear! and got some odd behavior and a BugSplat.

          Now, I'm not sure deleting the component is the "right" thing to do - I like the idea of leaving the Definition in model in case it is needed. The user can erase/purge it if and when they want.

          Hi

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

            The definition.entities.clear! should work much as my suggestion, inside the operation block?
            You could always suffix its new name with "[Untrimmed]" so it's easy to spot?
            You could also add a closing dialog
            'Remove the now Unused Untrimmed Definition from the Browser ?', Yes|No
            Then the user decides...
            πŸ˜•

            I have just written something very similar myself, within a broader 'commercial' tool, BUT that auto-removes the old untrimmed definition. That one gets complicated as it is say a panel component that is trimmed on one edge using special shaped instances [it's remade as a component rather than a group], a 'hidden' proxy of the original untrimmed panel is retained after the trimming is done, it is also given attributes defining what was done on that trim; then you can trim the 2nd, 3rd, 4th edges etc, each time the attributes are expanded for each edge trimmed; now the rub - the edge trimming is editable per edge, so if I want to redo the trimming to the 2nd edge I have to start with an untrimmed version again [derived from the proxy] then read the attributes that it has and repeat the 1st then the new 2nd trim and then repeat the 3rd, 4th etc. This is because trimming one edge affects the abutting other two edges... I have taken a while to get my head around it! Now you can trim parts out of all sides of the panel using various shaped 'notches' and edit them too... Now to finish the next part - these trimmed edges marry into panels meeting at right-angles and their 'notched' edges have to be the reverse of the other panels... A tangle of attribute crosschecks and a trimming frenzy ensues... πŸ˜’

            TIG

            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