kasra Posted April 16, 2010 Posted April 16, 2010 Hi. Is there a solution(s) to find out that there is an intersection between a line with a lwpline????? I know that it should be checked all entities of lwpline for existance of intersection with a line. but, cause i 'm new in programming, it's difficult for me to get entities of lwpline one after another. please guide me how i can check one by one??? Thank you for pay attention. Quote
Lee Mac Posted April 16, 2010 Posted April 16, 2010 Try this: ;; Finds all Intersections between obj1 & obj2 ;; Args: obj1,obj2 ;; VLA-Objects with Intersectwith method available ;; Returns: List of Intersections (or nil) (defun GetIntersections (obj1 obj2 / GroupByNum) ;; Lee Mac ~ 16.04.10 (defun GroupByNum (lst num / rtn) (setq rtn nil) (if lst (cons (reverse (repeat num (progn (setq rtn (cons (car lst) rtn) lst (cdr lst)) rtn))) (GroupByNum lst num)))) (GroupByNum (vlax-invoke obj1 'IntersectWith obj2 acExtendNone) 3)) Test Function: (defun c:test (/ e1 e2) (vl-load-com) (if (apply (function and) (mapcar (function (lambda (str sym) (set sym (car (entsel str))))) '("\nSelect First Object: " "\nSelect Second Object: ") '(e1 e2))) (print (apply (function GetIntersections) (mapcar (function vlax-ename->vla-object) (list e1 e2))))) (princ)) Quote
Lee Mac Posted April 16, 2010 Posted April 16, 2010 Another, for a Selection Set: (defun Get_Inters (ss / GroupByNum i j obj1 obj2 iLst) ;; Lee Mac ~ 19.01.10 (defun GroupByNum (lst num / rtn) (setq rtn nil) (if lst (cons (reverse (repeat num (progn (setq rtn (cons (car lst) rtn) lst (cdr lst)) rtn))) (GroupByNum lst num)))) (setq i (sslength ss)) (while (not (minusp (setq j (1- i) i (1- i)))) (setq obj1 (vlax-ename->vla-object (ssname ss i))) (while (not (minusp (setq j (1- j)))) (setq obj2 (vlax-ename->vla-object (ssname ss j))) (setq iLst (append iLst (GroupByNUm (vlax-invoke obj1 'IntersectWith obj2 acExtendNone) 3))))) iLst) Test Function: (defun c:test (/ ss x) (vl-load-com) (if (setq ss (ssget)) (foreach x (Get_Inters ss) (command "_.point" "_non" x))) (princ)) Quote
kasra Posted April 16, 2010 Author Posted April 16, 2010 Hi Dear Lee Mac. I should test your post in my routine. I'll tell the result after that. thanks for ur helping. Quote
kasra Posted June 20, 2012 Author Posted June 20, 2012 Hi. I have a problem with this Lisp-command (vlax-invoke obj1 'IntersectWith obj2 acExtendNone) to finding the intersection point between 2 objects that do not intersect with each other in drawing, but if i strech one to the other one, it can find the point. Isn't it possibleto find the point with this command? Thanks for helping. Quote
Lee Mac Posted June 20, 2012 Posted June 20, 2012 Investigate the ExtendOption parameter of the IntersectWith method: IntersectWith Method Gets the points where one object intersects another object in the drawing. ... ... ExtendOption AcExtendOption enum; input-only This option specifies if none, one or both, of the objects are to be extended in order to attempt an intersection. acExtendNone Does not extend either object. acExtendThisEntity Extends the base object. acExtendOtherEntity Extends the object passed as an argument. acExtendBoth Extends both objects. Quote
MSasu Posted June 20, 2012 Posted June 20, 2012 You should replace acExtendNone with either acExtendBoth, acExtendThisEntity or acExtendOtherEntity. Quote
kasra Posted June 20, 2012 Author Posted June 20, 2012 Thank you. I got the solution. What references you suggest for studing about all options of all method? Quote
Lee Mac Posted June 20, 2012 Posted June 20, 2012 What references you suggest for studing about all options of all method? Visual LISP IDE Help Docs: http://lee-mac.com/functioninfo.html Quote
kasra Posted June 20, 2012 Author Posted June 20, 2012 Ok. Thanx a lot. I will try it before any request. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.