乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 39|回复: 6

[编程交流] lsp file won't recognize

[复制链接]

10

主题

895

帖子

887

银币

初来乍到

Rank: 1

铜币
49
发表于 2022-7-5 14:00:25 | 显示全部楼层 |阅读模式
I have used this lisp file for a long time, modifying it over the years but now I can't get it to work with an attribute block.  I want it to call ATTEDIT when an attribute block is selected.  This is from 1994 so I am sure there are more elegant ways to do this code but if this can be quickly patched that would be good enough for me.
  1. ; TIP1011.LSP: ME.LSP    Multiple Editing   (c)1994, Gary Goode;;;modified 4.9.2003 to include mtext, dimensions, attdef and arctext;This program will let you pick and edit multi text and attributes;by window, pick or crossing using dialog boxes.;modified to use textedit;-----------------------------------------------------------------(defun C:ME (/ A B C D E F G H J K L M N P R)         (graphscr)   (setvar "CMDECHO" 0)   (setvar "HIGHLIGHT" 1)   (prompt "\nMulti-Edit is loaded ...  ")   (setq A (ssget) B (sslength A) C 0)                     (while (< C B) (setq D (ssname A C) E (entget D))      (setq F (car E))      (setq G (cdr E))      (setq H (car G))      (setq J (cdr H))      (setq K "TEXT")      (setq L "INSERT")      (setq M "DIMENSION")      (setq N "MTEXT")      (setq P "ATTDEF")      (setq R "ARCALIGNEDTEXT");;updated with next section using textedit for most objects      (if (= J K)(command ".TEXTEDIT" D ""))         (if (= J L)(command ".ATTEDIT" D ""))      (if (= J N)(command ".TEXTEDIT" D ""))      (if (= J M)(command ".TEXTEDIT" D ""))       (if (= J P)(command ".TEXTEDIT" D ""))      (if (= J R)(command ".ARCTEXT" D ""))   (setq C (1+ C)))   (princ)); end me.lsp
Thanks for any help you can provide.
         
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 14:18:05 | 显示全部楼层
Try something like this:
  1. (defun c:me ( / e i l s )    (setq l       '(            ("ATTDEF"         . "_.TEXTEDIT")            ("INSERT"         . "_.ATTEDIT")            ("TEXT"           . "_.TEXTEDIT")            ("MTEXT"          . "_.TEXTEDIT")            ("DIMENSION"      . "_.TEXTEDIT")            ("ARCALIGNEDTEXT" . "_.ARCTEXT")        )    )    (if (setq s            (ssget "_:L"               '(                    (-04 . "")                )            )        )        (repeat (setq i (sslength s))            (setq i (1- i)                  e (ssname s i)            )            (initcommandversion)            (command (cdr (assoc (cdr (assoc 0 (entget e))) l)) e)        )    )    (princ))
 
回复

使用道具 举报

10

主题

895

帖子

887

银币

初来乍到

Rank: 1

