maahee Posted March 20 Posted March 20 (edited) (defun c:Bdry () ; Get all polylines selected by the user (setq ss (ssget '((0 . "LWPOLYLINE")))) ; Filter for polylines (setq points '()) ; Check if any polylines were selected (if ss (progn ; Get the number of selected polylines (setq n (sslength ss)) (setq p 0) ; Loop through each selected polyline (repeat n (setq k (ssname ss p)) ; Get the selected polyline (setq m (entget k)) ; Get the entity list for the selected polyline (setq b (append m (list (assoc 10 m)))) (foreach y b (if (= (car y) 10) (progn (setq points (append points (list (cdr y)))) ; Get the vertex list (points) ;(setq bl (vlax-invoke k intersectWith (vlax-ename->vla-object entnext) acextendnone))) ); end progn ) ; end if ) ; end foreach (setq p (+ p 1)) ; Increment polyline index ) ; end repeat (if points (progn ; Draw the new polyline from the collected points (command "pline") (foreach pt points (command pt) ; Add points to the polyline command ) (command "") ; End the polyline command ) ) ; end if points ) ; end progn ) ; end if ) Try to intersect each polyline, then break it at the intersecting point connect all point vertexes, and intersect the point, I can not replace repeat function to foreach function BOUNDARY.pdfFetching info... Edited March 20 by maahee Quote
BIGAL Posted March 20 Posted March 20 (edited) Easy solution NO CODE, draw a closed pline around your shapes, Type Bpoly, pick point between shapes and out side pline, a pline around outside of shapes should be there now erase outer plines, yes plines as bpoly adds one to outside. Edited March 20 by BIGAL 1 Quote
ronjonp Posted Friday at 07:42 PM Posted Friday at 07:42 PM (edited) https://www.lee-mac.com/outlineobjects.html Or manually change all rectangles to regions then use the union command. Edited Friday at 07:43 PM by ronjonp 1 Quote
maahee Posted Saturday at 01:30 PM Author Posted Saturday at 01:30 PM (edited) On 3/20/2025 at 2:12 PM, GLAVCVS said: Hi Maahee It's better if you attach a drawing Expand (defun c:kol () (setq p1 (getpoint "\nSpecify the bottom-left corner point: "));; Prompt user to specify the bottom-left corner point (setq p2 (getpoint p1 "\nSpecify the top-right corner point: "));; Prompt user to specify the top-right corner point (setq f (ssget "w" p1 p2 '((0 . "LWPOLYLINE,circle,arc")))) ;; f selection set (setq ssadd pt) (command "RECTANGLE" p1 p2) ;; Create a rectangle using the RECTANGLE command (setq pt (entlast)) ;create selection set (setq m (polar p1 (* pi 1.75) 1));; point pick inside the rect (setq ssadd bm) (command "_.boundary" "a" "b" "n" f pt "" "" m "") ;; Create boundary command (setq bm (entlast));create selection set (setq p (ssget "-w-p" p1 p2 '((0 . "LWPOLYLINE"))));;; Create a rectangle using the RECTANGLE command remove f setectiol set from p (command "_.erase" pt "" );; erase a rectangle (ssdel f p) (command "_.erase" P) ;; erase a p sset ) (setq f (ssget "w" p1 p2 '((0 . "LWPOLYLINE,circle,arc")))) (setq p (ssget "-w-p" p1 p2 '((0 . "LWPOLYLINE")))) remove the f selection set from the p selection set then delete the p selection set both having the same entity except the rectangle. Drawing100.dwgFetching info... Edited Saturday at 02:16 PM by maahee Quote
BIGAL Posted Saturday at 11:45 PM Posted Saturday at 11:45 PM Just an idea for internal boundaries, not just one, if you make a list of ((area1 ent1)(area2 ent2)...) you can sort on areas the only one to keep is the second largest area, you have entity names so can erase all the others. Have a go plenty here will help if you get stuck. 1 Quote
GLAVCVS Posted Sunday at 01:02 AM Posted Sunday at 01:02 AM (edited) @maahee Are you sure that this point '(polar p1 (* pi 1.75) 1))' will lie inside the rectangle? Edited Sunday at 01:02 AM by GLAVCVS 1 Quote
GLAVCVS Posted Sunday at 01:05 AM Posted Sunday at 01:05 AM Shouldn't it be better, for example, '(polar p1 0.79 1))'? 1 Quote
GLAVCVS Posted Sunday at 02:15 PM Posted Sunday at 02:15 PM Another thing to keep in mind is that calculating a point just 1 drawing unit from the bottom corner of the rectangle may cause "boundary" to not work correctly. You may want to calculate that point by applying the drawing distance equivalent to one pixel. 1 Quote
GLAVCVS Posted Sunday at 02:22 PM Posted Sunday at 02:22 PM You can calculate this using: (/ (getvar "VIEWSIZE") (cadr (getvar "SCREENSIZE"))) 1 Quote
GLAVCVS Posted Sunday at 03:00 PM Posted Sunday at 03:00 PM And one last thing: you can't use 'ssadd' as a variable. It's a reserved word in the language. Quote
maahee Posted Monday at 06:50 AM Author Posted Monday at 06:50 AM (edited) On 3/23/2025 at 1:05 AM, GLAVCVS said: Shouldn't it be better, for example, '(polar p1 0.79 1))'? Expand (setq p1 (getpoint "\nSpecify the corner point: ")) ;; Prompt user to specify the corner point (setq p2 (getcorner p1 "\nSpecify the corner point: ")) ;; Prompt user to specify the corner point (setq m (polar p1 (angle p1 p2) 5)) try to keep the point always inside the rectangle On 3/22/2025 at 11:45 PM, BIGAL said: Just an idea for internal boundaries, not just one, if you make a list of ((area1 ent1)(area2 ent2)...) you can sort on areas the only one to keep is the second largest area, you have entity names so can erase all the others. Have a go plenty here will help if you get stuck. Expand (setq bm (ssadd)) (command "_.boundary" "a" "b" "n" dm rect "" "" m "") (ssadd (entlast) bm) entlast function always stores the last created entity so external rectangular can easily find out and other polylines sort by area. (defun c:kol () (setq p1 (getpoint "\nSpecify the corner point: ")) ;; Prompt user to specify the corner point (setq p2 (getcorner p1 "\nSpecify the corner point: ")) ;; Prompt user to specify the corner point (setq dm (ssget "w" p1 p2 '((0 . "LWPOLYLINE,CIRCLE,ARC,LINE")))) ;; Get selection set of objects within the specified window (/ (getvar "VIEWSIZE") (cadr (getvar "SCREENSIZE"))) (if dm (progn (setq rect (ssadd)) ;; Initialize a new selection set for the rectangle (command "RECTANGLE" p1 p2) ;; Create the rectangle using the RECTANGLE command (ssadd (entlast) rect) ;; Add the created rectangle to the selection set ;; Calculate a point slightly inside the rectangle to use with the boundary command (setq m (polar p1 (angle p1 p2) 5)) (setq bm (ssadd)) ;; Initialize a new selection set for the boundary ;; Create a boundary using the selected objects and the rectangle (command "_.boundary" "a" "b" "n" dm rect "" "" m "") (ssadd (entlast) bm) ;; Add the created boundary to the selection set (command "_.erase" rect "") ;; Erase the rectangle (command "_.erase" bm "") ;; Erase the boundary (princ "\nBoundary created successfully.") ) (princ "\nNo objects found in the specified area.") ;; Message if no objects are found ) (princ) ;; Exit quietly ) ;; end of c:kol Edited Monday at 08:17 AM by maahee Quote
GLAVCVS Posted Monday at 10:06 AM Posted Monday at 10:06 AM I think you misunderstood me. You should write: (setq m (polar p1 (angle p1 p2) (/ (getvar "VIEWSIZE") (cadr (getvar "SCREENSIZE"))))) 1 Quote
GLAVCVS Posted Monday at 10:18 AM Posted Monday at 10:18 AM (edited) After that, all that's left is to identify which of the objects created by 'boundary' matches the rectangle. '(ssadd (entlast) dm)' is useless because it might select the wrong polyline. I would use, for example: (setq f (ssget "_X" (list '(0 . "LWP*") '(-4 . "=,=,*") (list 10 (car p1) (cadr p1) 0.0)))) Edited Monday at 04:38 PM by GLAVCVS 1 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.