Jump to content

lisp needed


DEEPAKRAJ

Recommended Posts

Dear tharwat

 

its some what useful.

but if we want to check one by one .

can you do the lisp which can cross check standard blocks and present block so nonstandard blocks could be highlighted.

Link to comment
Share on other sites

  • Replies 38
  • Created
  • Last Reply

Top Posters In This Topic

  • DEEPAKRAJ

    15

  • Tharwat

    11

  • BIGAL

    4

  • ReMark

    2

Top Posters In This Topic

Posted Images

Dear tharwat

 

but if we want to check one by one .

can you do the lisp which can cross check standard blocks and present block so nonstandard blocks could be highlighted.

 

Could you tell me how can I filter the selected blocks to standard and nonstandard blocks ?

Link to comment
Share on other sites

Dear tharwat,

 

this is useful .

 

i want a help from you can i get a lisp which can cross check the blocks from the standard file to my file and highlight the nonstandard blocks.

which will be very useful

Link to comment
Share on other sites

It is not that easy to check between two files for their blocks at all and it is out of my ability .

 

one solution .

 

you can extract the name of all your standard blocks from the main drawing by a routine and after that you can use these names to check for current blocks in a drawing and divide them into two lists of standard and nonstandard by another routine also of course .

Link to comment
Share on other sites

First let us extract all names of your drawing that contains the standard blocks .

