sketch11 Posted Friday at 03:37 PM Posted Friday at 03:37 PM (edited) Was looking for something to rename blocks, and have found Lee Mac's code robust since it can handle dynamic blocks, and renames only the particular block selected, so it has a unique name. https://www.lee-mac.com/copyblock.html How can code be adjusted for the following. 1. Select block first, then run code (will right click to select command which runs code). At the moment code is called up, then block is selected. 2. When block name is changed, it will be at the end of the string, based on existing name. Tried to press End on keyboard to get to the end of the name but this won't work, the arrow keys do work but it starts from the beginning. See below. Edited Friday at 03:38 PM by sketch11 Quote
mhupp Posted Friday at 04:45 PM Posted Friday at 04:45 PM (edited) 1 hour ago, sketch11 said: How can code be adjusted for the following. Lee's code is above my pay grade. He has CB and RB broken out already maybe ask him nicely to add a feature. RBP - rename block with prefix RBS - rename block with Suffix -edit I think I have code that will do this for regular blocks or maybe it was for text. its been awhile. Edited Friday at 04:51 PM by mhupp 1 Quote
sketch11 Posted yesterday at 06:31 AM Author Posted yesterday at 06:31 AM Ok thanks mhupp. Do you know of a web page which has instructions on how to write LISP code after an object is selected. Quote
mhupp Posted 21 hours ago Posted 21 hours ago only tested this on regular blocks. if you use prefix on anonymous blocks they might not be anonymous anymore. I don't know what would happen so test it first before using it on project files. @Lee Mac let me know if you want this taken down. probably do it Monday anyway. Rename.lsp Quote
BIGAL Posted 15 hours ago Posted 15 hours ago Maybe (setq ss (ssget "I")) just select objects 1st then run in a lisp. A google revealed.. Quote
sketch11 Posted 8 hours ago Author Posted 8 hours ago Thanks mhupp, but I didn't want to add prefix or suffix, actually preferred to leave name unchanged, just wanted to press End on keyboard to get to the end of the string. Quote
Steven P Posted 2 hours ago Posted 2 hours ago (edited) On 1/9/2026 at 3:37 PM, sketch11 said: 2. When block name is changed, it will be at the end of the string, based on existing name. Tried to press End on keyboard to get to the end of the name but this won't work, the arrow keys do work but it starts from the beginning. See below. Not so sure you can do 'end' with the keyboard with the standard (getstring) functions - either live with it or perhaps a DCL pop up might let you do this. Should be able to amend Lees Code to insert a dialogue if it really is necessary. Change this line to call another function with the code needed, return value will be the string that (setq new is looking for: (setq new (strcat (getstring t (strcat "\nPrefix For Block <" def ">: ")) " " old))) Edited 2 hours ago by Steven P Quote
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.