Bill Tillman 发表于 2022-7-5 16:32:32

LISP代码绘制一条直线

我用LISP程序创建了附加文件来绘制楼梯梯边梁。我一直在试图找出如何添加所示尺寸,即纵梁的总长度。
 
手动执行此操作时,我从梯边梁底部创建一条与梯边梁顶线垂直的短线,然后从两个外部点进行DIMALIGN。当我试着画短线段时,我总是碰到一个方块。
我还沿着顶线在spt1和spt2之间画了一条临时线,并试图将其作为垂直度的目标,但它并不像我希望的那样结合在一起。
PerDimLisp。图纸

Bill Tillman 发表于 2022-7-5 16:51:09

我想出了一个使用小三角的方法,但想知道是否还有其他聪明的想法如何做到这一点。

Grrr 发表于 2022-7-5 16:56:06

例如:

(and
(setq p1 (getpoint "\nFirst point"))
(setq p2 (getpoint p1 "\nSecond point"))
(progn
   (redraw)
   (grdraw p1 p2 1)                ; draw your line in red
   (grdraw                         ; draw the perpendicular line in yellow
   p1                            ; starting from p1
   (polar                        ; calculate the 2nd point
       p1                        ; starting from p1
       (+ (angle p1 p2) (/ PI 2.)) ; perpendicular angle, Pi/2 = 90 deg
       (distance p1 p2)            ; distance, same as the original line
   ); polar
   2
   ); grdraw
); progn
); and

BIGAL 发表于 2022-7-5 17:08:36

也可能是vl闭合点,其也为90,即使另一条线不平行,并给出一个pt,您可以使用align 2 pt用于dim。

Grrr 发表于 2022-7-5 17:21:31

BIGAL是对的,使用vlax curve getClosestPointTo更容易,并且避免了计算角度(当您已经绘制了线时)。
要可视化结果,请使用grread:

(defun C:test ( / e grr Stop )
(if (setq e (car (entsel "\nSelect line, or curve: ")))
   (while (not Stop)
   (setq grr (grread T))
   (cond
       ( (= (car grr) 25) (setq Stop T) )
       ( (= (car grr) 5) (redraw) (grdraw (cadr grr) (vlax-curve-getClosestPointTo e (cadr grr) T) 2) )
       ( (= (car grr) 3)
         (entmakex
         (list (cons 0 "LINE") (cons 10 (cadr grr)) (cons 11 (vlax-curve-getClosestPointTo e (cadr grr) T)) )
         )
         (setq Stop T)
       )
   ); cond                       
   ); while
); if
(princ)
); defun

tombu 发表于 2022-7-5 17:24:06

另请参见:http://www.cadtutor.net/forum/showthread.php?94266-最近点到线自点&p=646114&viewfull=1#post646114
和http://forums.augi.com/showthread.php?149591-垂直-2D-snap-to-line&p=1228990&viewfull=1#post1228990线程我开始了,并得到了很大的帮助。

rkent 发表于 2022-7-5 17:39:40

将UCS旋转到对象,标注,将UCS更改回世界。我已经为UCS设置了一个对象。UW为UCS、World建立。非常快速和简单,我一直在使用这些。我在我的个人快捷键中列出了一些设置。lsp。
 
3
页: [1]
查看完整版本: LISP代码绘制一条直线