(defun c:BlockList (/ ss i Block blockNames)
 ;;; Tharwat 07. March . 2012 ;;;
 (if (setq ss (ssget "_x" '((0 . "INSERT"))))
   (progn
     (repeat (setq i (sslength ss))
       (if (not (member (setq Block
                               (cdr (assoc 2 (entget (ssname ss (setq i (1- i)))))
                               )
                        )
                        blockNames
                )
           )
         (setq blockNames (cons Block blockNames))
       )
     )
     (print blocknames)
   )
   (princ)
 )
 (princ)
)

Link to comment
Share on other sites

It is not that easy to check between two files for their blocks at all and it is out of my ability .

 

one solution .

 

you can extract the name of all your standard blocks from the main drawing by a routine and after that you can use these names to check for current blocks in a drawing and divide them into two lists of standard and nonstandard by another routine also of course .

although that can only check that the names match. It is far harder (or at least outside my ability) to check that the block definitions are identical in both places which I thought was the task requested.
Link to comment
Share on other sites

i did this then what should i do

 

did you see all your standards block names prompted in the command line ?

 

Try this one which is better than the above one to check all blocks definitions and not only the inserted ones .

 

(defun c:BlockList (/ ss Block blockNames)
;;; Tharwat 07. March . 2012 ;;;
 (while (setq ss (tblnext "BLOCK" (null ss)))
   (if (not (member (setq Block
                           (cdr (assoc 2 ss))
                    )
                    blockNames
            )
       )
     (setq blockNames (cons Block blockNames))
   )
 )
 (if blocknames
   (print blocknames)
 )
 (princ)
)

And after that save the name of blocks that would be listed in the command line to include them later on in the second routine .

 

But be patient , I have many things to do at the office and would write one for you as soon as I have time to do .

 

Tharwat

Link to comment
Share on other sites

Consider this code as a draft at this moment :)

 

(defun c:Test (/
              BlockList
              stand
              non
              ss
              Blockname
              StandardBlockname
              nonstandardBlockname
             )
 ;;; Tharwat 07. March. 2012 ;;;
 (setq BlockList '([color=red][b]"Block1" "Block2"[/b][/color]));;; [color=red][b]Put the block name that you got from the first routine instead of the block names[/b][/color]
 (if (and (setq ss (ssget "_x" '((0 . "INSERT"))))
          (setq stand 0)
          (setq non 0)
     )
   (repeat (setq i (sslength ss))
     (setq
       Blockname (cdr (assoc 2 (entget (ssname ss (setq i (1- i))))))
     )
     (cond ((member Blockname BlockList)
            (progn
              (setq stand (1+ stand))
              (setq standardBlock (cons Blockname standardBlock))
            )
           )
           (t
            (progn
              (setq non (1+ non))
              (setq nonstandardBlock (cons Blockname nonstandardBlock))
            )
           )
     )
   )
   (princ)
 )
 (if Blockname
   (alert (progn
            (strcat " You have : < "
                    (itoa stand)
                    " > Standard Blocks inserted into this drawing "
            "\n"
            (strcat " You have : < "
                    (itoa non)
                    " > Nonstandard Blocks inserted into this drawing "
            )
          )
   )
          )
   )
 (princ)
)

Link to comment
Share on other sites

Tharwat a suggestion dump the blocks from the master dwg into a txt file name only and put somewhere safe. 2nd part run again on current drawing and compare the two lists. Display or write out some form of list found or not found.

 

3rd bit harder beyond me as part of step 1 write out the number of entities and name per block save as master txt do 2nd again for name and number of entities this is rough but would find a few changes.

 

result this time is

Found

Found but changed

Not found.

 

Like a lot of us sounds simple but takes a lot of time to write and test.

Link to comment
Share on other sites

Tharwat a suggestion dump the blocks from the master dwg into a txt file name only and put somewhere safe. 2nd part run again on current drawing and compare the two lists. Display or write out some form of list found or not found.

 

That's true , and thanks for the extra clarifications BIGAL :)

Link to comment
Share on other sites

Dear Tharwat,

 

thank you very much but i need one thing added to the lisp, the non standard block could be highlighted what ???????????????????

Link to comment
Share on other sites

Dear Tharwat,

 

thank you very much but i need one thing added to the lisp, the non standard block could be highlighted what ???????????????????

 

You're welcome :)

 

Check this one ...

 

(defun c:Test (/               BlockList       stand
              non             ss              Blockname
              StandardBlockname               nonstandardBlockname
             )
;;; Tharwat 08. March. 2012 ;;;
 (setq BlockList '("Block1" "Block2"))
;;; Put the block name that you got from the first routine instead of the block names
 (if (and (setq ss (ssget "_x" '((0 . "INSERT"))))
          (setq stand 0)
          (setq non 0)
          (setq sel (ssadd))
     )
   (repeat (setq i (sslength ss))
     (setq
       Blockname
        (cdr
          (assoc 2
                 (entget (setq sn (ssname ss (setq i (1- i)))))
          )
        )
     )
     (if (member Blockname BlockList)
       (progn
         (setq stand (1+ stand))
         (setq standardBlock (cons Blockname standardBlock))
       )
       (progn
         (ssadd sn sel)
         (setq non (1+ non))
         (setq nonstandardBlock (cons Blockname nonstandardBlock))
       )
     )
   )
   (princ)
 )
 (if Blockname
   (alert
     (progn
       (strcat
         " You have : < "
         (itoa stand)
         " > Standard Blocks inserted into this drawing "
         "\n"
         (strcat " You have : < "
                 (itoa non)
                 " > Nonstandard Blocks inserted into this drawing "
         )
       )
     )
   )
 )
 (if (>= non 1)
   (sssetfirst nil sel)
 )
 (princ)
)

Link to comment
Share on other sites

Tharwat, this is similar to a recent post I place looking for information on how to dump a list of all the blocks in my drawing. By all the blocks I mean all of them. Not the ones that have been inserted. I see by using this command:

 

(tblsearch "BLOCK" "t288")

 

this will list all the information about block t288, and it lists the long narrative description (4) which is what I need to identify the blocks I have against the blocks I still need to add. There are about 100 blocks in this drawing right now and I have to find someway to get my hands around what's in there and what's not. Can you assist me in how to get a listing of all the blocks in this file?

 

OK, so I've tried this:

 

(ssget "X"  (list  (cons 0 "INSERT")))

 

but all I get is . So now how do I access Selection Set: 31, to see what's in it.

Edited by Bill Tillman
Link to comment
Share on other sites

Try something like this its actually a bit easier using VL if you want a global answer like all blocks all layers use ssget when you want to use filters as well. if you want to use ssget then you need ( ssname ss x) pulls entity number x from list remember starts at 0.

 

(setq  doc (vla-get-activedocument (vlax-get-acad-object))) ; open database
(vlax-for block (vla-get-blocks doc) ; get all the blocks same as ssget
(setq blkname (vla-get-name block)) ;get block name in for loop
(if   (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) ; dont show model space etc 
(princ blkname) ; do what you want here 
)
) 

 

ps starting to come to grips with VL

Link to comment
Share on other sites

Thanks BigAl,

 

I found this:

 

http://www.cadtutor.net/forum/showthread.php?57103-Arguments-ACET-TABLE-NAME-LIST

 

and also this:

 

(setq blist (acet-table-name-list (list "block" 1 4)))

 

In the posting by Lee-Mac above I substituted 4 in the 70 field and it got the first block then crashed. So I substituted 4 for the 2 field and I got all those descriptions I'm after. But I need a way to put 2 and 4 together so I can have the block name and the associated description together.

 

Will try the example above in your reply now.

 

ps Coming to grips...well kind of...I'm gripping my hair and pulling it out.

 

The example you gave works but it doesn't separate the block names. The acet-table command above lists all the blocks in quotes which makes parsing them easier for me. I just need a way to get the blocks and the descriptions in a listing together.

 

Thanks again for the pointers...I'm still hacking but now it's time to put the monster away!

Link to comment
Share on other sites

  • 1 month later...

hey tharwat,

how are hope so doing well.

do you have lisp which can convert the layers data from excel to autocad.

note :- only layer name , color and line type is given

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