查看: 100|回复: 2

[编程交流] Can't get selection right

[复制链接]
发表于 2022-7-6 09:48:31 | 显示全部楼层 |阅读模式
Hello,
 
I'm new in this forum and new to visual lisp programming.
So i need help with my code.
 
  1. (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:
  1.             (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        );if
But i can't get it work right.
Can someone explain what i'm doing wrong ?
回复

使用道具 举报

发表于 2022-7-6 10:37:19 | 显示全部楼层
1. Why Z in  cutting 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
 
  1. (vl-cmdf "_.rectangle" (list s_X s_Y) (list iCount1 iCount2))
 
and set break point after it.
回复

使用道具 举报

发表于 2022-7-6 11:16:39 | 显示全部楼层
Note reversed. Atsiprašome brolis.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2026-4-1 18:50 , Processed in 0.256725 second(s), 67 queries .

© 乐筑天下创办于2020年,已稳定运行至今,你来与不来,我们都一直在这里...

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表