本帖最后由 自贡黄明儒 于 2022-4-14 11:49 编辑
PCCAD V21的(osnap p "CEN")不起任何作用,与2K相比还有不少差距(但是此国产软件便宜,作为上市公司推行正版),于是只能计算圆心。以往发过计算圆心的函数,希望这个更成熟。
- ;;[获取圆心]无圆心返回nil
- (defun HH:GetCenter2 (curve P / EP PARAM PP SP)
- (setq pp (vlax-curve-getclosestpointto curve (trans p 1 0)))
- (setq Param (vlax-curve-GetParamAtPoint curve PP))
- (if (equal (vlax-curve-getsecondderiv curve Param)
- '(0.0 0.0 0.0)
- );直线
- nil
- (progn
- (if (<= (- Param 0.0001) (vlax-curve-GetStartParam curve))
- (progn
- (setq Param (+ Param 0.0001))
- (setq pp (vlax-curve-GetPointAtParam curve Param))
- )
- )
- (if (>= (+ Param 0.0001) (vlax-curve-GetEndParam curve))
- (progn
- (setq Param (- Param 0.0001))
- (setq pp (vlax-curve-GetPointAtParam curve Param))
- )
- )
- (setq sp (vlax-curve-getPointAtParam curve (- Param 0.0001)))
- (setq Ep (vlax-curve-getPointAtParam curve (+ Param 0.0001)))
- (if (wcmatch (getvar "AcadVer") "*BricsCAD*") ; PCCAD
- (mapcar '+ pp (vlax-curve-getsecondderiv curve Param))
- (if
- (minusp (car (trans (mapcar '- pp Ep) 0 (mapcar '- Ep sp)))) ;顺时针为T
- (mapcar '+ pp (vlax-curve-getsecondderiv curve Param))
- (mapcar '- pp (vlax-curve-getsecondderiv curve Param))
- )
- )
- )
- )
- )
|