highrez2 Posted March 21, 2013 Share Posted March 21, 2013 (edited) I am trying to move specific block names to specific layers. I can get the block and change it, but it only works in the current tab. How do I select all instances of the block name, to change it to a specific layer? Here is a copy of what I have so far: ;;move block name to layer 0 (prompt "\nType BTL to move blocks to layer specific layers") (defun C:BTL () (setq Blks (ssget "_x" '((0 . "INSERT")(2 . "TB_8x11")))) (command ".chprop" "p" "" "la" "0" "") (princ) ) Edited September 4, 2014 by highrez2 add code quote Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 21, 2013 Share Posted March 21, 2013 Below is my response to the email you sent me, copied here for the benefit of the forum community: Command expressions (such as your call to the chprop command) will only accept objects in the active space; consequently, to modify objects in all spaces (both modelspace and all paperspace layouts), you will need to iterate over all entities in the selection set and modify the DXF groups for each entity. Here is a simple example for you to study: (defun c:btl ( / e i s ) (if (setq s (ssget "_X" '((0 . "INSERT") (2 . "TB_8x11")))) (repeat (setq i (sslength s)) (setq e (entget (ssname s (setq i (1- i))))) (entmod (subst '(8 . "0") (assoc 8 e) e)) ) ) (princ) ) The above will perform successfully with all standard block references with name equal to TB_8x11; if such block is dynamic, some references may not be processed since dynamic block references become anonymous when dynamic properties are modified following insertion. Note also that the above program allows for a null selection set. Here is a DXF Reference to show how the various DXF group codes correspond to entity properties. In future please refrain from emailing me directly if your question is already posted in the forum. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted March 22, 2013 Share Posted March 22, 2013 highrez2, Please read the CODE POSTING GUIDELINES and edit your post to include your code in Code Tags. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.