Hi Z9E3zK5E,
I just wanted to thank you for your original code snippet posted somewhere else for the -REFEDIT version. I added the additional in-ref-edit check to that.
Here was the code before I saw your post on this thread, inspired me to make some changes:
;; REFEDIT Macros
;; The "first"? time this macro is run, has to be through the dialog to specify locking of unrelated objects.
;; Possible that the user won't know this, lol.
(defun C:QE () ;Quick Block Edit
;gonna try and nest in a refclose + save if already in refedit mode
(if (/= (getvar 'refeditname) "")
(vl-cmdf "_.Refclose" "S")
;else
(if *refedit1st
(command "_.-REFEDIT" "_Ok" "_All" "_No")
(progn
(setq *refedit1st T)
(initdia)
(command "_.REFEDIT"))
)
);if
(princ)
)
Context for the above additions, in case you might not remember: Using -refedit through the commandline doesn't allow the option to lock unrelated entities, so you added additional code to ensure the user steps through the usual refedit for the first time. I noticed that *refedit1st is set to true regardless of whether the user followed through with a successful refedit(by pressing ok instead of cancelling), so I have edited the set-true flag to occur only after the lisp checks and finds itself within a refedit. This would prevent user error unless the user deliberately unchecks the lock objects in the dialog box. I have no idea how to check for that, so that's the best I can get it to work.
Also, I see your new code has a new check for the implied selection, great idea to deal with the lisp not recognising a pre-selected block.
Here's the new version which I have adapted:
;; REFEDIT Macros
;; The "first"? time this macro is run, has to be through the dialog to specify locking of unrelated objects.
;; Possible that the user won't know this, lol.
(defun C:QE () ;Quick Block Edit
;gonna try and nest in a refclose + save if already in refedit mode
(if (/= (getvar 'refeditname) "")
(vl-cmdf "_.Refclose" "S")
;else
(if *refedit1st
(progn
(if (ssget "_I")
(command "_.-REFEDIT" "_Ok" "_All" "_No")
(command "_.-REFEDIT" pause "_Ok" "_All" "_No"))
);progn
(progn
(initdia)
(command "_.REFEDIT")
(if (/= (getvar 'refeditname) "") (setq *refedit1st T))
);progn
);if
);if
(princ)
)
Thanks for your help.