画大样时,一般都是从轮廓偏移画线筋,然后画点筋。如果能一键生成简单轮廓的线筋和点筋,再配合点线筋标注命令,就能快速画大样了。对此功能,我一直想实现,在春节假期,终于了此心愿了。简单效果如下:
针对功能,首先是偏移画线筋,然后是偏移画点筋。画线筋主要是两端缩进,然后偏移即可。
缩进采用构造一个选择,执行lengthen命令。
(if (not nosj)
(progn
(command "lengthen" "DE" (- hnu:barscale) (list en pt0) )
(command "")
(command "lengthen" "DE" (- hnu:barscale) (list en pt1) )
(command "")
));if nosj
一般的,可以用如下语句,采用命令获取首末点:
;需要修正不偏移的线筋长度
(if nopy
(progn
(command "lengthen" "DE" (+ offlen1) (list en (wtou (vlax-curve-getStartPoint en))))
(command "")
(command "lengthen" "DE" (+ offlen1) (list en (wtou (vlax-curve-getEndPoint en))))
(command "")
)
);
对于画点筋,则区分为端点和中部点筋,除非尺寸较短,否则端点均设置点筋:通过距离判断裁剪掉不满足的首末点即可。
(defun endhasbarp(ptlist / pt pt1 dist L )
(if (>= hnu:barscale 100) (setq dist (* 4 hnu:barscale));>=1:100,放大四倍作图;其他一比一作图
(setq dist 200);间距200,插入一点
)
(if (>= (length ptlist) 3)
(progn
(setq pt (car ptlist) pt1 (cadr ptlist) )
(setq L (distance pt pt1))
(if (< L (* 0.5 dist)) (setq ptlist (cdr ptlist)));if修正首
(setq ptlist(reverse ptlist))
(setq pt (car ptlist) pt1 (cadr ptlist) )
(setq L (distance pt pt1))
(if (< L (* 0.5 dist)) (setq ptlist (cdr ptlist)));if修正尾
(setq ptlist(reverse ptlist))
));if >=3 修正点表
(foreach pt ptlist
(make_circle_pline pt (* 0.25 hnu:barscale) (getvar 'clayer) (* 0.5 hnu:barscale))
);foreach
)
对于中部是否设置点筋,直接采用特征间距(大样一比一画图时,默认采用200)判断数量,然后再根据数量求出实际间距。可以使用递归函数,本函数也将递归优化为循环,
(defun midhasbarp(ptlist / pt pt1 ptm ang L dist i len1)
(if (>= hnu:barscale 100) (setq dist (* 4 hnu:barscale));>=1:100,放大四倍作图;其他一比一作图
(setq dist 200);间距200,插入一点
)
(while (> (length ptlist) 1)
;(princ)
;(progn
(setq pt (car ptlist) ptlist (cdr ptlist) )
(setq pt1 (car ptlist) ang (angle pt pt1) L (distance pt pt1))
(if (>= L (* 1.5 dist))
(progn
(setq n (fix (+ 0.4 (/ L dist))) );5舍6入,+0.4
(setq len1 (/ L n) i 1)
(repeat (1- n);插入点数比段数少1
(setq ptm (polar pt ang (* i len1)))
(make_circle_pline ptm (* 0.25 hnu:barscale) (getvar 'clayer) (* 0.5 hnu:barscale))
(setq i (1+ i))
);repeat
);progn
);if L> dist
;(midhasbarp ptlist)
;);progn
;);if length>1
);while
)
Last Modified·2022年2月8日 15:33
您尚未登录,请先登录才能评论。