eric_monceaux 发表于 2022-7-6 07:41:48

用直线到C进行圆弧分割

因此,我一直在论坛上搜索LISP,它可以在添加砂浆接缝的同时分割圆弧。
 
我工作的铸石公司制造窗户周围,当我绘制它们时,它们必须用1/4英寸的砂浆接缝等长分开。目前我所做的是使用DIVIDE命令,然后编写一个小的多线宏,从弧节点到所述弧的中心点绘制一条多线。
 
早在2006年,一个CADToor。net成员(CAB)和2009年(SteveK)帮助我将qbasic公式转换为LISP,用于水平和垂直片段,我想看看是否可以为圆弧片段创建类似的东西。
 
我附上了一个窗口环绕的例子。
车窗镶边。图纸
石头段。LSP

eric_monceaux 发表于 2022-7-6 07:55:57

同样作为背景,以下是我在LISP最初开发时提到的两篇文章。
 
http://www.cadtutor.net/forum/showthread.php?40973-LISP分割到一定的长度&p=275781#post275781。
 
http://www.cadtutor.net/forum/showthread.php?6712-将-a-QBASIC-formula-转换为-an-LISP-function&p=38968#post38968

BIGAL 发表于 2022-7-6 08:01:38

如果你把总弧长放在一个规则什么是最大的石头长度用户?然后得到一些块,你应该能够计算出弧长=节点数+块长。一旦你解决了这个问题,很容易将弧长转换为和弦并绘制石块。
 
比如说4个方块=方块长度23“这样可以吗?不试试5,然后画方块。
 
弧长=rad*θ,所以可以算出长度等简单的数学和弦是简单的公式,如果不确定的话,也只是谷歌循环公式。

irneb 发表于 2022-7-6 08:08:21

没有真正需要进行曲线计算。让vlax曲线-*函数为您实现这一点。以下是一个示例:
(vl-load-com)

(setq *SegmentPath:Gap* 0.
   *SegmentPath:GapStart* t
   *SegmentPath:GapEnd* t
   *SegmentPath:MaxLength* 10.)

