WHY? ; error: bad argument type: lselsetp

WHY? ; error: bad argument type: lselsetp

nychoe1
Advocate Advocate
522 Views
2 Replies
Message 1 of 3

WHY? ; error: bad argument type: lselsetp

nychoe1
Advocate
Advocate

WHY?   ; error: bad argument type: lselsetp

;;; textbox
(defun c:txt (/ e_list ap1 ap2 ax ay dx dy agng tp1 op1 op2 op3 op4)
   (setq ss (entsel  "\n\tselect text : "))
      (setq en (ssname ss 0))
      (setq e_list (entget en))
      (setq ap1 (car (textbox e_list)))
      (setq ap2 (cadr (textbox e_list)))
      (setq ax (car ap2) ay (cadr ap2) )
      (setq dy (/ ay 4) dx (/ ay 2)) 
      (setq agng (cdr (assoc 50 e_list)))
      (setq tp1 (cdr (assoc 10 e_list)))
      (setq op1 (polar tp1 (- agng pi) dx)) 
      (setq op1 (polar op1 (- agng (/ pi 2)) dy))                 
      (setq op2 (polar op1 agng (+ ax (* dx 2))))              
      (setq op3 (polar op2 (+ agng (/ pi 2)) (+ ay (* dy 2)))) 
      (setq op4 (polar op3 (+ agng pi) (+ ax (* dx 2))))        
      (command "pline" op1 op2 op3 op4 "c")    
   (princ)
)

0 Likes
523 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant

Beacause entsel retuns a list of (entname picked-point). Entname you get using (car (entsel)). But if you dont need a point, ssget is better. It allows you pre-selection. Also it's easier to set some filter for entities you need. Read about ssget.

 

Spoiler
(defun c:txt (/ e_list ap1 ap2 ax ay dx dy agng tp1 op1 op2 op3 op4)
   (setq esel (entsel  "\n\tselect text : "))
      (setq en (car esel))
      (setq e_list (entget en))
      (setq ap1 (car (textbox e_list)))
      (setq ap2 (cadr (textbox e_list)))
      (setq ax (car ap2) ay (cadr ap2) )
      (setq dy (/ ay 4) dx (/ ay 2)) 
      (setq agng (cdr (assoc 50 e_list)))
      (setq tp1 (cdr (assoc 10 e_list)))
      (setq op1 (polar tp1 (- agng pi) dx)) 
      (setq op1 (polar op1 (- agng (/ pi 2)) dy))                 
      (setq op2 (polar op1 agng (+ ax (* dx 2))))              
      (setq op3 (polar op2 (+ agng (/ pi 2)) (+ ay (* dy 2)))) 
      (setq op4 (polar op3 (+ agng pi) (+ ax (* dx 2))))        
      (command "pline" op1 op2 op3 op4 "c")    
   (princ)
)

(defun c:txt2 (/ e_list ap1 ap2 ax ay dx dy agng tp1 op1 op2 op3 op4)
  (princ "\nNeed TEXT,")
  (if (setq ss (ssget "_+.:E:S" '((0 . "TEXT"))))
    (progn
      (setq e_list (entget (ssname ss 0))
            ap2 (cadr (textbox e_list))
            ax (car ap2)
            ay (cadr ap2)
            dy (/ ay 4)
            dx (/ ay 2)
            agng (cdr (assoc 50 e_list))
            tp1 (cdr (assoc 10 e_list))
            op1 (polar tp1 (- agng pi) dx)
            op1 (polar op1 (- agng (/ pi 2)) dy)
            op2 (polar op1 agng (+ ax (* dx 2)))
            op3 (polar op2 (+ agng (/ pi 2)) (+ ay (* dy 2)))
            op4 (polar op3 (+ agng pi) (+ ax (* dx 2))))
      (command "_.pline" op1 op2 op3 op4 "_c"))
    (princ "\nWrong selection, required TEXT."))
  (princ)
)

Did you tried this?

 

Maybe easier would be calculation of just two points and draw rectangle with angle.

 

 

Message 3 of 3

nychoe1
Advocate
Advocate
I got it. thank you for big help.
0 Likes