Jump to content

Help to amend this LISP


ctrlaltdel

Recommended Posts

The LISP below I googled will list the entity layer name & type including its block name & nested to what level.

 

(DEFUN C:XS ( / NLVL )
(SETQ NENT (NENTSEL))
(SETQ EN (CAR NENT))
(SETQ ENT (ENTGET EN))
(PROMPT (STRCAT "\nEntity type >>>" (CDR (ASSOC 0 ENT)) "  layer>>> " (CDR (ASSOC 8 ENT))))
(SETQ NLVL (1- (LENGTH (CADDDR NENT))))
(FOREACH EN (CADDDR NENT)
(PROGN
(SETQ ENT (ENTGET EN))
(PROMPT (STRCAT "\nBlock " (CDR (ASSOC 2 ENT))
"  [[layer]] " (CDR (ASSOC 8 ENT)) " [[nesting level]] "
(ITOA NLVL)))
(SETQ NLVL (1- NLVL))))
(PRINC))

This is shown in command line when LISP is run & Click on an enity

 

Entity type >>>LWPOLYLINE layer>>> DELETED

Block A [[layer]] 0 [[nesting level]] 3

Block B [[layer]] 0 [[nesting level]] 2

Block C [[layer]] 0 [[nesting level]] 1

Block D [[layer]] DELETED [[nesting level]] 0

Please tell me what code to change to:

1) rearrange the list- nesting level,Block name,layer name

2) Add [[]] to BLOCK

3) nesting level 0 start from the top down

 

Entity type >>>LWPOLYLINE layer>>> DELETED

[[nesting level]] 0 [[Block]] D [[layer]] DELETED

[[nesting level]] 1 [[Block]] C [[layer]] 0

[[nesting level]] 2 [[Block]] B [[layer]] 0

[[nesting level]] 3 [[Block]] A [[layer]] 0

 

Cheers

Edited by ctrlaltdel
Link to comment
Share on other sites

Instead of the PROMPT you need to do a cons so you make a list of the blocks nesting level as a text string then display the list, you can also (reverse lst) use (nth x lst) to retrieve each item.

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