(defun c:SegmentPath(/ en space len pos dist)
(setq space (apply (if (> (getvar 'cvport) 1)
                      'vla-get-ModelSpace
                      'vla-get-PaperSpace)
                  (list (vla-get-ActiveDocument (vlax-get-acad-object)))))
(while (progn (princ (strcat "\nGap Size: "
                              (rtos *SegmentPath:Gap*)
                              "; Max Length: "
                              (rtos *SegmentPath:MaxLength*)
                              "; "
                              (if *SegmentPath:GapStart*
                              "Gap at start; "
                              "")
                              (if *SegmentPath:GapEnd*
                              "Gap at end; "
                              "")))
               (initget "Gap Max Start End")
               (setq en (entsel "\nPick Path : ")))
   (cond ((eq en "Gap")
          (if (setq en (getdist (strcat "\nEnter gap size <" (rtos *SegmentPath:Gap*) ": ")))
            (setq *SegmentPath:Gap* en)))
         ((eq en "Max")
          (if (setq en (getdist (strcat "\nEnter max length <" (rtos *SegmentPath:MaxLength*) ": ")))
            (setq *SegmentPath:MaxLength* en)))
         ((eq en "Start") (setq *SegmentPath:GapStart* (not *SegmentPath:GapStart*)))
         ((eq en "End") (setq *SegmentPath:GapEnd* (not *SegmentPath:GapEnd*)))
         (t
          (setq en(car en)
                len (vlax-curve-getDistAtParam en (vlax-curve-getEndParam en))
                pos 0.)
          (if *SegmentPath:GapStart*
            (setq pos *SegmentPath:Gap*)
            (setq len (+ len *SegmentPath:Gap*)))
          (if *SegmentPath:GapEnd*
            (setq len (- len *SegmentPath:Gap*)))
          (setq dist (/ len (1+ (fix (/ len (+ *SegmentPath:Gap* *SegmentPath:MaxLength*))))))
          (while (< pos len)
            (vla-AddLine
            space
            (vlax-3d-point (vlax-curve-getPointAtDist en pos))
            (vlax-3d-point (vlax-curve-getPointAtDist en (+ pos (- dist *SegmentPath:Gap*)))))
            (setq pos (+ pos dist))))))
(princ))

fixo 发表于 2022-7-6 08:18:09

@比加尔成功了。谢谢
 
奇怪的是,当我加载AMORT时。LSP今天进入一个新的绘图,程序将初始化,但在“选择最长弧段:”程序终止后没有错误报告。。。昨天我用另一幅画把它画出来了。实际上,我对LSP所做的唯一更改是“选择(长/短)弧段:”在口头上是向后的。此外,我还添加了一个SETVAR,用于重新打开osnaps。我错过什么了吗?
 
__________________________________________阿莫特。lsp;;(vl load com);;获取凸出半径;;Juergen Menzi的数学(defun get radii(p1 p2 bulge)(abs(/(distance p1 p2)2(sin(/(*4(atan(abs bulge)))2 1097;));;-------------------------------------------------------;;(defun ang切线(曲线pnt)(角度'(0 0 0)(trans(vlax curve getFirstDerivcurve(vlax curve getParamAtPoint curve(trans(vlax curve GetClosestPoint to curve pnt)1 0)));;----------------------------------------;;(defun get segments(en-pnt/par)(setq par(vlax curve getParamAtPointen(vlax curve getClosestPointTo en-pnt)))(list(vlax curve getPointAtParam en(fix par))(vlax curve getPointAtParam en(1+(fix par);---------------------------主要部分-------------------------------;;(defun C:Amort(/*error*adoc ang clay curve da en gap i joint leg num p1 e p2 par pe1 pe2 pn ps1 ps2 rad segs sset step stleg th)(defun*error*(msg)(vla endundomark(vla get activedocument(vlax get acad object))(cond((or(not msg)(member msg’(“console break”“Function cancelled”“quit/exit abort”))((princ(strcat”\error:“msg))))(setvar“nomutt”0)(if clay(setvar“clayer”clay))(princ))(setq adoc(vla get activedocument(vlax get acad object))(vla startundomark adoc)(setq clay(getvar“clayer”))(setvar“clayer”“Mortar”);

eric_monceaux 发表于 2022-7-6 08:28:21

BIGAL 发表于 2022-7-6 08:34:03

Re osnaps pretty simple the variable osmode holds current snap value so
 

At start of code do(setq oldsnap (getvar "osmode"))at end of code do(setvar "osmode" oldsnap)

eric_monceaux 发表于 2022-7-6 08:50:07

@BIGAL That worked. Thanks!
 
Oddly enough, when I loaded the AMORT.LSP today into a new drawing, the program would initialize but after "Select Longest Arc Segment:" the program terminates with no error report... I was able to get it to work yesterday, in a different drawing. The only change I actually made to the LSP is the "Select (long/short) Arc Segment:" was verbally backwards. Also I added a SETVAR for turning osnaps back on. Am I missing something?
 

;;__________________________________________Amort.lsp________________________________________________;;(vl-load-com);; get bulge radius;; math by Juergen Menzi(defun get-radii (p1 p2 bulge)(abs (/ (distance p1 p2) 2 (sin (/ (* 4 (atan (abs bulge))) 2)))));;--------------------------------------;;(defun ang-tangent (curve pnt)(angle'(0 0 0)(trans(vlax-curve-getFirstDerivcurve(vlax-curve-getParamAtPoint curve (trans (vlax-curve-getClosestPointTo curve pnt) 1 0)))0 1 T )));;--------------------------------------;;(defun get-segments (en pnt / par)(setq par (vlax-curve-getParamAtPointen(vlax-curve-getClosestPointTo en pnt)))(list (vlax-curve-getPointAtParam en (fix par))(vlax-curve-getPointAtParam en (1+ (fix par)))));;----------------------- main part ----------------------------;;(defun C:Amort(/ *error* adoc ang clay curve da en gap i joint leg num p1 p1e p2 par pe1 pe2 pn ps1 ps2 rad segs sset step stleg th)(defun *error* (msg)(vla-endundomark (vla-get-activedocument(vlax-get-acad-object)))(cond ((or (not msg)(member msg '("console break" "Function cancelled" "quit / exit abort"))))((princ (strcat "\nError: " msg))))(setvar "nomutt" 0)(if clay (setvar "clayer" clay))(princ))(setq adoc (vla-get-activedocument(vlax-get-acad-object)))(vla-startundomark adoc )(setq clay (getvar "clayer"))(setvar "clayer" "Mortar");
页: [1]
查看完整版本: 用直线到C进行圆弧分割