SELECT EACH BLOCK ONE BY ONE FROM ENTIRE DRAWING

SELECT EACH BLOCK ONE BY ONE FROM ENTIRE DRAWING

Anonymous
Not applicable
2,221 Views
10 Replies
Message 1 of 11

SELECT EACH BLOCK ONE BY ONE FROM ENTIRE DRAWING

Anonymous
Not applicable

Good Day..

 

New to forum here,

Looking for help in Lisp Coding to select Each Block , one by one from entire Drawing (means select first Block  then next Block ) like that. 

 

Your help in this highly appreciated.

Regards

  

0 Likes
Accepted solutions (2)
2,222 Views
10 Replies
Replies (10)
Message 2 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Have fun!

 

(defun c:BlocksZoomOnebyOne ( / ss ent i)

  (if (setq ss (ssget "_X" '((0 . "INSERT") (410 . "Model"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (command "_.ZOOM" "_Object" ent "")
      (getkword "\nZoom <next block>: ")))
  (princ)
)
Message 3 of 11

Anonymous
Not applicable

Hi,

Good Morning

 

Your help in this highly appreciated. but Looking for help in Lisp Coding to select Each Block ,one by one from entire Drawing (means select first Block  then next Block ) like that.  i attach image for your kind information and reference. 

your given code is for zooming the object one by one and next actually i need selecting each Block one by one and next 

(command "_.ZOOM" "_Object" ent "")

 

Thank you once again. 

 

Your help in this highly appreciated.

Regards

 

0 Likes
Message 4 of 11

ВeekeeCZ
Consultant
Consultant
Accepted solution

Add this line, perhaps behind the zoom, or instead? Try and see...

 

(command "_.PSELECT" ent "")
Message 5 of 11

Anonymous
Not applicable

Hi,

 

Good Day Sir,

Looking for help in Lisp Coding to select Each Block (Automatic), one by one from entire Drawing .

 

Before i use this code , select block By Block Name  and Block Layer Name as Follows.

 

 (sssetfirst nil (ssget "_X" '((0 . "INSERT")(2 . "`*U27"))))-SELECT BLOCK by Block Name

 

(sssetfirst nil (ssget "_X" '((0 . "INSERT")(8 . "Left View-SUPPORTS"))))-SELECT BLOCK by Block Layer Name

 

but write now i wanted to select Each Block (Automatic), one by one from entire Drawing, but for this operation how i perform ? or which code i follow please guide me .

 

Your help in this highly appreciated.

Regards

 

 

 

 

 

0 Likes
Message 6 of 11

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

…. i wanted to select Each Block (Automatic), one by one from entire Drawing ....


And do what  with them?  Should it let you do something with each before automatically going on to the next?  Should selecting the next one un-select the previous one?  Or add it to a growing selection?  If each one is added, and automatically, why do it one by one, rather than just getting a selection of all Blocks at once?

 

I would like more explanation of the purpose.

Kent Cooper, AIA
0 Likes
Message 7 of 11

Anonymous
Not applicable

Thanks for your kind reply.

We are looking for a code to give a block names for piping support. We could do this pro-grammatically for one support when the block name was given. I am looking implement the same for entire drawing. The sample output is shown in attachment. Your support is highly appreciated.

 

Regards

 

0 Likes
Message 8 of 11

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

Hi,

 

Good Day Sir,

Looking for help in Lisp Coding to select Each Block (Automatic), one by one from entire Drawing .

 

Before i use this code , select block By Block Name  and Block Layer Name as Follows.

 

 (sssetfirst nil (ssget "_X" '((0 . "INSERT")(2 . "`*U27"))))-SELECT BLOCK by Block Name

 

(sssetfirst nil (ssget "_X" '((0 . "INSERT")(8 . "Left View-SUPPORTS"))))-SELECT BLOCK by Block Layer Name

 

but write now i wanted to select Each Block (Automatic), one by one from entire Drawing, but for this operation how i perform ? or which code i follow please guide me .

 

Your help in this highly appreciated.

Regards

 


Well, trying to understand you... 

I guess your fixed to some idea how to preform the job, but the thing does not work like that.

You need to select some group (selection set) of entities (blocks in your case) by some criteria (name?, same attribute?). Once you have it, you need use some systematic way to deal with one block after another (going thrue the selection set). So in my example I've used the REPEAT loop, and saved the ename of each block (one by one) into the ent variable. 

So what you have and what you need? Your screen shot is confusing. You marked some TAG and its value. Is that what you need to export? Or it is a block name, as you describe...: "We are looking for a code to give a block names for piping support. "

 

Please would you describe the whole process simple points? Like

- selecting all block by name *U27

- go thrue selection set, get and export the value of "Tag"

- export where, to the command line? 

0 Likes
Message 9 of 11

Anonymous
Not applicable

Thanks for your quick reply,

 

This code is intended use in autocad, the file generated by plant 3d, in this all the blocks are unique (Only one item with same block name ). This is for pipe support which has unique number. This is a not a block name its a tag name. I have attached a property of the block for ready reference.

 

Sorry for confusing with block name. I need to show tag name of the support of piping.

We are not intending any export the data, we are looking at write the tag name  near to the support possibly with leaderline and textframe as shown in the attachment.

 

The problem looks like half sloved with this code

(defun c:BNBLBC (/ en ss ctr bl the_list n)
(setq ss (ssget "X" (list (cons 0 "INSERT")))
ctr (sslength ss)
)
(repeat ctr
(setq ctr (1- ctr)
en (entget (ssname ss ctr))
bl (strcat (cdr (assoc 2 en)))
)
(if (setq count (cdr (assoc bl the_list)))
(setq the_list (subst (cons bl (1+ count))(cons bl count) the_list))
(setq the_list (cons (cons bl 1) the_list))
)
)
(setq the_list (vl-sort the_list '(lambda (e1 e2)(< (car e1) (car e2)))))
(foreach n the_list
tt (strcat "'" (car n) )
;(sssetfirst nil (ssget "_X" '((0 . "INSERT")(2 . tt))))
(sssetfirst nil (ssget "_X" '((0 . "INSERT")(2 . "`*U27"))))
(command "lnsert" p1 p2 "")
(setq TXTHT 3.5) ;;set plotted text height
(setq TXTHT (* TXTHT (getvar "dimscale"))) ;;adjust height per dimscale
(command ".STYLE" "romans" "" "0" ".75" "0" "N" "N" "N"
".TEXT" "J" "C" PT TXTHT ".125" NN)

)
)

 

above code gives error at"Insert "


@ВeekeeCZ wrote:

@Anonymous wrote:

Hi,

 

Good Day Sir,

Looking for help in Lisp Coding to select Each Block (Automatic), one by one from entire Drawing .

 

Before i use this code , select block By Block Name  and Block Layer Name as Follows.

 

 (sssetfirst nil (ssget "_X" '((0 . "INSERT")(2 . "`*U27"))))-SELECT BLOCK by Block Name

 

(sssetfirst nil (ssget "_X" '((0 . "INSERT")(8 . "Left View-SUPPORTS"))))-SELECT BLOCK by Block Layer Name

 

but write now i wanted to select Each Block (Automatic), one by one from entire Drawing, but for this operation how i perform ? or which code i follow please guide me .

 

Your help in this highly appreciated.

Regards

 


Well, trying to understand you... 

I guess your fixed to some idea how to preform the job, but the thing does not work like that.

You need to select some group (selection set) of entities (blocks in your case) by some criteria (name?, same attribute?). Once you have it, you need use some systematic way to deal with one block after another (going thrue the selection set). So in my example I've used the REPEAT loop, and saved the ename of each block (one by one) into the ent variable. 

So what you have and what you need? Your screen shot is confusing. You marked some TAG and its value. Is that what you need to export? Or it is a block name, as you describe...: "We are looking for a code to give a block names for piping support. "

 

Please would you describe the whole process simple points? Like

- selecting all block by name *U27

- go thrue selection set, get and export the value of "Tag"

- export where, to the command line? 


 

Thanks 

 

0 Likes
Message 10 of 11

ВeekeeCZ
Consultant
Consultant

Post that drawing as a dwg, state before and after.

 

BTW If I link you some good sample would you try to do that by yourself for learning purpose? - Look HERE, the issue is very similar. Selection by block names, sorting by attributes... also HERE is very good Lee Mac's side with sub-routines for working with attributes.

Not sure how experienced "lisper" you are. 

0 Likes
Message 11 of 11

Anonymous
Not applicable

Thanks for the reply , i am not expert in lisping and beginner in Lisp Coding.

Will study the link sent and update if any help required.

 

Thanks

 

 

0 Likes