Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Check attribute of block with external database

3 REPLIES 3
Reply
Message 1 of 4
AcciaioSteel
353 Views, 3 Replies

Check attribute of block with external database

Hi everybody Smiley Happy,

 

I have a big problem and i ask you help me, please!!!

 

I have a block with:

 

tag1: XX

tag2: YYYYYY

tag3: ZZZZZZZZ

 

I have an external file check.txt with string:

 

XXYYYYYYZZZZZZZZ

 

I would like to create a lisp program that check the attributes of block using an external database, if tag1+tag2+tag3 = XXYYYYYYZZZZZZZZ ok end program, if not  make a circle on block :

 

Thanks-you very much

AcciaioSteel

3 REPLIES 3
Message 2 of 4
devitg
in reply to: AcciaioSteel

Are it ?

 

tag1: XX

tag2: YYYYYY

tag3: ZZZZZZZZ 

 

textstring that mean numbers, or letters 

 

Please ubload a sample DWG , or send it off  line , see attached file 

Message 3 of 4
pbejse
in reply to: AcciaioSteel


@AcciaioSteel wrote:

Hi everybody Smiley Happy,

 

I have a big problem and i ask you help me, please!!!

 

I have a block with:

 

tag1: XX

tag2: YYYYYY

tag3: ZZZZZZZZ

 

I have an external file check.txt with string:

 

XXYYYYYYZZZZZZZZ

 

I would like to create a lisp program that check the attributes of block using an external database, if tag1+tag2+tag3 = XXYYYYYYZZZZZZZZ ok end program, if not  make a circle on block :

 

Thanks-you very much

AcciaioSteel


Sounds easy enough. What does the text file contents look like? If it is as vague as you have posted XXYYYYYYZZZZZZZZ , how'd you know where the second and third tag value start and end? If the length of string per tag value is constant ,then its easy cheesy. 

 

Provide more ino AcciaioSteel

 

Message 4 of 4
pbejse
in reply to: pbejse


@pbejse wrote:
 Provide more ino AcciaioSteel 

info provided thru PM

 

...it is possible make the circle on new layer named "$01Check" with yellow color?

 

HYG

 

(defun c:CirBlk ( / file of data ss Bdata e ll ur str)
(vl-load-com)
(if (not (tblsearch "Layer" "$01Check"))
  	(entmake (list (cons 0 "LAYER")
                 (cons 100 "AcDbSymbolTableRecord")
                 (cons 100 "AcDbLayerTableRecord")
                 (cons 2 "$01Check")
                 (cons 70 0)(cons 62 5))))
(cond ((and
        (setq data nil file  (getfiled "Select text file" (getvar 'dwgprefix) "txt" 16))
        (progn (setq of (open file "r"))
	(while (setq a (read-line of))
	  	(setq data (cons a data))
	  )
	(close of) data
          )
	(setq ss (ssget "_x" '((0 . "INSERT")(66 . 1)(2 . "sample"))))
	(repeat (setq i (sslength ss))
          (setq str "" Bdata (last (mapcar '(lambda (j)
                           (if (member (vla-get-tagstring j) '("TAG1" "TAG2" "TAG3"))
                             		(setq str (strcat str (strcase (vla-get-textstring j))))))
          		(vlax-invoke (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
                          'GetAttributes))))
          (if (not (member Bdata Data))
            	(progn
                  	(vla-getboundingbox e 'll 'ur)
                  	(entmakex (list (cons 0 "CIRCLE")
				(cons 10
                                      (mapcar (function (lambda (a b) (/ (+ a b) 2.)))
                                              (vlax-safearray->list ll)
                                              (vlax-safearray->list ur)
                                      )
                                )
				(cons 8 "$01Check")
				(cons 40 (* (distance (vlax-safearray->list ll)
                                     (vlax-safearray->list ur)) 0.5))))
                  			)
            			)
                          )
          	)
       )
      )
(princ)
  )

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost