Russian Doll Blocks... Go back to parent block after exiting child block

Russian Doll Blocks... Go back to parent block after exiting child block

alx86
Enthusiast Enthusiast
1,321 Views
6 Replies
Message 1 of 7

Russian Doll Blocks... Go back to parent block after exiting child block

alx86
Enthusiast
Enthusiast

Hi,
I frequently have to work with block which are into a block, which is also into a block and so on... So lets say I'm in the 7th block and after editing it, I want to go back to editing the previous (parent block) without going back to model space, then edit the 1st block, to enter the second block, to then enter the third block etc. until I'm back at the 6th block.

Is there a command for that? Or do I need a lisp, macro or something? If so, can someone help me with the code?


001.png

Thanks a lot in advance for any help.

0 Likes
Accepted solutions (1)
1,322 Views
6 Replies
Replies (6)
Message 2 of 7

Libbya
Mentor
Mentor

No, as far as I know there is not any command to do what you are asking.  Bear in mind that you might have nested a block within another block, but when you are within block editor and editing the block definition of a block that happens to be a nested block within another block definition, you are not in a version of block editor that is within another version of block editor...  You are just in block editor, editing a block definition.  Exiting block editor will take you to model space unless you open a different block definition from within block editor.  

 

You can, of course, use "BEDIT" command and select a different block from within the list of blocks in the current drawing.  CAD won't remember the name for you, though. 

 

If you want help with custom code, you should post that on one of the Customization forums that deal with code.   

0 Likes
Message 3 of 7

alx86
Enthusiast
Enthusiast

Hi Libbya,

I know it's not a block editor within a block editor etc. and that I'm in the block editor editing a block definition. Actually, to be clearer, what I would want is probably a Lisp that when used, will close block editor, then will look at the name of previously edited block definition then open back this block definition... Or something like that.. I understand how block editor work, but i thought that maybe there something like an History of block definition name that as been used, that a command or lisp could use to automatically open the previous block definition.

0 Likes
Message 4 of 7

Libbya
Mentor
Mentor

There may a way to store the prior block definition and open that with a custom command (I imagine that is likely possible), but I do not know of any way within stock AutoCAD.  Someone on one of the coding forums might know how to do so.  

0 Likes
Message 5 of 7

Libbya
Mentor
Mentor

Also, if you do find a workable solution, please post back with the details.  I rarely deal with nested blocks, much less ones that are two levels deep, but I can see how such a solution would occasionally be useful.  

Message 6 of 7

vinodkl
Mentor
Mentor

Why not use REFEDIT(Reference edit) to edit the nested child block without entering into the parent block, as in BEDIT(block editor) ?

Condition applies, if its not a dynamic block. As I could see the from the snapshot it doesn't seem to be a dynamic block.

 

--------------------------------------------------------------------------------------------------------------------------
ವಿನೋದ್ ಕೆ ಎಲ್( System Design Engineer)
Likes is much appreciated if the information I have shared is helpful to you and/or others.

Please mark "Accept as Solution" if my reply resolves the issue or answers your question, to help others in the community.
--------------------------------------------------------------------------------------------------------------------------
0 Likes
Message 7 of 7

Anonymous
Not applicable
Accepted solution

OK,

this is the first LISP i do from zero.

I'm sure there is a lot to improve and there is bugs that i already know about.

Please let me know if you see anything to fix/improve.

 

;;by Pinet Antoine the 01-Mar-20

; use it to enter inside each block 
(defun c:inside	(/ test)
  (setq test 1)
  (setq
    bname (vla-get-effectivename
	    (vlax-ename->vla-object (car (entsel "\nSelect block: ")))
	  )
  )
  (setq listebloc (cons bname listebloc))
  (command "_-bedit" "" bname "")
  (while
    (cond
      ((> index 0)
       (setq listebloc (RemNth-R 1 listebloc))
	 (setq index (- index 1)))
       (t (princ nil))
      )
    )
  (setq index 0)
)

; use it to display the 10nth first block 
(defun c:sayliste ()
  (print (nth 0 listebloc))
  (print (nth 1 listebloc))
  (print (nth 2 listebloc))
  (print (nth 3 listebloc))
  (print (nth 4 listebloc))
  (print (nth 5 listebloc))
  (print (nth 6 listebloc))
  (print (nth 7 listebloc))
  (print (nth 8 listebloc))
  (print (nth 9 listebloc))
)

; use i to come back to the previous block
(defun c:previous ()
  (setq index (+ index 1))
  (command "_bsave")
  (command "_-bedit" (nth index listebloc) "")
)

; use it to go in the next block (after a "previous")
(defun c:next ()
  (setq index (- index 1))
  (command "_bsave")
  (command "_-bedit" (nth index listebloc) "")
)

(defun RemNth-R	(n lst /)
  ;;by irneb found in www.cadtutor.net/forum/topic/37995-remove-element-from-list/
  (if (> n 0)
    (cons (car lst) (RemNth-R (1- n) (cdr lst)))
    (cdr lst)
  )
)

 

I tried to use an active selection set if there was one but didn't succeed.