See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: removing items from list

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    2012-03
    Posts
    4
    Login to Give a bone
    0

    Default removing items from list

    Hello all,
    So I have been tasked with setting up something for back fixing layers. at the end of all this I plan on using the "laytrans" command to have the user decide what layers they want transferred. A corrected template is already provided and I know what layers should exist in the drawing, but I need to provide a list of layers that don't belong. So first thought was to use this


    Code:
    (setq lay (tblnext "LAYER" T))
    (while lay
    (setq lay_lst (cons (cdr (assoc 2 lay)) lay_lst)
    lay (tblnext "LAYER")))
    to grab all my layer names. This is functioning as I expected but how do I remove the good layers from this list by their name? Thanks for the help in advance!
    Last edited by Opie; 2012-05-02 at 01:03 PM. Reason: [code] tags added

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,713
    Login to Give a bone
    0

    Default Re: removing items from list

    Perhaps these will help....

    _GetLayers:
    Code:
    (defun _GetLayers  (/ layerNames)
      ;; Example: (setq myLayerList (_GetLayers))
      (vlax-for oLayer
                (vla-get-layers
                  (vla-get-activedocument
                    (vlax-get-acad-object)))
        (setq layerNames (cons (vla-get-name oLayer) layerNames)))
      (vl-sort layerNames '<))
    _GetLayers (alternative):
    This adaptation supplies the sub-function with the ActiveDocument Object as an argument
    Code:
    (defun _GetLayers  (acDoc / layerNames)
      ;; Example:
      ;; (setq myLayerList
      ;;        (_GetLayers
      ;;          (vla-get-activedocument (vlax-get-acad-object))))
      (vlax-for oLayer  (vla-get-layers acDoc)
        (setq layerNames (cons (vla-get-name oLayer) layerNames)))
      (vl-sort layerNames '<))
    _RemItems:
    Code:
    (defun _RemItems  (removeList  sourceList / newList)
      ;; Example: (_RemItems '("B") '("A" "B" "C"))
      (setq newList sourceList)
      (foreach item  removeList
        (setq newList (vl-remove item newList)))
      newList)
    ** Note - The sub-functions above require that (vl-load-com) be loaded prior to calling.

    HTH
    Last edited by RenderMan; 2012-05-02 at 03:08 PM. Reason: Added _GetLayers (alternative)
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Member
    Join Date
    2012-03
    Posts
    4
    Login to Give a bone
    1

    Default Re: removing items from list

    You sir, are my hero for the day! Command is working perfectly!

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,713
    Login to Give a bone
    0

    Default Re: removing items from list

    Quote Originally Posted by mixted570595 View Post
    You sir, are my hero for the day! Command is working perfectly!
    That is kind of you to say; you're welcome.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,713
    Login to Give a bone
    0

    Default Re: removing items from list

    I've added _GetLayers (alternative) to my previous post.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: removing items from list

    You could also simply have tested inside the while loop if the layer name matches to another list. E.g.
    Code:
    (setq lay (tblnext "LAYER" t))
    (while lay
      (if (not (member (setq lname (cdr (assoc 2 lay))) standard_layer_names))
        (setq lay_lst (cons lname lay_lst)))
      (setq lay (tblnext "LAYER")))

Similar Threads

  1. Removing the double list pairs
    By Ehsan in forum AutoLISP
    Replies: 1
    Last Post: 2012-07-16, 03:47 PM
  2. Removing items from an install dwg
    By robert.pickeral in forum CAD Standards
    Replies: 1
    Last Post: 2008-07-03, 01:28 PM
  3. Wish List items
    By The Monk in forum Revit Architecture - Wish List
    Replies: 23
    Last Post: 2005-07-09, 03:02 AM
  4. Removing Items from a Design Option
    By pashley in forum Revit Architecture - General
    Replies: 4
    Last Post: 2005-03-29, 12:57 AM
  5. Removing duplicate strings in a list
    By whdjr in forum AutoLISP
    Replies: 7
    Last Post: 2004-06-09, 05:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •