See the top rated post in this thread. Click here

Results 1 to 6 of 6

Thread: removing items from list

  1. #1
    Member
    Join Date
    2012-03
    Posts
    4
    0 Did you find this post helpful? Yes

    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
    Programming Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    3,543
    0 Did you find this post helpful? Yes

    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)
    "Potential has a shelf life." - Margaret Atwood

    Autodesk Exchange Apps
    ~ Autoloader ~ AutoCAD Security

  3. #3
    Member
    Join Date
    2012-03
    Posts
    4
    1 Did you find this post helpful? Yes

    Default Re: removing items from list

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

  4. #4
    Programming Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    3,543
    0 Did you find this post helpful? Yes

    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.
    "Potential has a shelf life." - Margaret Atwood

    Autodesk Exchange Apps
    ~ Autoloader ~ AutoCAD Security

  5. #5
    Programming Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    3,543
    0 Did you find this post helpful? Yes

    Default Re: removing items from list

    I've added _GetLayers (alternative) to my previous post.
    "Potential has a shelf life." - Margaret Atwood

    Autodesk Exchange Apps
    ~ Autoloader ~ AutoCAD Security

  6. #6
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2007-07
    Location
    Jo'burg SA
    Posts
    4,493
    0 Did you find this post helpful? Yes

    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")))
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

Similar Threads

  1. Old Wish List Items
    By iankids in forum Revit Architecture - General
    Replies: 4
    Last Post: 2008-12-08, 07:52 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-28, 11:57 PM
  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
  •