Jump to content

Moving all objects from old layer to new layer over entire drawing


Recommended Posts

Posted (edited)

is there a way to update the attached lisp so that you can select and enter new layer names without the underscore between each piece of text.

 

Layers within the drawing are current labeled similar to POD Building Pads. 

 

When I attempt to nominate the layer it doesn't accept the space within the text and steps to make new layer within the lisp.  I would like to retain the current layer naming convention as this is what is used within company.

 

 

(defun c:MoveLayerAllLayouts ( / oldLayer newLayer ss)
  ;; Prompt for source layer
  (setq oldLayer (getstring "\nEnter the name of the layer to move FROM: "))
  ;; Prompt for target layer
  (setq newLayer (getstring "\nEnter the name of the layer to move TO: "))

  ;; Ensure target layer exists, create if not
  (if (not (tblsearch "layer" newLayer))
    (command "_.LAYER" "_Make" newLayer "")
  )

  ;; Select all objects in the drawing (model + layouts) on the old layer
  (setq ss (ssget "X" (list (cons 8 oldLayer))))

  (if ss
    (progn
      ;; Change layer of all selected objects
      (command "_.CHPROP" ss "" "_LA" newLayer "")
      (princ (strcat "\nMoved all objects from layer \"" oldLayer "\" to \"" newLayer "\"."))
    )
    (princ (strcat "\nNo objects found on layer \"" oldLayer "\"."))
  )
  (princ)
)

 

Edited by andyb57J
  • andyb57J changed the title to Moving all objects from old layer to new layer over entire drawing
Posted
  (setq oldLayer (getstring T "\nEnter the name of the layer to move FROM: "))
  ;; Prompt for target layer
  (setq newLayer (getstring T "\nEnter the name of the layer to move TO: "))

 

  • Like 1
Posted

thankyou.  

Posted (edited)

notice your lisp name is MoveLayerAllLayouts that mean other tabs other than model? ssget "_X" wont pick up things on other tabs if they are on that layer.

So if your moving everything might assume your deleting the old layer. if that's the case just rename it. no need to mess with ssget and will pick up everything.

 

(vl-cmdf "_.-Rename" "LA" old new)

 

Edited by mhupp
  • Agree 2

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...