Jump to content

Blocks to set layers


highrez2

Recommended Posts

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 by highrez2
add code quote
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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