digitalmapper Posted December 7, 2016 Share Posted December 7, 2016 Hi guys. I've been trying to find a lisp that detects if layer specified polylines are inside another layer specified polyline. I want to check if closed polylines under layers (Layer 1, Layer 2 & Layer 3..) is inside a closed polyline under Layer 4. I hope someone gets what im saying. The best I can do in AutoCAD is creating macros and this cannot be done by that Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 7, 2016 Share Posted December 7, 2016 Hi, Be sure to have the selected polyline's border completely seen in the screen otherwise the program may fail or not detect all polyline objects. (defun c:test (/ sn ss dis div s in l) (princ "\nPick a closed polyline :") (if (setq s (ssget "_+.:S:E" '((0 . "*POLYLINE") (8 . "Layer4") (-4 . "&=") (70 . 1)))) (progn (setq sn (ssname s 0) dis (/ (vlax-curve-getdistatparam sn (fix (vlax-curve-getendparam sn)) ) 100. ) div dis ) (repeat 100 (setq l (cons (vlax-curve-getpointatdist sn dis) l)) (setq dis (+ div dis)) ) (if (setq ss (ssget "_WP" l '((0 . "*POLYLINE") (8 . "Layer1,Layer2,Layer3")) ) ) (sssetfirst nil ss) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
digitalmapper Posted December 7, 2016 Author Share Posted December 7, 2016 That was fast Tharwat. While the program is good, would it be possible to prompt an error message if any of the polylines under Layer 1, 2 or 3 is not completely inside Layer 4? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted December 7, 2016 Share Posted December 7, 2016 That was fast Tharwat. While the program is good, would it be possible to prompt an error message if any of the polylines under Layer 1, 2 or 3 is not completely inside Layer 4? Try this: (defun c:test (/ lays fnd sn ss dis div s lst lay l) ;; Tharwat - 07.Dec.2016 ;; (princ "\nPick on closed polyline :") (if (setq lays "Layer1,Layer2,Layer3" fnd 0 s (ssget "_+.:S:E" '((0 . "*POLYLINE") (8 . "Layer4") (-4 . "&=") (70 . 1)) ) ) (progn (setq sn (ssname s 0) dis (/ (vlax-curve-getdistatparam sn (fix (vlax-curve-getendparam sn)) ) 100. ) div dis ) (repeat 100 (setq l (cons (vlax-curve-getpointatdist sn dis) l)) (setq dis (+ div dis)) ) (if (setq ss (ssget "_WP" l (list '(0 . "*POLYLINE") (cons 8 lays))) ) (while (and (/= fnd 3) (setq sn (ssname ss 0)) ) (and (wcmatch (setq lay (cdr (assoc 8 (entget sn)))) lays) (not (member lay lst)) (setq lst (cons lay lst)) (setq fnd (length lst)) ) (ssdel sn ss) ) ) (cond ((= fnd 3) (princ "\nAll layers are found ")) ((>= fnd 1) (princ (strcat "\nPolylines' layers [" (vl-string-right-trim "," (apply 'strcat (mapcar '(lambda (u) (strcat u ",")) lst)) ) "]." ) ) ) ((princ "\nNo polylines found on specified layers <!>")) ) ) ) (princ) )(vl-load-com) Quote Link to comment Share on other sites More sharing options...
digitalmapper Posted December 7, 2016 Author Share Posted December 7, 2016 Works great! Thank you! One quick question though, how do i change "Select Objects:" to "Select Object:" since I will only be selecting one Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 7, 2016 Share Posted December 7, 2016 Works great! Thank you! One quick question though, how do i change "Select Objects:" to "Select Object:" since I will only be selecting one Use entsel/nentsel instead of ssget, and modify half of the code. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 7, 2016 Share Posted December 7, 2016 Apparently there is a way to suppress the default ssget prompt (but I don't think it works well in BricsCAD). (prompt ...) (setvar 'nomutt 1) (ssget ...) (setvar 'nomutt 0) Quote Link to comment Share on other sites More sharing options...
digitalmapper Posted December 8, 2016 Author Share Posted December 8, 2016 I have another concern, when one or more polylines under (Layer1, Layer2, Layer3) are on top of Layer4, I want it to be considered as inside the polyline. It will just exclude it if it is outside. Quote Link to comment Share on other sites More sharing options...
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.