Results 1 to 6 of 6

Thread: Help with Image layer lisp

  1. #1
    topomav
    Guest
    Login to Give a bone
    0

    Default Help with Image layer lisp

    Hi, I am using this code to move all images from model and paper space to the layer Image.
    I want to update this code to move all images from model space to layer Image_Model and all images from paper space to layer Image _Lay.

    Can any one help me?

    HTML Code:
    (vl-load-com)
    
    (defun c:LinkLayerImage (/ *error* acDoc layerName oLayer ss)
    
      (defun *error* (msg)
        (if ss
          (vla-delete ss)
        )
        (if acDoc
          (progn
            (vla-endundomark acDoc)
            (vla-regen acDoc acallviewports)
          )
        )
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (if (ssget "_X" '((0 . "IMAGE") (8 . "~Image")))
        (progn
          (vla-startundomark
            (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
          )
    
          ;; get or create layer
          (setq oLayer
                 (vla-add (vla-get-layers acDoc) (setq layerName "Image"))
          )
    
          ;; set image layer
          (vlax-for x (setq ss (vla-get-activeselectionset acDoc))
            (vla-put-layer x layerName)
          )
    
          ;(setvar 'clayer "Line1")
        )
    )
    ;(alert "image done")
      (*error* nil)
    )

    Thanks

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,655
    Login to Give a bone
    0

    Default Re: Help with Image layer lisp

    Add a filter to determine the Layer name based on if group code 67 equals 1. https://help.autodesk.com/view/ACD/2...3-7E60B22BB5BD
    Group code 67 - Absent or zero indicates entity is in model space. 1 indicates entity is in paper space (optional).

  3. #3
    topomav
    Guest
    Login to Give a bone
    0

    Default Re: Help with Image layer lisp

    Hi, Tom Beauford. Can you help with the code because I am not good in lisp.

    Thanks

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Help with Image layer lisp

    I did not test the following routine so please try it and let me know and be sure to have your layers unlocked in prior otherwise if any on locked layer then it won't be moved to the target layer name and besides that, if you don't have the two target layers then the program will add them with default values like White color ..... etc.
    Code:
    (vl-load-com)
    (defun c:LinkLayerImage (/ *error* acDoc s i n e mod lay)
      (defun *error* (msg)
        (if acDoc
          (progn
            (vla-endundomark acDoc)
            (vla-regen acDoc acallviewports)
          )
        )
        (cond ((not msg))                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))
                                            ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))
                                            ; Fatal error, display it
        )
        (princ)
      )
    
      (if (setq s (ssget "_X" '((0 . "IMAGE") (8 . "~Image"))))
        (progn
          (vla-startundomark
            (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
          )
          (vla-add (vla-get-layers acDoc) (setq mod "Image_Model"))
          (vla-add (vla-get-layers acDoc) (setq lay "Image_Lay"))
    
          (repeat (setq i (sslength s))
            (setq i (1- i)
                  n (ssname s i)
                  e (entget n)
            )
            (entmod (subst (cons 8
                                 (if (= (cdr (assoc 67 e)) 1)
                                   mod
                                   lay
                                 )
                           )
                           (assoc 8 e)
                           e
                    )
            )
          )
        )
      )
      (*error* nil)
      (princ)
    )

  5. #5
    topomav
    Guest
    Login to Give a bone
    0

    Default Re: Help with Image layer lisp

    Thank you Tharwat

  6. #6
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Help with Image layer lisp

    Quote Originally Posted by Razor View Post
    Thank you Tharwat
    You're welcome anytime.

Similar Threads

  1. Combine query lisp with layer draw order lisp?
    By wayne.murphy704398 in forum AutoLISP
    Replies: 1
    Last Post: 2020-11-06, 03:08 AM
  2. 2015: Insert image, unload image, image border stays around
    By invaderkyle in forum AutoCAD General
    Replies: 4
    Last Post: 2015-04-10, 03:23 PM
  3. LISP to create layer, hatch and set layer back to original.
    By jpcadconsulting347236 in forum AutoLISP
    Replies: 1
    Last Post: 2013-12-11, 07:22 PM
  4. Replies: 13
    Last Post: 2011-06-28, 03:31 PM
  5. layer control: lisp vs layer manager
    By gseals in forum AutoCAD Customization
    Replies: 2
    Last Post: 2004-10-08, 02:36 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
  •