向左或向右偏移距离
嗨,我知道一点autolisp,但现在我想学习vlispim目前正在使用autolisp程序计算桩号和偏移量
但抵消都是积极的。我想让程序知道偏移是在多段线的左侧还是右侧。如果点位于左侧而右侧为正,则应显示负偏移值。
这是代码(我不记得我在哪个论坛复制了这段代码,但信用卡
转到func中提到的Jeff Mishler。
(defun c:sta-off (/ endpt ent off offpt onpt ss sta startpt)
;; Marker for point location on the screen
;; Oct. 2004 by Jeff Mishler
(defun Xmarksthespot (x y / leglen start)
(setq start (list x y)
leglen (* 0.03 (getvar "viewsize"))
)
(grdraw (polar start (angtof "135" 1) leglen)
(polar start (angtof "315" 1) leglen)
7)
(grdraw (polar start (angtof "45" 1) leglen)
(polar start (angtof "225" 1) leglen)
7)
)
(while (setq ss (ssget "" '((0 . "LINE,*POLYLINE,SPLINE,ARC"))))
(setq ent (ssname ss 0))
(setq startpt (vlax-curve-getstartpoint ent)
endpt (vlax-curve-getendpoint ent)
)
(xmarksthespot (car startpt)(cadr startpt))
(while (setq offpt (getpoint "\nOffset point: "))
(setq onPt (vlax-curve-getclosestpointto ent offpt)
sta (vlax-curve-getdistatpoint ent onpt)
off (distance onpt offpt)
)
(princ (strcat "Station: " (rtos sta 2 2) " - Offset: " (rtos off 2 2)))
)
(redraw)
)
(princ)
)
帮助任何人?
谢谢
Ger Aven公司 欢迎来到CADTutor
首先,请阅读您帖子中关于格式化代码的说明,并相应地编辑您的帖子。
对不起,我没有看说明书,谢谢李
这是上面代码的示例输出,
偏移点:桩号:5.2397-偏移:4.8319
偏移点:桩号:7.4596-偏移:4.4995
我在多段线左侧选取了一个点,其值为正4.8319
然后我选择右边的值为正4.4995
我希望程序为在路线多段线左侧拾取的点提供负偏移值
谢谢 您可能需要查看拾取点任一侧的pline的两个点,并比较角度,以确定其左侧或右侧的距离仅返回+ve值。这里有各种各样的东西,都是关于象限的,你的角度在零角的两边。
ang1为pt1-pt2
ang2 pt1拾取pt
如果ang2大于ang1-ve?
请记住,柱脚可以在任何方向绘制,但返回点位于创建方向。
最后一个想法是查看一些链测标签LISP,它们可能有答案。 谢谢Bigal
我在看这段代码,看看从哪里开始,
(defun AT:AngleAtPoint (e p)
;; Return angle along curve, at specified point (on curve)
;; e - valid curve (ENAME or VLA-OBJECT)
;; p - point on curve
;; Alan J. Thompson, 11.04.10
(angle '(0. 0. 0.) (vlax-curve-getFirstDeriv e (vlax-curve-getParamAtPoint e p)))
) 就我做事的方式而言,几条建议节省了一些打字时间
rather than (angtof "45" 1) use just45ang
in autoload lisp have the common values all preset 45 90 270 etc
(setq 45ang (/ pi() 4.0))
If only selecting one object maybe use entsel rather than ssget can still check if its line arc pline
还可以查看RTD和DTR非常常见的LISP
页:
[1]