Hello,
Please have a look at the free downloads area on our web-site (See
TechCenter URL - www.4d-technologies.com/techcenter)
The Blocks library provides a number of functions to easily process
blocks and attributes. In particular, the functions that you would find
useful are:
(BL_WriteAttr ...)
(BL_WriteAttrNo ...)
(BL_ReadAttr ...)
(BL_ReadAttrNo ...)
In addition, you may find a lot of other useful tools for working with
other AutoCAD objects.
Regards
Rakesh
anct wrote:
> Dear sirs,
> I'm working on a routine wich could extract area and perimeter values from a polyline, and than assign them to a specific existing block by simply picking it.
>
> At the moment I've managed to select the poly, extract and setq the area and perimeter values, select the block... but how to identify the attribute values nested in a block, in order to edit them?
>
> thank you for your time
>
>
> ------------------------------------------------------------------------
>
> (defun C:UPDAP (/ A P obj)
>
> ;;;****************EXTRACTS AREA AND PERIMETER FROM POLYLINES
> (command "area" "object" (setq obj (entsel)))
> ;ENTER TO EXIT LOOP. ERRNO 52?
>
> (if (= (getvar "errno") 0)
>
> (progn
> (setq A (rtos (getvar "area") 2 0))
> (setq P (rtos (getvar "perimeter") 2 0))
> (princ "\nArea: ")
> (princ A)
> (princ "\nPerimeter: ")
> (princ P)
> (princ)
> (BLKSEL)
> )
>
> (progn
> (princ "pick!!")
> (setvar "errno" 0)
> ) ;end progn
>
>
> ) ;end if
> )
> ;;end defun
> ;;;***************SELECTS OUR ALREADY PLACED BLOCK
> (defun BLKSEL (/ BSEL BGET)
> (while
> (OR (NULL BSEL)
> (/= (cdr (assoc 2 BGET)) "Ourblock")
> )
> (progn
> (setq BSEL (ENTSEL "\nSelect one of ourBlocks:"))
> (setq BGET (entget (CAR BSEL)))
>
> )
>
> )
> (BLKMOD BSEL A P)
> )
> ;;;***********************SHOULD FIND THE CURRENT VALUES OF AREA AND PERIMETER AND UPDATE THEM WITH THE NEW A AND P VALUES
> ;;;***********************ATTRIBUTE TAGS ARE "AA" AND "PP"
> (defun BLKMOD (BSEL A P / SUBENT SUBGET ATTTAG SUBLIST)
>
> (setq SUBENT (entnext (car BSEL)));;;car BSLEL acquires entity code, without the selecting point info
> (princ "step-1, ok")
>
> ;;;***********************THAT'S SOMETHING I HOPLESSY TRIED
>
>
>
> (while (or (= (cdr (assoc 0 SUBGET)) "ATTRIB") (NULL subget))
> (setq SUBGET (entget SUBENT))
> (setq ATTTAG (cdr (assoc 2 SUBGET)))
> (if (= ATTTAG "AA")
> (entmod (subst A (cdr (assoc 1 SUBGET)) SUBGET))
>
> ;;; (entmod SUBGET)
>
>
>
> )
> ;;end if
> (setq SUBENT (entnext SUBENT))
>
> ;;; (if (= ATTTAG "PP")
> ;;; (setq SUBENT (subst (cons "0" P)
> ;;; (cdr (assoc 1 SUBENT))
> ;;; SUBENT
> ;;; )
> ;;; ;;end subst
> ;;; )
> ;;; ;;end setq
> ;;; );;end if
>
>
>
> )(princ "done")
> ;;end while
> )
>
>
> ;;;*************************************************************************************************************
> (alert
> "\n\tLoaded A-P LISP. Type UPDAP to begin."
> )
> (princ)
--
Please email me your replies. I may not always be observing the posts here.
AutoCAD customization for Engineering/Mapping/GIS
Get GeoTools @ http://www.4d-technologies.com/geotools
Build MyGeoTools @ http://www.4d-technologies.com/geotools/my_geotools.htm
FREE downloads : http://www.4d-technologies.com/techcenter