[help] lisp newbie. nil message...

Discussion in 'AutoCAD' started by francesco panzeri, Jan 17, 2005.

  1. Hi! i've written a little lisp to understand my level but it doesn't work
    and i'm not able to understand why.
    My lisp draw a circle of 1000units diameter from the insert point of any
    block called "blok".
    Is anybody out there able to help me?

    Thnk a lot

    Franz



    (defun c:cc ()
    ;;;;;;;;;;;;;;;;;;;;;;;;;fa un cerchio di 10 un intorno al p di ins dei
    blocchi
    (command "_UNDO" "_BE"
    "expert" "5")
    (setq
    act_os (getvar "OSMODE")
    act_la (getvar "CLAYER")
    )
    (command

    "_VIEW" "_S" "START"
    "-LAYER" "S" "0" ""
    "OSMODE" "0" "_ucs" "w")
    (princ "\nSeleziona oggetti: ")
    (setq my_sel (ssget)
    m_s_l (sslength my_sel)
    count 0
    van_blk (ssadd)
    )
    (setq act_ent (ssname my_sel count)
    )
    (if (and
    (= "INSERT"
    (cdr (assoc 0 (setq act_list (entget act_ent))))
    )
    (= "BLOK"
    (cdr (assoc 2 act_list))
    )
    )
    (setq van_blk (ssadd act_ent van_blk)
    count (1+ count)
    )
    )
    (setq
    v_b_l (sslength van_blk)
    count_b 0
    )

    (while (< count v_b_l)
    (setq
    tr_obj (ssname van_blk count)
    act_ent tr_obj
    count_b (1+ count_b)
    p_ins (cdr (assoc 10 (entget tr_obj)))
    )
    )

    (command

    "_circle" p_ins "" 1000 "")
    (command "_ucs"
    "_P"
    "_UNDO"
    "_END"
    )
    (command "_VIEW" "_R" "START"
    "OSMODE" "act_os"
    "CLAYER" "act_la"
    )

    )
     
    francesco panzeri, Jan 17, 2005
    #1
  2. francesco panzeri

    Tom Berger Guest

    Am Mon, 17 Jan 2005 20:04:13 +0100 schrieb francesco panzeri:
    ;; help function to translate a pickset to a list of entities:
    (defun ss_s2e (sset / eset counter)
    (setq counter 0)
    (if (= 'PICKSET (type sset))
    (repeat (sslength sset)
    (setq eset (cons (cdr (assoc -1 (entget (ssname sset counter))))
    eset)
    counter (1+ counter)
    )
    )
    )
    eset
    )

    ;; Now, the function

    (defun c:cc ()
    (if (setq sset (ss_s2e (ssget "X" '((0 . "INSERT")))))
    (mapcar (function (lambda (en)
    (command "._circle" (trans (cdr (assoc 10 (entget en))) 0 1) 500)
    )
    sset
    )
    (princ "\nno blocks inserted")
    )
    (prin1)
    )

    Good luck
    Tom Berger
     
    Tom Berger, Jan 17, 2005
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.