乐筑天下

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

[编程交流] 垂直线

[复制链接]

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:01:45 | 显示全部楼层
Try this:
 

[code](defun c:chain ( / *error* DOC E1 E2 FILE L LEN LLST OFILE PA                           PT SDIS SPC TANG TOBJ UNDO VLST X) (vl-load-com) ;; © Lee Mac  ~  24.05.10 (defun *error* ( msg )   (and Undo  (vla-EndUndoMark doc))   (and ofile (close ofile))       (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   (apply (function and)     (append       (mapcar         (function           (lambda ( sym str )             (set sym               (CurveifFoo                 (lambda ( x )                   (eq "LWPOLYLINE" (cdr (assoc 0 (entget x))))                 )                 str               )             )           )         )         '(e1 e2) '("\nSelect First Curve: ""\nSelect Curve to Measure to: ")       )       (list (setq file (getfiled "Create Output File" "" "txt" 1)))     )   )   (progn     (setq Undo (not (vla-StartUndoMark doc)))     (setq vLst       (GroupByNum         (vlax-get           (vlax-ename->vla-object e1) 'Coordinates         )         2       )     )     (while (setq x (car vLst))       (setq lLst         (cons           (list             (setq sDis               (vlax-curve-getDistatPoint e2                 (setq pt                   (vlax-curve-getClosestPointto e2 x)                 )               )             )             (car x) (cadr x)             (progn               (setq l (line x pt))               (setq len                 (vlax-curve-getDistatParam l                   (vlax-curve-getEndParam l)                 )               )             )           )           lLst         )         vLst (cdr vLst)       )       (vla-put-rotation         (setq tObj           (MText spc             (vlax-curve-getPointatParam l               (setq pa                 (/ (vlax-curve-getEndParam l) 2.)               )             )             (rtos len)             acAttachmentPointMiddleCenter           )         )         (setq tAng           (MakeReadable             (angle '(0. 0. 0.)               (vlax-curve-getFirstDeriv l pa)             )           )         )       )       (vla-put-backgroundfill tObj :vlax-true)       (vla-put-rotation         (MText spc pt (rtos sDis) acAttachmentPointMiddleCenter) tAng       )                  )     (setq ofile (open file "w"))     (mapcar       (function         (lambda ( line )           (write-line             (lst2str                               (mapcar                 (function                   (lambda ( p )                     (PadRight (rtos p) " " 10)                   )                 )                 line               )               "      "             )             ofile           )         )       )       (vl-sort Llst         (function           (lambda ( a b )             (< (car a) (car b))           )         )       )               )     (setq ofile (close ofile))          (setq Undo (vla-EndUndoMark doc))   ) ) (princ))(defun MakeReadable ( a ) ;; © Lee Mac (cond   (     (and (> a (/ pi 2)) ( a pi) (
回复

使用道具 举报

14

主题

40

帖子

26

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2022-7-6 12:06:27 | 显示全部楼层
Hi Lee,
 
Thanks this is a master piece, I have being trying to generate the lisp file for at least 2 years.
 
I am sure there are intermediate programs that could write the lisp for me but your the best.
 
Some time I would like to change the coordinates that are sent to the ascii file as the other intersection point on the blue line.
 
 
ty
 
bsimpson:roll:
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 12:08:50 | 显示全部楼层
Thanks bSimpson.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-6 11:20 , Processed in 0.379944 second(s), 56 queries .

© 2020-2025 乐筑天下

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