4
21
18
初来乍到
使用道具 举报
106
1万
101
顶梁支柱
(defun c:Test1 (/ ent lst) (if (and (setq toLine (vlax-ename->vla-object (car (entsel "\nSelect Line: ")))) (setq p1 (getpoint "\nSpecify First Point: ")) (setq p2 (getpoint "\nSpecify Second Point: " p1)) (setq ss (apply 'ssget (append (list "_C") (mapcar '(lambda (foo) (apply 'mapcar (cons foo (list p1 p2)))) '(min max) ) (list '((0 . "*LINE"))) ) ) ) (setq lst0 ((lambda (l / i) (setq i (lm:getobjintersectionsinss l ss)) (vla-delete l) i ) (vlax-ename->vla-object (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2))) ) ) ) ) (progn (setq lst1 (mapcar 'cons (mapcar 'cadr (ssnamex ss)) lst0)) (setq i 0) (repeat (sslength ss) (setq e (ssname ss i)) (setq lst (cadr (at:segment int_f))) (setq Pintobj (LM:GetIntersections toLine (vlax-ename->vla-object e) ) ) (vl-cmdf "_.stretch" ss "" "_non" (trans lst 0 1) (trans (car Pintobj) 0 1) ) (setq i (1+ i)) ) ) ) (princ))(defun lm:getobjintersectionsinss (obj ss) ;; © Lee Mac 2010 ((lambda (i / j a b ilst) (while (setq e (ssname ss (setq i (1+ i)))) (setq ilst (append ilst (lm:groupbynum (vlax-invoke obj 'intersectwith (vlax-ename->vla-object e) acextendnone ) 3 ) ) ) ) ) -1 ))(defun AT:Segment (entPnt) ;; Retreive segment number and Start & End points ;; entPnt - List with entity (ENAME or VLA-OBJECT) & point ;; Alan J. Thompson, 11.10.09 / 08.19.10 / 11.15.11 (if (vl-consp entPnt) ((lambda (e p / n) (if (setq n (vlax-curve-getPointAtParam e (1+ p))) (list p (list (vlax-curve-getPointAtParam e p) n)) (list p (list (vlax-curve-getPointAtParam e (1- p)) (vlax-curve-getPointAtParam e p))) ) ) (car entPnt) (fix (vlax-curve-getParamAtPoint (car entPnt) (vlax-curve-getClosestPointToProjection (car entPnt) (trans (cadr entPnt) 1 (car entPnt)) '(0. 0. 1.) ) ) ) ) ))
(defun c:Test2 (/ toLine p1 p2 ss lst0 lst1 Pintobj vtx_pline list_vtx_pline) (if (and (setq toLine (vlax-ename->vla-object (car (entsel "\nSelect Line: "))) ) (setq p1 (getpoint "\nSpecify First Point: ")) (setq p2 (getpoint "\nSpecify Second Point: " p1)) (setq ss (apply 'ssget (append (list "_C") (mapcar '(lambda (foo) (apply 'mapcar (cons foo (list p1 p2)))) '(min max) ) (list '((0 . "*LINE"))) ) ) ) (setq lst0 ((lambda (l / i) (setq i (lm:getobjintersectionsinss l ss)) (vla-delete l) i ) (vlax-ename->vla-object (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2)) ) ) ) ) ) ;_and (progn ;; Find intersection between line and selection (setq Pintobj (lm:getobjintersectionsinss toLine ss)) ;;(princ Pintobj) ;_for testing (setq cadrm (mapcar 'cadr (ssnamex ss))) ;; Make list (ename point_intersection) (setq lst1 (mapcar 'list cadrm lst0)) (foreach n lst1 (setq p (fix (vlax-curve-getparamatpoint (car n) (vlax-curve-getclosestpointtoprojection (car n) (trans (cadr n) 1 0) '(0.0 0.0 1.0) ) ) ) ) ;_setq p (setq vtx_pline (list (trans (vlax-curve-getpointatparam (car n) p) 0 1) ) ) ;;(princ vtx_pline) ;_for testing (setq list_vtx_pline (append list_vtx_pline vtx_pline)) ;_This is Start point of Selected Segment PLINES as base point of STRETCH: ) ;_foreach ;;(princ list_vtx_pline) ;_for testing (setq data (mapcar 'list cadrm list_vtx_pline pintobj)) (foreach m data (vl-cmdf "_.stretch" (car m) "" "_non" (cadr m) (caddr m) ) ) ) ;_progn ) ;_if (princ)) ;_defun(defun lm:getobjintersectionsinss (obj ss) ;; © Lee Mac 2010 ((lambda (i / j a b ilst) (while (setq e (ssname ss (setq i (1+ i)))) (setq ilst (append ilst (lm:groupbynum (vlax-invoke obj 'intersectwith (vlax-ename->vla-object e) acextendnone ) 3 ) ) ) ) ) -1 ));; Author: Lee Mac, Copyright © 2010 - www.lee-mac.com ;;(defun LM:GroupByNum (l n / r) (if l (cons (reverse (repeat n (setq r (cons (car l) r) l (cdr l)