我做了这个函数,使用第一个端点、要生成的维度数和DIMSPACE在两个点之间生成相等的维度。
它看起来像是这张图片顶部显示的内容。我希望它看起来像图片底部的那个(忽略尺寸在上面而不是在下面)。
我可以对我的代码做什么快速的更改来实现这一点。还有其他可以使我的基本代码更简单的更改吗?(不需要)。
代码如下:
- (defun c:holedim()
-
- (setq oldsnap (getvar "osmode"))
- (setq p0 (getpoint "\n pick left endpoint: "))
- (setq pfirst (getpoint "\n pick point of the first hole"))
- (setq plast (getpoint "\n pick point of the last hole"))
- (setq n (getint "Enter number of holes: "))
- (setq dimspacingy (getreal "Enter dimspacing value: "))
- (setq p0x (car p0))
- (setq pfirstx (car pfirst))
- (setq plastx (car plast))
- (setq p0y (cadr p0))
- (setq pfirsty (cadr pfirst))
- (setq plasty (cadr plast))
- (setq pnx pfirstx)
- (setq pny pfirsty)
- (setq pn pfirst)
- (setq dimoffsetx (/ (- plastx pfirstx) (- n 1.0)))
- (setq halfdimoffsetx (/ dimoffsetx 2.0))
- (setq dim1x (/ (+ p0x pfirstx) 2.0))
- (setq dim1y (+ pfirsty dimspacingy))
- (setq dimnx dim1x)
- (setq dimny dim1y)
- (setq dimn (list dimnx dimny))
- (setvar "osmode" 0)
- (repeat n
- (command "dimlinear" p0 pn dimn)
- (setq dimnx (+ pnx halfdimoffsetx))
- (setq dimny (+ dimny dimspacingy))
- (setq dimn (list dimnx dimny))
- (setq pnx (+ pnx dimoffsetx))
- (setq pn (list pnx pny))
- )
- (setvar "osmode" oldsnap)
- (princ)
- )
|