(defun NEXUS_REF () (setq allObjSet (ssget "X") totalNUM (sslength allObjSet) counter 0 attMode 0) ;**************** To be changed if different ****************** (setq ATT_Tag_Name "EXTERNAL.REFERENCE.3D.DRAWING.TAG") ;************************************************************** ;******************** Start LISP logic ************************ ;Set initial start of loop ;************************* (setq entity (entnext)) ;Start loop on objects ;********************* (while (< counter totalNUM) ;Get layername ;************* (setq tempSS (ssadd)) (ssadd entity tempSS) (setq layerName (strcat "NX_" (cdr (assoc 8 (entget (ssname tempSS 0)))))) (setq layerName_ORG (cdr (assoc 8 (entget (ssname tempSS 0))))) ;Layer name without NX ;Create attribute ;**************** (if (= 0 attMode) (progn (command "attdef" "I" "L" "" ATT_Tag_Name "Promp" layerName '(0.0 0.0 0.0) 5000 0) (setq attMode 1) ) (command "attdef" "" ATT_Tag_Name "" layerName '(0.0 0.0 0.0) 5000 0) ) ;Setting selection ;***************** (setq currentOBJ (ssget "L")) (ssadd entity currentOBJ) ;Set current layer ;***************** (if (tblsearch "layer" layerName_ORG) (setvar 'clayer layerName_ORG) (prompt (strcat "\n** Layer \"" layerName_ORG "\" not found ** ")) ) ;Create block ;************ (command "block" layername '(0.0 0.0 0.0) currentOBJ "") ;Re-insert blocks ;**************** (setq blockOBJ (ssget "L")) ;;(setq a (entget (ssname blockOBJ 1))) (command "insert" layername '(0.0 0.0 0.0) "" "" "" "") ;Counter step ;************ (setq counter (1+ counter)) (setq entity (entnext entity)) (setq currentOBJ nil) (setq blockOBJ nil) ) )