;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; ;;;; ;;;; Copyright (c) Feb. 1997 by Takehiko Nagakura. ;;;; ;;;; All rights reserved. ;;;; ;;;; ;;;; ;;;; Do not copy, use, modify or distribute this software ;;;; ;;;; without written permission by Nagakura. Nagakura will ;;;; ;;;; not be responsible for any consequence of its use. ;;;; ;;;; ;;;; ;;;; Takehiko Nagakura (e-mail: takehiko@mit.edu) ;;;; ;;;; Massachusetts Institute of Technology ;;;; ;;;; 77 Massachusetts Ave. 10-472M, Cambridge, MA 02139 ;;;; ;;;; ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Original Feb 21, 1997 by TN ;;;; Last updated Feb 10, 2001 by TN ; This file provides functions to demonstrate entity data manipulations. ; The program works in AutoCAD R13. ; ; ; function : description ; (print_entity_data entity) ; : prints all regular data attached to an entity ; (get_data_for_group_code group_code entity) ; : retieves a entity data corresponding to a specific DXF group_code ; (change_data_for_group_code group_code entity new_value) ; : changes a entity data corresponding to a specific DXF group_code ; ; The following is an excerpt from AutoLISP manual's command summery. ; ; (entget ename [applist]) : gets the definition data of an entity ; (entmod elist) : modifies the definition data of an entity ; (entmake [elist]) : makes a new entity and appends it to the drawing database ; (entdel ename) : deletes entities in the drawing ; (entnext [ename]) : finds the next entity in the drawing ; (entlast) : finds the last entity in the drawing ; (handent handle) : finds an entity by its handle ; (entsel [prompt]) : prompts user to select an entity by specifying a point ; (nentsel [prompt]) : returns additional data for nested entities ; (nentselp [prompt] [pt]) : returns a full 3D 4x4 matrix and enables the program to specify the pick point ; (entupd ename) : updates the screen image of an entity ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; example (command "layer" "make" "y_layer" "color" "yellow" "y_layer" "make" "c_layer" "color" "cyan" "c_layer" "") (command "zoom" (list -85 -85) (list 210 210)) ;Sets up the first circle (command "circle" '(0 0) 60) (setq col_1 (entlast)) (command "line" '(0 0) '(100 100) "") (setq line_1 (entlast)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun print_entity_data (entity / all_data) ; if the given parameter value is not an entity, ask user to pick one. (if (/= (type entity) 'ENAME) (setq entity (car (entsel "Pick an entity.")))) ; grabs the entity data and prints the content line by line. (setq all_data (entget entity)) (while all_data (print (car all_data)) (setq all_data (cdr all_data))) (textscr) ; forces text screen to show up. ) (defun get_data_for_group_code (group_code entity / all_data pair_list the_data) ; if the given parameter value is not an entity, ask user to pick one. (if (/= (type entity) 'ENAME) (setq entity (car (entsel "Pick an entity.")))) (setq all_data (entget entity)) (setq pair_list (assoc group_code all_data)) (setq the_data (cdr pair_list)) ) (defun change_data_for_group_code (group_code entity new_value / old_all_data pair_list the_data) ; if the given parameter value is not an entity, ask user to pick one. (if (/= (type entity) 'ENAME) (setq entity (car (entsel "Pick an entity.")))) (setq old_all_data (entget entity)) (setq old_pair_list (assoc group_code old_all_data)) (setq new_pair_list (cons group_code new_value)) (setq new_all_data (subst new_pair_list old_pair_list old_all_data)) (entmod new_all_data) (entupd entity) )