×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Lisp-Adding to a Selection Set

Lisp-Adding to a Selection Set

Lisp-Adding to a Selection Set

(OP)
I'd like to take the LayerIsolate lisp routine from the Express Tools and modify it. We use 4 layers for one component, we call them layer groups. So for the component 1, the 4 actual layers needed to show the part are: layer 1s is solid lines only, layer 1c is centerlines only, layer 1h is hidden lines only, and layer 1p is phantom lines only. I would like to control the visibility of each group all together.

So what I want is a LayerIsolateGroup routine that will look at the selected items, and keep those layers on as well as the ?s, ?c, ?h, and ?p layers for each selection.

Here's the code to get the graphical selections:

CODE

  (if (not (setq SS (ssget "_i")))
    (progn
      (prompt "\nSelect object(s) on the layer(s) to be isolated: ")
      (setq SS (ssget))
    )
  )
  
  
  (if SS
    (progn
  
      (setq CNT 0)
  
      (while (and ss
                  (> (sslength ss) 0)
                  (setq LAY (ssname SS CNT))
             );and
        (setq LAY (cdr (assoc 8 (entget LAY))))
        (if (not (member LAY LAYLST))
          (setq LAYLST (cons LAY LAYLST))
        )
        (setq CNT (1+ CNT))
      )

Any idea how to add the additional layer names to LAYLST (or maybe LAY...I'm not really sure but I think LAYLST)? I think that is what I want to do because later in the code are these 3 lines:

CODE

          (command "_.-LAYER" "_OFF" "*" "_Y")
          (foreach VAL LAYLST (command "_ON" VAL))
          (command "")

I've also found this to check whether a layer exists (NEWLAYER in this example):
(setq flag (tblsearch "LAYER" "NEWLAYER"))

And this for the string length:
strlen

Thanks,
Ken

RE: Lisp-Adding to a Selection Set

Heres the VLISP way to cycle through all the layers. This example shows how to unlock all of the layers but you can apply a test to the layer names and then apply the property you want the layers to have (eg be ON and THAWED). IHTH.

(setq *acad-object* nil)      ; Initialize global variable
(setq *active-document* nil)  ; Initialize global variable
(defun pp_GetActiveDocument ()
  (cond (*active-document*)   ; Return the cached object
    (T
      (setq *active-document* (vla-Get-ActiveDocument (pp_GetAcadObject)))
    )
  )
)
(defun pp_GetAcadObject ()
  (cond (*acad-object*)       ; Return the cached object
    (T
      (setq *acad-object* (vlax-Get-Acad-Object))
    )
  )
)
(defun pp_UnlockAllLayers (/ EA_LYR)
  (vl-catch-all-error-p
    (vlax-for EA_LYR (vla-get-Layers (pp_GetActiveDocument))      
      (vla-put-lock EA_LYR :vlax-false)
      )
    )
  )

http://mechcad-insider.blogspot.com/
 
"The fear of the Lord is the beginning of wisdom"

RE: Lisp-Adding to a Selection Set

Add this to your Acad.lsp file, then type L1 to make it work.

(Defun C:L1 ()
 (Command("Layer" "Freeze" "*" "Thaw" "1*")
 (princ)
)

RE: Lisp-Adding to a Selection Set

(OP)
Thanks for the reply's. I've gotten something kludged together that mostly works, but I'll look more into what you've shown me and see if I can get this thing completely working for me.

Thanks,
Ken

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources