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

BLOCK ON POINT UCS V AND UCS W

1 REPLY 1
Reply
Message 1 of 2
allanbsteven
366 Views, 1 Reply

BLOCK ON POINT UCS V AND UCS W

 

The code below will place a block on a point, but I cannot get it to work for both "View" and "world"

Can the option be added??

Cheers

Allan

 

(defun c:nt2blk( / *error* echohold attreqhold KorR ss len ct e pt)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg))
    ); end if
    (setvar 'attreq attreqhold)
    (command "_.undo" "_end")
    (setvar 'cmdecho echohold)
    (princ)
  ); defun
  (command "_.undo" "_begin")
  (setq
    echohold (getvar 'cmdecho)
    attreqhold (getvar 'attreq)
  ); setq
  (setvar 'cmdecho 0)
  (setvar 'attreq 0)
  (initget 1 "Keep Remove")
  (setq KorR (getkword "\nKeep or Remove point objects [K/R]: "))
  (prompt "\nSelect Block name from list, then pick OK.")
  (princ)
  (initdia)
  (command "_.insert" (getvar 'viewctr) "_.erase" "_last" ""); establishes default Block name
  (princ "\nSelect point objects:")
  (setq ss (ssget '((0 . "POINT"))))
  (if ss
    (progn ; then
      (setq len (sslength ss) ct 0)
      (while (< ct len)
        (setq
          e (ssname ss ct)
          ct (+ ct 1)
          pt (cdr (assoc 10 (entget e)))
        ); setq
        (command "_insert" "" "_none" pt "" "" "")
        (if (= KorR "Remove") (command "_.erase" e "")); remove Point if requested
      ); while
      (prompt (strcat "\nInserted " (itoa len) " Blocks on current Layer."))
    ); progn
    (princ "\nNo point objects selected."); else
  ); if
  (setvar 'attreq attreqhold)
  (command "_.undo" "_end")
  (setvar 'cmdecho echohold)
  (princ)
)

1 REPLY 1
Message 2 of 2
mid-awe
in reply to: allanbsteven

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

Post to forums  

Autodesk Design & Make Report

”Boost