RepCad Posted October 4, 2022 Posted October 4, 2022 (edited) Hello everyone, I'm trying to use Select Fence to get circles that have intersected with 3DPolyline by AutoLisp but there is a problem that circles and the 3DPolyline are on different elevation. The circle's elevation can be between 0.0 and the 3DPolyline or on the 3DPolyline. Is it possible to obtain circles programmatically without making changes on whole drawings of the file? (I mean without using flatten command because it cause changes on 3DPolyline's property like Length) Thanks in advance. Sample21.dwg Edited October 4, 2022 by RepCad Quote
Steven P Posted October 4, 2022 Posted October 4, 2022 what is the LISP code you are using to get the selection? Post that to if you can 1 Quote
RepCad Posted October 4, 2022 Author Posted October 4, 2022 5 minutes ago, Steven P said: what is the LISP code you are using to get the selection? Post that to if you can Yes sure : (defun c:test () (setq lateral (car (entsel "Please select a 3DPolyline :"))) (setq pts (pline_points lateral)) (setq ss (ssget "_F" pts '((0 . "ellipse,circle")))) (sssetfirst nil ss) ) (defun pline_points (e / i r) (repeat (1+ (setq i (fix (vlax-curve-getendparam e)))) (setq r (cons (vlax-curve-getpointatparam e i) r) i (1- i) ) ) r ) Quote
Emmanuel Delay Posted October 4, 2022 Posted October 4, 2022 (edited) I'm not sure if I understand what you want. Here's a Front view. Those are (normal 2D) polylines, not 3D polylines. And the way I see it only the top circles touch the polyline. The rest don't intersect. Care to further elaborate what you want? Edit: there's a thing called apparent intersection. that's when a projection of the drawing has things intersecting. Is ahat something you want? Edited October 4, 2022 by Emmanuel Delay 1 Quote
RepCad Posted October 4, 2022 Author Posted October 4, 2022 10 minutes ago, Emmanuel Delay said: I'm not sure if I understand what you want. Here's a Front view. Those are (normal 2D) polylines, not 3D polylines. And the way I see it only the top circles touch the polyline. The rest don't intersect. Care to further elaborate what you want? Edit: there's a thing called apparent intersection. that's when a projection of the drawing has things intersecting. Is ahat something you want? Sorry, the attached file was wrong, I have updated it. Quote
Emmanuel Delay Posted October 4, 2022 Posted October 4, 2022 The problem with this last drawing you uploaded is that zero polylines truly intersect with any circle. I moved 5 circles to truly intersect with a polyline and re-uploaded the drawing. You can find out which with my routine here below. Command SFP. (vl-load-com) ;; Intersections - Lee Mac ;; http://www.lee-mac.com/intersectionfunctions.html ;; Returns a list of all points of intersection between two objects ;; for the given intersection mode. ;; ob1,ob2 - [vla] VLA-Objects ;; mod - [int] acextendoption enum of intersectwith method ;; acextendnone Do not extend either object ;; acextendthisentity Extend obj1 to meet obj2 ;; acextendotherentity Extend obj2 to meet obj1 ;; acextendboth Extend both objects (defun LM:intersections ( ob1 ob2 mod / lst rtn ) (if (and (vlax-method-applicable-p ob1 'intersectwith) (vlax-method-applicable-p ob2 'intersectwith) (setq lst (vlax-invoke ob1 'intersectwith ob2 mod)) ) (repeat (/ (length lst) 3) (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn) lst (cdddr lst) ) ) ) (reverse rtn) ) ;;;;;;;;;;;;;;;;;;;; ;; how to grip elements: ;;;; make an empty pickset ;; (setq pickset1 (ssadd)) ;;;; add ssget elements 1 by one ;; (ssadd (ssname ss 1) pickset1) ;; (ssadd (ssname ss 2) pickset1) ;; ... ;;;; then grip the pickset ;; (sssetfirst nil pickset1) ;; SFP for Select Fence Problem (defun c:SFP ( / plines_3d circles i j pickset1 ins skip) (setq pickset1 (ssadd)) (princ "\nSelect 3D Polylines: ") (setq plines_3d (ssget (list (cons 0 "POLYLINE,LWPOLYLINE")))) ;; maybe add this group? ;;(setq plines_3d (ssget (list (cons 0 "POLYLINE,LWPOLYLINE") (cons 100 "AcDb3dPolyline") ))) (princ "\nSelect Circles: ") (setq circles (ssget (list (cons 0 "CIRCLE,ELLIPSE")))) ;; double loop over all 3D poly and circles. ;; check for each pair if they intersect. (setq j 0) (repeat (sslength circles) (setq skip nil) ;; once we find 1 intersect point we can skip looking at the other polylines, for that circle (setq ob2 (ssname circles j)) (setq i 0) (repeat (sslength plines_3d) (if (not skip) (progn (setq ob1 (ssname plines_3d i)) (setq ins (LM:intersections (vlax-ename->vla-object ob1) (vlax-ename->vla-object ob2) acextendnone )) ;; now if this pair intersects we add the circle to the picklist (if (> (length ins) 0) (progn (setq skip T) (ssadd (ssname circles j) pickset1) )) )) (setq i (+ i 1)) ) (setq j (+ j 1)) ) (sssetfirst nil pickset1) (princ (strcat "\n" (itoa (sslength pickset1)) " circles selected") ) (princ) ) select-fence-problem.dwg 2 Quote
RepCad Posted October 4, 2022 Author Posted October 4, 2022 6 hours ago, Emmanuel Delay said: The problem with this last drawing you uploaded is that zero polylines truly intersect with any circle. I moved 5 circles to truly intersect with a polyline and re-uploaded the drawing. You can find out which with my routine here below. Command SFP. (vl-load-com) ;; Intersections - Lee Mac ;; http://www.lee-mac.com/intersectionfunctions.html ;; Returns a list of all points of intersection between two objects ;; for the given intersection mode. ;; ob1,ob2 - [vla] VLA-Objects ;; mod - [int] acextendoption enum of intersectwith method ;; acextendnone Do not extend either object ;; acextendthisentity Extend obj1 to meet obj2 ;; acextendotherentity Extend obj2 to meet obj1 ;; acextendboth Extend both objects (defun LM:intersections ( ob1 ob2 mod / lst rtn ) (if (and (vlax-method-applicable-p ob1 'intersectwith) (vlax-method-applicable-p ob2 'intersectwith) (setq lst (vlax-invoke ob1 'intersectwith ob2 mod)) ) (repeat (/ (length lst) 3) (setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn) lst (cdddr lst) ) ) ) (reverse rtn) ) ;;;;;;;;;;;;;;;;;;;; ;; how to grip elements: ;;;; make an empty pickset ;; (setq pickset1 (ssadd)) ;;;; add ssget elements 1 by one ;; (ssadd (ssname ss 1) pickset1) ;; (ssadd (ssname ss 2) pickset1) ;; ... ;;;; then grip the pickset ;; (sssetfirst nil pickset1) ;; SFP for Select Fence Problem (defun c:SFP ( / plines_3d circles i j pickset1 ins skip) (setq pickset1 (ssadd)) (princ "\nSelect 3D Polylines: ") (setq plines_3d (ssget (list (cons 0 "POLYLINE,LWPOLYLINE")))) ;; maybe add this group? ;;(setq plines_3d (ssget (list (cons 0 "POLYLINE,LWPOLYLINE") (cons 100 "AcDb3dPolyline") ))) (princ "\nSelect Circles: ") (setq circles (ssget (list (cons 0 "CIRCLE,ELLIPSE")))) ;; double loop over all 3D poly and circles. ;; check for each pair if they intersect. (setq j 0) (repeat (sslength circles) (setq skip nil) ;; once we find 1 intersect point we can skip looking at the other polylines, for that circle (setq ob2 (ssname circles j)) (setq i 0) (repeat (sslength plines_3d) (if (not skip) (progn (setq ob1 (ssname plines_3d i)) (setq ins (LM:intersections (vlax-ename->vla-object ob1) (vlax-ename->vla-object ob2) acextendnone )) ;; now if this pair intersects we add the circle to the picklist (if (> (length ins) 0) (progn (setq skip T) (ssadd (ssname circles j) pickset1) )) )) (setq i (+ i 1)) ) (setq j (+ j 1)) ) (sssetfirst nil pickset1) (princ (strcat "\n" (itoa (sslength pickset1)) " circles selected") ) (princ) ) select-fence-problem.dwg 104.12 kB · 1 download Great , Thank you for spend your time on my project. 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.