1. ;;说明:管接头放样线归置
    2. (defun C:MYM(/ bf-pickset->list bf-translation isptinrectang lss pss pt1 pt2)
    3. (defun BF-Translation (p0 p1 / v)
    4. (setq v (mapcar '- p1 p0))
    5. (list
    6. (list 1. 0. 0. (float (car v)))
    7. (list 0. 1. 0. (float (cadr v)))
    8. (list 0. 0. 1. (float (caddr v)))
    9. (list 0. 0. 0. 1.)
    10. )
    11. )
    12. (defun IsPtInRectang(p1 p2 p) (vl-every '>= (mapcar '* (mapcar '- p p1) (mapcar '- p2 p)) '(0 0)))
    13. (defun BF-pickset->list (SS / bf-enamep) (defun BF-enamep (arg) (equal (type arg) 'ename)) (vl-remove-if-not 'BF-enamep (mapcar 'cadr (ssnamex SS))))
    14. (if (and (setq pt1 (getpoint "\n指定第一个角点:")) (setq pt2 (getcorner pt1 "指定第二个角点,确保移动点在框内:")) (princ "\n请选择需要放置的直线:") (setq lss (ssget '((0 . "LINE")))) (princ "\n请框选放置点:") (setq pss (ssget '((0 . "POINT")))))
    15. (progn
    16. (setq lss (BF-pickset->list lss) lss (vl-sort lss (function (lambda(e1 e2) (< (cadr (assoc 10 (entget e1))) (cadr (assoc 10 (entget e2))))))))
    17. (setq pss (BF-pickset->list pss) pss (vl-sort pss (function (lambda(e1 e2) (< (cadr (assoc 10 (entget e1))) (cadr (assoc 10 (entget e2))))))))
    18. (mapcar
    19. (function
    20. (lambda(l p)
    21. (setq mat (vlax-make-safearray vlax-vbDouble '(0 . 3) '(0 . 3)) edata (entget l) d10 (cdr (assoc 10 edata)) d11 (cdr (assoc 11 edata)))
    22. (vlax-safearray-fill
    23. mat
    24. (BF-Translation
    25. (if (IsPtInRectang pt1 pt2 d10) d10 d11)
    26. (cdr (assoc 10 (entget p)))
    27. )
    28. )
    29. (vla-TransformBy (vlax-ename->vla-object l) mat)
    30. )
    31. )
    32. lss
    33. pss
    34. )
    35. )
    36. )
    37. (prin1)
    38. )

    录制_2022_04_15_09_07_01_293.gif