Jump to content

Recommended Posts

Posted

I really enjoy using Lee's Layer Director lisp, (thanks Lee :beer:)

 

and it occurs to me that it could easily be (were it not for my illisperacy) tweaked to create the unique layer I need for each Xref, triggered by the XATTACH command. The command reactor is already in place. Each XREF needs to be attached on a new layer which is an exact copy of the 0 Layer, and named Xref *, of course the wildcard name will be extracted from the entity being attached, which I don't yet know how to do?

 

Suggestions/solutions greatly appreciated.

  • 3 years later...
Posted

Hi Lee,

I am using this old post for a tweak on layerdirector and i have a wish. too

When my settings are set that the layers is 'not visible in toolbar' the layerdirector routine will place the object in the current layer. It fails to reasign the layer

 

Can the tool be modified that it allways finds the good layer, even if this is 'not listed'?

Thanks in advance

 

 

Hans

Knipsel.jpg

Posted
Suggestions/solutions greatly appreciated.

 

How about this code by Alan J. Thompson (alanjt):

 

;;; ------------------------------------------------------------------------
;;;	XRefsToLayers.lsp v1.0
;;;
;;;	Copyright© 04.27.10
;;;	Alan J. Thompson (alanjt)
;;;
;;;	Contact: alanjt @ TheSwamp.org, CADTutor.net
;;;
;;;	Permission to use, copy, modify, and distribute this software
;;;	for any purpose and without fee is hereby granted, provided
;;;	that the above copyright notice appears in all copies and
;;;	that both that copyright notice and the limited warranty and
;;;	restricted rights notice below appear in all supporting
;;;	documentation.
;;;
;;;	The following program(s) are provided "as is" and with all faults.
;;;	Alan J. Thompson DOES NOT warrant that the operation of the program(s)
;;;	will be uninterrupted and/or error free.
;;;
;;;	Allows user to moved all XRefs to layer, based on XRef name with
;;;	prefix of "G-XREF_".
;;;	User also has option to lock created XRef layers.
;;;
;;;	Revision History:
;;;
;;; ------------------------------------------------------------------------



(defun c:XR2L (/) (c:XRefsToLayers))
(defun c:XRefsToLayers (/ *error* Prefix4Layer xrefLst ss flag lock layLst lst)

 ;; Prefix4Layer (if no prefix wanted, set as "")
 (setq Prefix4Layer "G-XREF_")


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SUBROUTINES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 ;; error handler
 (defun *error* (msg)
   (and flag *AcadDoc* (vla-EndUndoMark *AcadDoc*))
   (and msg
        (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*"))
        (princ (strcat "\nError: " msg))
   )
 )



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; MAIN ROUTINE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (vl-load-com)

 (if (eq ""
         (setq xrefLst
                ((lambda (s)
                   (vlax-for x (vla-get-blocks
                                 (cond (*AcadDoc*)
                                       ((setq *AcadDoc* (vla-get-ActiveDocument (vlax-get-acad-object))))
                                 )
                               )
                     (and (eq (vla-get-isXRef x) :vlax-true) (not (wcmatch (vla-get-name x) "*TBLOCK*")) (setq s (strcat s (vla-get-name x) ",")))
                   )
                   s
                 )
                  ""
                )
         )
     )
   (alert "Zero XRefs in drawing.")
   (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 xrefLst))))
     ((lambda (pre layers)
        (initget 0 "Yes No")
        (setq lock "No")
        (setq flag (not (vla-StartUndoMark *AcadDoc*)))
        (vlax-for o (setq ss (vla-get-ActiveSelectionSet *AcadDoc*))
          ((lambda (layer)
             (or (vl-position layer layLst) (setq layLst (cons layer layLst)))
             (setq lst ((lambda (lst)
                          ((lambda (ass)
                             (if ass
                               (subst (cons (car ass) (1+ (cdr ass))) ass lst)
                               (cons (cons layer 1) lst)
                             )
                           )
                            (assoc layer lst)
                          )
                        )
                         lst
                       )
             )
             (or (eq (vla-get-layer o) (strcat pre (vla-get-name o)))
                 (if (vl-catch-all-error-p
                       (vl-catch-all-apply
                         (function vla-put-layer)
                         (list o layer)
                       )
                     )
                   ((lambda (item)
                      (vla-put-lock item :vlax-false)
                      (vla-put-layer o layer)
                      (vla-put-lock item :vlax-true)
                    )
                     (vla-item layers (vla-get-layer o))
                   )

                 )
             )
           )
            (if (vl-position (strcat pre (vla-get-name o)) layLst)
              (strcat pre (vla-get-name o))
              (vla-get-name (vla-add layers (strcase (strcat pre (vla-get-name o)))))
            )
          )
        )
        (vla-delete ss)
        (and
          layLst
          (or (eq lock "No")
              (mapcar (function (lambda (l) (vla-put-lock (vla-item layers l) :vlax-true))) layLst)
          )
;;;           lst
;;;           (foreach i (vl-sort lst (function (lambda (a b) (< (car a) (car b)))))
;;;             (princ (strcat "\n" (itoa (cdr i)) " XRef(s) on layer: \"" (car i) "\""))
;;;           )
          (setq lst ((lambda (lst str)
                       (if lst
                         (progn
                           (foreach i (vl-sort lst
                                               (function (lambda (a b)
                                                           (< (car a) (car b))
                                                         )
                                               )
                                      )
                             (setq str (strcat str
                                               "\n"
                                               (itoa (cdr i))
                                               " XRef(s) on layer: \""
                                               (car i)
                                               "\""
                                       )
                             )
                           )
                           str
                         )
                       )
                     )
                      lst
                      ""
                    )
          )
          (alert lst)

        )
      )
       Prefix4Layer
       (vla-get-Layers *AcadDoc*)
     )
   )
 )
 (*error* nil)
 (princ)
)
(c:XR2L)

