Message 1 of 5
Creating List of newly made points and using that in next function

Not applicable
07-21-2016
04:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have this code, which creates text and inserts a block on a selection of 3D points which are created from the first function from Attributed Blocks. I want to narrow it down to one step instead of having to select the points twice.
Is it possible to create a new list at the end of the first function which contains all the newly created 3D points and instead of having to select them again, use that set for the next two functions which are narrowed down to just one step?
(defun c:toelev1( / opt lay count object elev) ;;program name is toelev (setq ssPoints (ssget '((0 . "INSERT")(2 . "POINT")))) ;;restrict selection set (initget "Yes No") ;;initialize keywords (setq opt (getkword "\nWould you like to add AutoCAD point to the drawing?")) ;;find out if adding nodes (if (= opt "Yes") ;;selected yes? (while (= lay nil) ;;prompt for layer name until (setq lay "SPOTHEIGHT_POINTS") ;;user enters one ) ;;while ) ;;if (setq count 0) ;;initialize counter (repeat (sslength ssPoints) ;;repeat for each point (setq object (entget (entnext (ssname ssPoints count)))) ;;get entity data (if (= "ELEV" (cdr (assoc 2 object))) ;;check if first attribute (progn ;;is elevation (setq elev (atof (cdr (assoc 1 object)))) ;;get elevation attribute (moveup (ssname ssPoints count) elev opt lay) ;;run move up function (setq count (+ count 1)) ;;increment counter ) ;;progn ) ;;if ) ;;repeat (princ) ) ;;defun (defun moveup(pntblock elev opt lay / ) ;;moveup function takes (setq pntblock (entget pntblock)) ;;pntblock & elev parameters (setq pntblock (subst (list 10 (cadr (assoc 10 pntblock)) ;;substitute new elev for old (caddr (assoc 10 pntblock)) elev) (assoc 10 pntblock) pntblock)) (entmod pntblock) ;;update point block (if (= opt "Yes") ;;if user chose yes earlier (entmake (list '(0 . "POINT") (assoc 10 pntblock) (cons 8 lay))) ;;make an AutoCAD point ) ;;if (princ) ) ;;;;;;;;;;;;;;;; (defun SPOT ( / pt ent loc pt2 elv i sty) (prompt "\nSelect points: ") (setq sset (ssget '((0 . "POINT"))) i 0 z (getvar "textsize") ) (setq sty "R") (if (not (tblsearch "STYLE" sty)) (setq sty (getvar 'textstyle)) ) (if sset (repeat (sslength sset) (setq pt (ssname sset i)) (setq ent (entget pt)) (setq loc (cdr (assoc 10 ent))) (setq pt2 (polar (list (car loc) (cadr loc)) 0.0 z)) (setq elv (last loc)) (entmake (list (cons 0 "TEXT") (cons 100 "AcDbText") (cons 8 "SPOTLEVELS") ;Layer (cons 1 (rtos elv 2 2)) ;Content (cons 10 pt2) ;Insert Point (cons 40 0.4) ;Text Height (cons 41 0.8) ;Text Width (cons 71 1) ;Justification (4=Top Left) (cons 50 0.785398) ;Rotation (Radians) (cons 51 0.261799) ;Oblique Angle (cons 7 sty) ;Text Style ) ) (setq i (1+ i)) ) (princ "\n No POINT objects found! ") ) (princ) ) ;;;;;;;;;;;;;;;; (defun cross ( / BlockName sn) (setq BlockNAme "SH_CROSS") (if (not (tblsearch "BLOCK" BlockName)) (prompt (strcat "\nBlock name <" BlockName "> is not found in this drawing !")) (while (setq sn (ssname sset 0)) (entmake (list '(0 . "INSERT") (cons 2 BlockName) (assoc 10 (entget sn)))) (ssdel sn sset) ) ) (princ) ) (defun c:WSH( / sset ) (c:toelev1) (SPOT) (if sset (cross)) (command "-layer" "off" "SPOTHEIGHT_POINTS") (princ) )