Vytukas 发表于 2022-7-6 09:48:31

Can't get selection right

Hello,
 
I'm new in this forum and new to visual lisp programming.
So i need help with my code.
 

(defun c:imp (/ file_to_process file_open sx_f text_list str_find s_x s_y icount1 icount2 icount cross_ent iname) (setq file_to_process (getfiled "\nChoose file" "F:\\" "txt" 16)) (setq str_list (ssadd)) (setq text_list (ssadd)) (setq iName 0) (vl-cmdf "._zoom" "_E") (if (setq file_open (open file_to_process "r"))      (while (setq sx (read-line file_open))      (if (setq str_find (ssget "_X" (list (cons 0 "*TEXT")(cons 1 sx))))      (progn      (setq text_list (ssadd (ssname str_find 0) text_list))      (setq str_list (ssadd (ssname str_find 0) str_list))      (setq iName (1+ iName))      (setq s_X (cadr (assoc 10 (entget (ssname str_find 0)))))      (setq s_Y (caddr (assoc 10 (entget (ssname str_find 0)))))       (setq iCount1 s_X)      (setq iCount2 s_Y)      (setq iCount "")          (while iCount      (setq iCount1 (1- iCount1))      (setq iCount2 (1- iCount2))            (if (setq cross_ent (ssget "_C" (list s_X s_Y 0) (list iCount1 iCount2 0) '((62 . 20))))            (progn      (setq iCount nil)            (setq str_list (ssadd (ssname cross_ent 0) str_list))          );progn      );if          );while      );progn      );if    );while ) ;if (sssetfirst nil str_list) (close file_open) (princ))(princ)I want to find first polyline that is surrounding the text object, but when i run my code it finds it but doesn't select it.
 
I think the problem is here:

            (if (setq cross_ent (ssget "_C" (list s_X s_Y 0) (list iCount1 iCount2 0) '((62 . 20))));a polyline with color = 20          (progn      (setq iCount nil)            (setq str_list (ssadd (ssname cross_ent 0) str_list))          );progn      );ifBut i can't get it work right.
Can someone explain what i'm doing wrong ?

Smirnoff 发表于 2022-7-6 10:37:19

1. Why Z incutting frame coordinates (list s_X s_Y 0) (list iCount1 iCount2 0)? It is no need because will be ignored. And why it is Integer 0 not Real 0.0?
 
2. The best way to view your cutting frame temporarily add to your code
 

(vl-cmdf "_.rectangle" (list s_X s_Y) (list iCount1 iCount2))
 
and set break point after it.

Smirnoff 发表于 2022-7-6 11:16:39

Note reversed. Atsiprašome brolis.
页: [1]
查看完整版本: Can't get selection right