乐筑天下

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

[编程交流] 单Att旋转

[复制链接]

73

主题

261

帖子

195

银币

后起之秀

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

铜币
375
发表于 2022-7-5 17:21:30 | 显示全部楼层 |阅读模式
你好
我有一个lisp,可以旋转选定块的属性。是否可以更改为只有选定属性旋转,而不是所有属性旋转。
一个块中有多个属性,它们都需要不同的角度。
 
  1. (defun c:atrot(/ blSet attLst errCount oldAng)
  2. (if(not atrot:rAng)(setq atrot:rAng 0))
  3. (setq oldAng atrot:rAng
  4.        atrot:rAng
  5.     (getangle
  6.       (strcat "\nSpecify rotation angle <"(angtos atrot:rAng)">: ")))
  7. (if(not atrot:rAng)(setq atrot:rAng oldAng))
  8. (princ "<<< Select blocks to rotate attributes >>>")
  9. (setq errCount 0)
  10. (if
  11.    (setq blSet(ssget '((0 . "INSERT")(66 . 1))))
  12.    (progn
  13.      (setq blSet(mapcar 'vlax-ename->vla-object
  14.                    (vl-remove-if 'listp
  15.                     (mapcar 'cadr(ssnamex blSet)))))
  16.      (foreach itm blSet
  17.    (setq attLst
  18.           (vlax-safearray->list
  19.         (vlax-variant-value
  20.           (vla-GetAttributes itm))))
  21.    (foreach att attLst
  22.      (if(vl-catch-all-error-p
  23.           (vl-catch-all-apply
  24.             'vla-put-Rotation(list att atrot:rAng)))
  25.        (setq errCount(1+ ErrCount))
  26.          ); end if
  27.      ); end foreach
  28.    ); end foreach
  29.      ); end progn
  30.    (princ ">>> Nothing selected! <<<")
  31.    ); end if
  32. (if(/= 0 errCount)
  33.    (princ
  34.      (strcat "\n>>> "
  35.    (itoa errCount)
  36.          " attributes or blocks were on locked layer! <<< "))
  37.          ); end if
  38. (princ)
  39. ); end of c:atrot

 
 
还是谢谢你的时间
 
PMXcad
回复

使用道具 举报

1

主题

9

帖子

11

银币

初来乍到

Rank: 1

铜币
9
发表于 2022-7-5 17:40:17 | 显示全部楼层
这篇文章可能有一些有用的东西http://www.cadtutor.net/forum/showthread.php?97667-自动将文本旋转到任何UCS
回复

使用道具 举报

1

主题

9

帖子

11

银币

初来乍到

Rank: 1

铜币
9
发表于 2022-7-5 17:47:19 | 显示全部楼层
回复

使用道具 举报

73

主题

261

帖子

195

银币

后起之秀

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

铜币
375
发表于 2022-7-5 17:59:17 | 显示全部楼层
Good job alm865. Almost perfect.
Can it be made simpler?  ATROT -> angle -> pick attribute -> done.
And for the other attributes i wil do the same....running ATROT.
 
There are blocks with a lot of attributtes, like 10. And it could be that a attribute is the last one. By selecting a attribute for rotating.i scip the other attributes.
 
PMXcad
回复

使用道具 举报

1

主题

9

帖子

11

银币

初来乍到

Rank: 1

铜币
9
发表于 2022-7-5 18:04:42 | 显示全部楼层
Well there's lots of ways to do it.
 
If it was me I'd do a first pass with your script and create a list of attributes. Send the list to a 'list box in a dialog' for user selection (i.e. create a DCL file). The user returns the list and you check that each item is a member of the user's selection. Kind of like how the new 'laydel' command works if you choose selection by name.
 
If I get some time I'll post an example unless someone beats me to it with a better way ;-)
回复

使用道具 举报

73

主题

261

帖子

195

银币

后起之秀

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

铜币
375
发表于 2022-7-5 18:19:29 | 显示全部楼层
Okay Alm865, it's solved. I found a lisp in my lisp database. This does exactly what I want and more.
See code:
 
  1. ;*  Variables ans   = given answer to what to change                     *;*            tmp   = temporary storage                                  *;*            alist = storage of separate selections (check list)        *;*            pt    = storage for point selections                       *;*            sset  = selection set storage ( check for entity )         *;*            cnt   = storage for counter vs. string length              *;*************************************************************************; (defun c:chatt    ( / cnt ans tmp alist pt sset value angle style layer color hgt pos)       (setq ans "")       (setq tmp " ")       (setq alist (list ""))       (While (/= tmp "")                           ; Continue if user                                                    ; gives us an answer.         (prompt "\nChange what?\nValue, Angle,")         (prompt " Style, Layer, Color, Height, Position:"); Long eh?         (if (> (strlen ans) 0)           (progn            (prompt "\nCurrent[")                   ; Display the current            (prompt ans)                            ; list if available.            (prompt "]:")           )         )         (setq tmp (strcase (substr (getstring) 1 1)))         (if (AND (or (= tmp "V")(= tmp "A")(= tmp "S")(= tmp "L")                      (= tmp "C")(= tmp "H")(= tmp "P"))                  (= nil (member tmp alist))              )                                     ; If the answer is in the           (progn                                   ; group and not in the             (setq ans(strcat ans tmp))              ; check list add it!            (setq alist (append alist (list tmp)))           )         )       )       (if (= ans "")(setq ans "VASLCHP"))          ; If the user doesn't       (setq cnt 1)                                 ; us an option force       (setq value nil)                             ; all of them!       (setq angle nil)       (setq style nil)                             ; Set all the variables       (setq layer nil)                             ; to nil!       (setq color nil)                             ; I'm not very trusting!       (setq hgt nil)       (setq pos nil)       (While (/= "" (setq tmp (substr ans cnt 1))) ; Check for options and                                                    ; get the values.         (if (= tmp "V")          (setq value (getstring "\nNew Value for attributes: "))         )         (if (= tmp "A")          (setq angle (* 180 (/ (getangle "\nNew angle for attributes: ")                        pi)))         )         (if (= tmp "S")          (setq style (getstring "\nNew style for attributes: "))         )         (if (= tmp "L")          (setq layer (getstring "\nNew layer for attributes: "))         )         (if (= tmp "C")          (setq color (getstring "\nNew color for attributes: "))         )         (if (= tmp "H")             (setq hgt (getdist "\nNew height for attributes: "))         )         (if (= tmp "P")(setq pos 1))         (setq cnt (+ cnt 1))       )       (setvar "cmdecho" 0)       (setq pt (getpoint "\nSelect Attribute: "))  ; As long as we get a       (while pt                                    ; point value!         (if  (setq sset (ssget pt))                ; Check for an entity!            (progn               (if (= nil (assoc 66 (entget (ssname sset 0))))                 (progn                             ; If it does not have                                                    ; Attributes worry!                   (prompt "\nNot An Attributed Block")                   (setq sset nil)                 )               )            )            (progn                                  ; If you dont find              (prompt "\nNo Entity Found")          ; an entity at the              (setq sset nil)                       ; given location            )                                       ; worry!         )        (if (and pt sset)         (progn                                     ; If all is well,         (command ".attedit" "" "" "" "" pt "" )    ; Start the ATTEDIT         (if value (command "v" "r" value))         ; function and do         (if angle (command "a" angle))             ; each one that was         (if style (command "s" style))             ; requested and         (if layer (command "l" layer))             ; that has a value.         (if color (command "c" color ))         (if hgt (command "h" hgt ))                ; If the position         (if pos                                    ; was requested,           (progn                                   ; give an additional             (Prompt "\n New Position: ")           ; prompt since we             (command "p" pause )                   ; turned off the           )                                        ; command echo!         )         (command "")                               ; Terminate the         )                                          ; command.        )        (setq pt (getpoint "\nSelect Attribute: ")) ; Get a new point!       ));/* End of File */
 
 
still thanks for your time
 
PMXcad
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:28:09 | 显示全部楼层
This post may have some thing useful http://www.cadtutor.net/forum/showthread.php?97667-Auto-rotaing-text-to-any-UCS
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 04:50 , Processed in 0.438691 second(s), 66 queries .

© 2020-2025 乐筑天下

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