akgbmb 发表于 2022-7-5 23:37:50

将线路分成相等的间隔

是否有任何lisp可以满足以下条件?
将直线等距分割,但端点应为间距的一半,并添加交叉顶点

Lee Mac 发表于 2022-7-5 23:47:17

这会帮你实现目标:
 
http://lee-mac.com/centeredmeasure.html

akgbmb 发表于 2022-7-5 23:51:59

先生
我需要输入“输入段数”,并交叉点“x”,点大小为5

marko_ribar 发表于 2022-7-5 23:57:59

使用两倍大段数的“分割”命令,然后取每个奇数点1,3,5,。。。
 
确保在“除法”之前将“PDMODE”设置为3。。。
 
M、 R。
 

(defun c:divtest ( / pdm pds e ss c n )
(setq pdm (getvar 'pdmode)
       pds (getvar 'pdsize)
)
(setq e (entlast))
(if (null e)
   (progn
   (alert "No entities in active document... Please create and restart routine...")
   (exit)
   )
   (progn
   (while (not ss)
       (prompt "\nPick curve for division with points on equal spaces and half spaces at start/end of curve")
       (if (setq ss (ssget "_+.:E:S" '((0 . "*POLYLINE,LINE,SPLINE,HELIX,CIRCLE,ARC,ELLIPSE"))))
         (progn
         (setq c (ssname ss 0))
         (initget 7)
         (setq n (getint "\nSpecify number of division spaces : "))
         (setvar 'pdmode 3)
         (setvar 'pdsize 5)
         (command "_.divide" c (* (1- n) 2))
         (setq e (entnext e))
         (repeat (- n 2)
             (setq e (entnext e))
             (entdel e)
             (setq e (entnext e))
         )
         )
         (alert "Empty sel. set... Please, select again...")
       )
   )
   )
)
(setvar 'pdmode pdm)
(setvar 'pdsize pds)
(princ)
)

pBe 发表于 2022-7-6 00:02:58

(defun c:dib (/ point e div d mark1 pd)
;;;        pBeFeb2014        ;;;
(defun Point (pt)
   (entmakex (list (cons 0 "POINT")
          (cons 10 pt)
      )
   )
)

(if (and (setq
   ss        (setq
          ss (ssget
             '((0
                  .
                  "LWPOLYLINE,LINE,SPLINE,ARC"
               )
                )
             )
        )
   )
   (setq div (getint "\nEnter the number of segments : "))
   )
   (repeat (setq i (sslength ss))
   (setq e (ssname ss (setq i (1- i))))
   (setq d (vlax-curve-getdistatpoint e (vlax-curve-getEndPoint e)))
   (setq mark1 (/ d div)
    hlf          (* 0.5 mark1)
   )
   (point (setq pd (vlax-curve-getpointatdist e hlf)))
   (repeat (1- div)
(point (setq pd        (vlax-curve-getpointatdist
                  e
                  (+ (vlax-curve-getdistatpoint e pd) mark1)
                )
       )
)
   )
   )
)
(princ)
)

akgbmb 发表于 2022-7-6 00:13:20

它正在工作,但在使用lisp之前,我必须确保“PDMODE=3”,“PDSIZE=5”

MSasu 发表于 2022-7-6 00:18:10

然后只需将这些语句添加到代码中:
(setvar "PDMODE" 3)
(setvar "PDSIZE" -5)

akgbmb 发表于 2022-7-6 00:20:19

是的,它在工作
感谢您的宝贵支持

pBe 发表于 2022-7-6 00:30:19

 
很高兴能帮上忙
 
 
是的,谢谢你。
 
@马尔科
 
没有意识到您设置了pdmode和pdsize变量,我觉得这很奇怪。
 
伙计们,有没有lisp代码可以将点实体转换为一系列对象(几乎可以肯定会有)?或者最好使用点样式的块等效物?
 
有什么想法吗?

marko_ribar 发表于 2022-7-6 00:35:22

 
pBe,我在我的acaddoc中将pdmode设置为35,pdsize设置为-1.5。lsp,也许OP的ACAD设置也是如此。。。我已经设置并重新设置了这些变量,因为OP希望这些值用于这个特定的任务。。。只是不知道OP是考虑了相对于当前视口显示的点的相对%大小,还是他想要5个dwg单位大小。。。
页: [1] 2
查看完整版本: 将线路分成相等的间隔