Posted
I really enjoy using Lee's Layer Director lisp, (thanks Lee :beer:)

 

and it occurs to me that it could easily be (were it not for my illisperacy) tweaked to create the unique layer I need for each Xref, triggered by the XATTACH command. The command reactor is already in place. Each XREF needs to be attached on a new layer which is an exact copy of the 0 Layer, and named Xref *, of course the wildcard name will be extracted from the entity being attached, which I don't yet know how to do?

 

At long last, your wish has been granted (it's only taken me 4 years to get around to it!): Layer Director V1.5

 

I'm delighted that you find this program so useful!

 

Lee

Posted (edited)
At long last, your wish has been granted (it's only taken me 4 years to get around to it!): Layer Director V1.5

 

I'm delighted that you find this program so useful!

 

Lee

 

Lee as helpful as your lisps have been for me, ever since starting to use them, words cannot express my gratitude.

 

As always, thanks on an epic scale! :beer:

 

Some nice new extra functionality as well, I am sure Halam will be thrilled when he checks it out too. :)

 

For anyone who isn't using this lisp every day in their startup lisp directory, why NOT? :huh:

Edited by Dadgad
Posted

Lee

I agree with Dadgad

Great improvement.

Still i have a wish.

I noticed that the oldfashioned way (classicxref) does't work.

Personally i like avoid the screen filling xref pannel.

Can it be done?

 

 

Great work !!

Greeting from sunny Holland

 

 

Posted
Lee as helpful as your lisps have been for me, ever since starting to use them, words cannot express my gratitude.

 

As always, thanks on an epic scale! :beer:

 

Thank you Dadgad for your kind words & gratitude, I do appreciate it and I'm delighted that you find my programs so useful.

 

Lee

I agree with Dadgad

Great improvement.

Still i have a wish.

I noticed that the oldfashioned way (classicxref) does't work.

Personally i like avoid the screen filling xref pannel.

Can it be done?

 

Great work !!

Greeting from sunny Holland

 

 

Good catch Hans - I have now updated the program to V1.6 to account for the use of the CLASSICXREF command.

 

Lee

Posted
Lee as helpful as your lisps have been for me, ever since starting to use them, words cannot express my gratitude.

 

As always, thanks on an epic scale! :beer:

 

Some nice new extra functionality as well, I am sure Halam will be thrilled when he checks it out too. :)

 

For anyone who isn't using this lisp every day in their startup lisp directory, why NOT? :huh:

 

+1

 

What he said.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...