铜币
49
发表于 2022-7-5 14:21:28 | 显示全部楼层
Lee,
        Thanks for looking at this.  Your version doesn't edit the inserts in the order picked and it stops after the first mtext object rather than continuing when more than one has been selected.
        Thanks,
        rkent
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 2022-7-5 14:31:39 | 显示全部楼层
Heres a modification of Lee's suggestion - 
  1. ; Multiple Editing   (c)1994, Gary Goode; Updated version at: https://www.cadtutor.net/forum/topic/65888-lsp-file-wont-recognize-attribute-block-need-help/(defun C:ME nil (C:MultipleEditing)(princ))(defun C:MultipleEditing ( / *error* acDoc c e i L s )  (setq L    '(      ("ATTDEF"         (x) (command "_.TEXTEDIT" x  ""))      ("INSERT"         (x) (if (member '(066 . 1) (entget x)) (command "_.ATTEDIT" x)))      ("TEXT"           (x) (command "_.TEXTEDIT" x  ""))      ("MTEXT"          (x) (command "_.TEXTEDIT" x  ""))      ("DIMENSION"      (x) (command "_.TEXTEDIT" x  ""))      ("ARCALIGNEDTEXT" (x) (command "_.ARCTEXT" x))    )  )    (defun *error* ( m )    (and c (setvar 'cmdecho c))    (and acDoc (vla-EndUndoMark acDoc))    (and m (princ m)) (princ)  ); defun *error*    (cond    ( (setq s (ssget "_:L-I" '((000 . "ATTDEF,*DIMENSION,TEXT,MTEXT,ARCALIGNEDTEXT,INSERT"))))      (if vlax-get-acad-object        (progn           (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))           (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc)        ); progn      ); if      (and (setq c (getvar 'cmdecho)) (setvar 'cmdecho 0))      (repeat (setq i (sslength s))        (setq          i (1- i)          e (ssname s i)        )        (initcommandversion)        ((cdr (assoc (cdr (assoc 0 (entget e))) L)) e)      ); repeat    )  ); cond  (*error* nil) (princ)); defun C:MultipleEditing
 
        Couldn't figure out the ssget filter to select all the object types + attributed blocks (in theory Lee's suggestion should work - but I got XOR behavior, rather than OR).
        So I had to iterate and check every block reference if its attributed.
        And I hate posting "corrected" versions from a professional lispers that did 90% of the work.. but oh well, sorry Lee.
        I find this routine quite useful, so thanks guys!
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 14:46:22 | 显示全部楼层
Odd - it worked in my brief testing.
        The following should correct the pick order -
  1. (defun c:me ( / e i l s )    (setq l       '(            ("ATTDEF"         . "_.TEXTEDIT")            ("INSERT"         . "_.ATTEDIT")            ("TEXT"           . "_.TEXTEDIT")            ("MTEXT"          . "_.TEXTEDIT")            ("DIMENSION"      . "_.TEXTEDIT")            ("ARCALIGNEDTEXT" . "_.ARCTEXT")        )    )    (if (setq i -1 s            (ssget "_:L"               '(                    (-04 . "")                )            )        )        (while (setq i (1+ i) e (ssname s i))            (initcommandversion)            (command (cdr (assoc (cdr (assoc 0 (entget e))) l)) e)        )    )    (princ))
 
回复

使用道具 举报

10

主题

895

帖子

887

银币

初来乍到

Rank: 1

铜币
49
发表于 2022-7-5 14:50:37 | 显示全部楼层
Grr - when I select the objects one at a time the order for editing is last picked is edited first, with the first pick being the last one edited.  If I use a crossing window or a selection window then I see the order of editing the way you show in your video.
        Lee - yours still edits in the opposite order picked when  pick individually.  When selecting other than attributes it will halt and wait for me to select the next text again, I edit that, then it pauses to have be pick the next text.
        With the original you can pick individually text, attributes, etc, hit enter and then each one will be in edit mode in the order picked, first, second, third,...last.
        Thanks again for working on this, I appreciate your time and effort.
        rkent
回复

使用道具 举报

10

主题

895

帖子

887

银币

初来乍到

Rank: 1

铜币
49
发表于 2022-7-5 15:04:20 | 显示全部楼层
I finally narrowed the problem with the original to the ATTEDIT not working in the lisp.  After a search on the internet I found someone using
         
  1.     (command (initdia) ".ATTEDIT" "0,0" ""))
in their lisp file.  I have no idea, yet, what the (initdia) does, but I used it and the original works just fine now.  
  1. ; TIP1011.LSP: ME.LSP    Multiple Editing   (c)1994, Gary Goode;;;modified 4.9.2003 to include mtext, dimensions, attdef and arctext;This program will let you pick and edit multi text and attributes;by window, pick or crossing using dialog boxes.;modified to use textedit;-----------------------------------------------------------------(defun C:ME (/ A B C D E F G H J K L M N P R)         (graphscr)   (setvar "CMDECHO" 0)   (setvar "HIGHLIGHT" 1)   (prompt "\nMulti-Edit is loaded ...  ")   (setq A (ssget) B (sslength A) C 0)                     (while (< C B) (setq D (ssname A C) E (entget D))      (setq F (car E))      (setq G (cdr E))      (setq H (car G))      (setq J (cdr H))      (setq K "TEXT")      (setq L "INSERT")      (setq M "DIMENSION")      (setq N "MTEXT")      (setq P "ATTDEF")      (setq R "ARCALIGNEDTEXT");;updated with next section using textedit for most objects      (if (= J K)(command ".TEXTEDIT" D ""))         (if (= J L)(command (initdia) ".ATTEDIT" D ""))      (if (= J N)(command ".TEXTEDIT" D ""))      (if (= J M)(command ".TEXTEDIT" D ""))       (if (= J P)(command ".TEXTEDIT" D ""))      (if (= J R)(command ".ARCTEXT" D ""))   (setq C (1+ C)))   (princ)); end me.lsp
Thanks to everyone for helping with this request.
        rkent
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 23:30 , Processed in 1.653371 second(s), 66 queries .

© 2020-2025 乐筑天下

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