乐筑天下

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

[编程交流] 自动编号和长度

[复制链接]

7

主题

30

帖子

23

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 19:08:26 | 显示全部楼层
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 19:11:32 | 显示全部楼层
You're welcome
 
I like to use the dynamic approach when placing text, as it gives you a proper preview of what you are about to place. The only drawback to this method is that you don't have any AutoCAD functionality such as OSnap, Ortho, Tracking etc. But I figure most do not use such that regularly to place text.
 
Lee
回复

使用道具 举报

51

主题

481

帖子

457

银币

后起之秀

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

铜币
262
发表于 2022-7-5 19:16:15 | 显示全部楼层
Alanjt
 
see attached image and cad file
193251voyk2n293o2n6adz.png
plab.dwg
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-5 19:17:08 | 显示全部楼层
Ahh, the woes of vlax-curve-getClosestPointTo and not properly considering it's obvious constraints.
 
Try it now (also removed the need for the AT:MText subroutine since I was defining the ActiveSpace for each text object.
 
 
  1. (defun c:PLab (/ obj) ;; Label each LWPolyline segment with number and distance ;; Alan J. Thompson, 04.21.10 / 04.23.10 (vl-load-com) (if (and (setq obj (car (entsel "\nSelect LWPolyline: ")))          (or (eq "LWPOLYLINE" (cdr (assoc 0 (entget obj))))              (alert "Invalid object!")          )          (setq obj (vlax-ename->vla-object obj))     )   ((lambda (n l s / d)      (while (nth (1+ (setq n (1+ n))) l)        ((lambda (a b / dist)           (setq dist (abs (- (setq d (vlax-curve-getDistAtPoint obj a))                              (vlax-curve-getDistAtPoint obj b)                           )                      )           )           ((lambda (p)              ((lambda (text)                 (vla-put-AttachmentPoint text                  (vla-put-InsertionPoint text p)                 ;; (vla-put-Rotation text (angle a b))                 ((lambda (ang)                    (if (and (> ang (* pi 0.5)) (< ang (* pi 1.5)))                      (vla-put-rotation text (+ pi ang))                      (vla-put-rotation text ang)                    )                  )                   (angle a b)                 )               )                (vla-AddMText s p 0. (strcat (itoa (1+ n)) " - " (rtos dist)))              )            )             (vlax-3d-point (vlax-curve-getPointAtDist obj (+ (/ dist 2.) d)))           )         )          (nth n l)          (nth (1+ n) l)        )      )    )     -1     (AT:ListGroupByNumber (vlax-get obj 'Coordinates) 2)     (if (or (eq acmodelspace                 (vla-get-activespace                   (cond (*AcadDoc*)                         ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))                   )                 )             )             (eq :vlax-true (vla-get-mspace *AcadDoc*))         )       (vla-get-modelspace *AcadDoc*)       (vla-get-paperspace *AcadDoc*)     )   ) ) (princ));;; Group items in list based on specified number;;; L - List to process;;; # - Number of items for grouping;;; Alan J. Thompson, 03.26.10(defun AT:ListGroupByNumber (L # / n g f) (setq n -1) (while (> (1- (length L)) n)   (repeat # (setq g (cons (nth (setq n (1+ n)) L) g)))   (setq f (cons (reverse g) f)         g nil   ) ;_ setq ) ;_ while (reverse f)) ;_ defun
193253w449m152yhh0oloo.png
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 19:21:33 | 显示全部楼层
I think Alan's gone lambda mad
回复

使用道具 举报

54

主题

3755

帖子

3583

银币

后起之秀

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

铜币
438
发表于 2022-7-5 19:25:04 | 显示全部楼层
ROFL
I did let them get a little out of control. Ever since you did that Boundingbox routine modeled after MP's code, I've been loving and abusing lambda outside of the use of mapcar (or defining as functions like I've been known to do) like a mad man.
 
I mean, look at this:
  1.     (([color=Red]lambda[/color] (n l s / d)      (while (nth (1+ (setq n (1+ n))) l)        (([color=Red]lambda [/color](a b / dist)           (setq dist (abs (- (setq d (vlax-curve-getDistAtPoint obj a))                              (vlax-curve-getDistAtPoint obj b)                           )                      )           )           (([color=Red]lambda [/color](p)              (([color=Red]lambda [/color](text)                 (vla-put-AttachmentPoint text                  (vla-put-InsertionPoint text p)                 ;; (vla-put-Rotation text (angle a b))                 (([color=Red]lambda [/color](ang)
5 lambda expressions
 
You know, I'm surprised you haven't commented on my abandonment of end line comments and #Variable assigning.
 
BTW/off topic: I got a 96 on my Trig test (final Monday) and 2 of those points were taken off because I forgot to denote my units on a problem. If you hadn't answered my questions, I would have been completely lost on that section. Thanks a lot.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 19:27:06 | 显示全部楼层
 
No worries mate, glad it went well for you
回复

使用道具 举报

1

主题

10

帖子

15

银币

初来乍到

Rank: 1

铜币
9
发表于 2022-7-5 19:32:38 | 显示全部楼层
Lee Mac the PLen lisp works great for what I am wanting, but would it be possible to have one that would...


  • Not to do auto numbering.
  • The total length value gets inserted automatically in the center/midpoint of the polyline.
I would like to go for speed when finding the length of each polyline. If it could be possible I would like to be able to select all polylines and have all the values insert themselvs automatically on each individual polyline.
 
Thanks agian and hopes its not asking too much.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 19:33:49 | 显示全部楼层
Hi Gordon,
 
Give this a shot, let me know how you get on (using FIELDS),
 

[code](defun c:PlL ( / *error* spc i ss e Der p obj ) (vl-load-com) ;; Lee Mac  ~  29.04.10 (defun *error* ( msg )   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")       (princ (strcat "\n** Error: " msg " **")))   (princ) ) (setq spc   (if     (or       (eq AcModelSpace         (vla-get-ActiveSpace           (setq doc             (vla-get-ActiveDocument               (vlax-get-acad-object)             )           )         )       )       (eq :vlax-true (vla-get-MSpace doc))     )     (vla-get-ModelSpace doc)     (vla-get-PaperSpace doc)   ) ) (if (setq i -1 ss (ssget '((0 . "LINE,*POLYLINE"))))      (while (setq e (ssname ss (setq i (1+ i))))     (setq Der       (angle '(0. 0. 0.)         (vlax-curve-getFirstDeriv e           (vlax-curve-getParamatPoint e             (setq p (MidPoint e))           )         )       )     )                    (setq Obj       (MCMText spc (polar p (- Der (/ pi 2.)) (getvar 'TEXTSIZE)) 0.         (strcat "%%).Length \\f \"%lu6\">%"         )       )     )     (vla-put-rotation Obj (MakeReadable Der))   ) ) (princ))(defun MCMText (block point width string / o) (vla-put-AttachmentPoint   (setq o (vla-AddMText block             (vlax-3D-point point) width string))   acAttachmentPointMiddleCenter)  (vla-put-InsertionPoint o (vlax-3D-point point))  o)(defun MakeReadable ( a ) (cond   (     (and (> a (/ pi 2)) ( a pi) (
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 13:42 , Processed in 0.364760 second(s), 70 queries .

© 2020-2025 乐筑天下

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