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

Newbie list step through help

1 REPLY 1
Reply
Message 1 of 2
gccdaemon
262 Views, 1 Reply

Newbie list step through help

I've got a list of xrefs / blocks that I'm trying to put through a set of commands. What I need to happen is this:

 

1. Isolate one item from the list.

2. Run the set of commands.

3. Remove the isolated item from the list.

4. Repeat items 1 thru 3 until no items are left in the list.

 

Here is some of the code, and if you see anything that could be changed, please let me know.

;; Object Selection List

  (princ "\nPick X-Refs or Blocks to copy objects from... ")
  (setq XRLIST (ssget '((-4 . "<OR")(0 . "INSERT")(-4 . "OR>"))))

;; Save Selection Window

  (princ "\nDraw selection window...")
  (COMMAND "._Select" "_si" "CPolygon")
  (while (eq 1 (logand 1 (getvar "cmdactive")))
  (COMMAND pause))
  (setq SS1 (ssget "P"))
  (setq BNDY (mapcar 'cadr (cdr (last (ssnamex SS1)))))

;; Rebuild Selection Window

(defun buildpolyline (SS1 /)
  (setq pointlst (cdr (assoc '-1 (ssnamex ss 0))))
  (setq pointlst (mapcar '(lambda (x) (cadr x)) pointlst))
  (setq nextpnt (car pointlst) pointlst (cdr pointlst))
  (command "pline" nextpnt)
  (while (setq nextpnt (car pointlst))
    (command nextpnt)
    (setq pointlst (cdr pointlst)))
  (command "close")
  (setq nextpnt (car pointlst) pointlst (cdr pointlst))
  (command "pline" nextpnt)
  (while (setq nextpnt (car pointlst)) (command nextpnt) (setq pointlst (cdr pointlst)))
  (command "close")
)

;; Step Through List

(repeat (setq inc (sslength XRLIST))
  (setq XREF (ssname XRLIST (setq inc (1- inc))))

;; Commands to run on isolated object in list

  (command
    "-refedit" XREF "O" "N" "WP" (buildpolyline BNDY) "N"
    "_copy" "ALL" "" ZBASE ZBASE
    "_refset" "R" "ALL" ""
    "_refclose" "D"
  )
)

 

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
1 REPLY 1
Message 2 of 2
gccdaemon
in reply to: gccdaemon

bump

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram

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

Post to forums  

Autodesk Design & Make Report

”Boost