2andygs Posted April 16, 2015 Share Posted April 16, 2015 (edited) Hello Guys... can some one help me to build the following requirements in the drawing.. this is basically for qc purpose....I am beginner in this field Should list if there are any splines, ellipses & arc less than 1/8" ... display the same in Alert box ex: NO ELLIPSE or FOUND 5 ELLIPSES NO SPLINE or FOUND 5 SPLINES FOUND 10 ARC LESS THAN 1/8" long OR NO ARCS LESS THAN 1/8" This will help me big time.... Thanks in advance... Can some one help me to add.. Spline and arc less than .125" to the following code. (DEFUN C:AR() (setq set nil) (setq G4 (ssget "x" '((0 . "ELLIPSE" )))) (if (null G4) (progn (alert (strcat "\nHSP" "\n-----------------" "\nNo ELLIPSE" "\nIN THIS DWG.") ) ) (progn (setq len (rtos (sslength G4) 2 3)) (alert (strcat "\n HSP" "\n------------------" "\nTotal " len " ELLISPSE<s>" "\nin ' THIS DWG 'Layer.") ) (command "change" G4 "" "p") ) )) Edited April 22, 2015 by 2andygs Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 17, 2015 Share Posted April 17, 2015 2andygs dont hijack posts start a new one, Moderator ?? Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 17, 2015 Author Share Posted April 17, 2015 SORRY... Newbie... Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 17, 2015 Author Share Posted April 17, 2015 Hello Guys... can some one help me to build the following requirements in the drawing.. this is basically for qc purpose....I am beginner in this field Should list if there are any splines, ellipses & arc less than 1/8" ... display the same in Alert box ex: NO ELLIPSE or FOUND 5 ELLIPSES NO SPLINE or FOUND 5 SPLINES FOUND 10 ARC LESS THAN 1/8" long OR NO ARCS LESS THAN 1/8" This will help me big time.... Thanks in advance... Quote Link to comment Share on other sites More sharing options...
SLW210 Posted April 17, 2015 Share Posted April 17, 2015 Post moved from other thread to this one. Quote Link to comment Share on other sites More sharing options...
SLW210 Posted April 22, 2015 Share Posted April 22, 2015 Please read the Code Posting Guidelines and edit your post to include the Code in Code Tags. Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 22, 2015 Author Share Posted April 22, 2015 Do I have to just type # before the code? or select the code and click on icon #? For some reason it's nor showing up the way it explained in the example thanks Quote Link to comment Share on other sites More sharing options...
Commandobill Posted April 22, 2015 Share Posted April 22, 2015 Your code should be wrapped in these -> [ CODE ]Your code here[ /CODE ] Minus the spaces of course. Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 22, 2015 Author Share Posted April 22, 2015 Thank you... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 22, 2015 Share Posted April 22, 2015 Should list if there are any splines, ellipses & arc less than 1/8" Splines, Ellipses & Arcs all less than 1/8"? Or any length of Splines & Ellipses, and all Arcs less than 1/8"? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 22, 2015 Share Posted April 22, 2015 Here's some code to get you started: (defun c:ar ( / e i n s ) (alert (strcat (if (setq s (ssget "_X" '((0 . "ELLIPSE")))) (strcat "Found " (itoa (sslength s)) " ellipse" (if (= 1 (sslength s)) "." "s.")) "No ellipses found." ) (if (setq s (ssget "_X" '((0 . "SPLINE")))) (strcat "\nFound " (itoa (sslength s)) " spline" (if (= 1 (sslength s)) "." "s.")) "\nNo splines found." ) (if (setq s (ssget "_X" '((0 . "ARC")))) (progn (setq n 0) (repeat (setq i (sslength s)) (setq e (entget (ssname s (setq i (1- i))))) (if (< (* (cdr (assoc 40 e)) (rem (+ (- (cdr (assoc 51 e)) (cdr (assoc 50 e))) pi pi) (+ pi pi))) 0.125) (setq n (1+ n)) ) ) (if (< 0 n) (strcat "\nFound " (itoa n) " arc" (if (= 1 n) "" "s") " shorter than 1/8\"") "\nNo arcs shorter than 1/8\" found." ) ) "\nNo arcs found." ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 23, 2015 Author Share Posted April 23, 2015 Splines & Ellipses can be any size.....only Arcs and lines less than 1/8" Thank you Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 23, 2015 Author Share Posted April 23, 2015 Thank you LeeMac, that's wonderful... just what I wanted... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 23, 2015 Share Posted April 23, 2015 You're welcome! - I hope the code is clear. Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 23, 2015 Author Share Posted April 23, 2015 Works well... Can you also please add Line Length less than 1/8" and move all selected items (spline. Ellipses, arc & lines less than 1/8" to Layer name "fix" Thanks Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 24, 2015 Author Share Posted April 24, 2015 Hi LeeMac, Can you also please add Line Length less than 1/8" and move all selected items (spline. Ellipses, arc & lines less than 1/8" to Layer name "fix" Thanks Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 24, 2015 Author Share Posted April 24, 2015 Hi LeeMac, Hi Tried to Modify the code to select lines less than 1/8"...but did not work... please see the code (defun c:stt ( / e i n s ) (alert (strcat (if (setq se (ssget "_X" '((0 . "ELLIPSE")))) (strcat "Found " (itoa (sslength se)) " Ellipse" (if (= 1 (sslength se)) "." "s.")) "\nNo ellipses found." ) (if (setq sp (ssget "_X" '((0 . "SPLINE")))) (strcat "\nFound " (itoa (sslength sp)) " Spline" (if (= 1 (sslength sp)) "." "s.")) "\nNo Splines found." ) (if (setq sl (ssget "_X" '((0 . "LINE")))) (strcat "\nFound " (itoa (sslength sl)) " Line" (if (= 1 (sslength sl)) "." "s.")) "\nNo Lines found." ) (if (setq sa (ssget "_X" '((0 . "ARC")))) (progn (setq n 0) (repeat (setq i (sslength sa)) (setq e (entget (ssname sa (setq i (1- i))))) (if (< (* (cdr (assoc 40 e)) (rem (+ (- (cdr (assoc 51 e)) (cdr (assoc 50 e))) pi pi) (+ pi pi))) 0.125) (setq n (1+ n)) ) ) (if (< 0 n) (strcat "\nFound " (itoa n) " Arc" (if (= 1 n) "" "s") " shorter than 1/8\"") "\nNo Arcs shorter than 1/8\" found." ) ) "\nNo arcs found." ) ) ) (command "LAYER" "NEW" "FIX" "COLOR" "5" "FIX" "") (COMMAND "CHANGE" se sp sa sl "" "p" "layer" "fix" "") (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 25, 2015 Share Posted April 25, 2015 Try the following: (defun c:stt ( / e i n sa se sl sp ) (alert (strcat (if (setq se (ssget "_X" '((0 . "ELLIPSE") (8 . "~FIX")))) (strcat "Found " (itoa (sslength se)) " Ellipse" (if (= 1 (sslength se)) "." "s.")) "\nNo Ellipses found." ) (if (setq sp (ssget "_X" '((0 . "SPLINE") (8 . "~FIX")))) (strcat "\nFound " (itoa (sslength sp)) " Spline" (if (= 1 (sslength sp)) "." "s.")) "\nNo Splines found." ) (if (setq sl (ssget "_X" '((0 . "LINE") (8 . "~FIX")))) (progn (repeat (setq i (sslength sl)) (setq e (entget (ssname sl (setq i (1- i))))) (if (<= 0.125 (distance (cdr (assoc 10 e)) (cdr (assoc 11 e)))) (ssdel (cdr (assoc -1 e)) sl) ) ) (if (< 0 (setq n (sslength sl))) (strcat "\nFound " (itoa n) " Line" (if (= 1 n) "." "s.") " shorter than 1/8\"") (progn (setq sl nil) "\nNo Lines shorter than 1/8\" found." ) ) ) "\nNo Lines found." ) (if (setq sa (ssget "_X" '((0 . "ARC") (8 . "~FIX")))) (progn (repeat (setq i (sslength sa)) (setq e (entget (ssname sa (setq i (1- i))))) (if (<= 0.125 (* (cdr (assoc 40 e)) (rem (+ (- (cdr (assoc 51 e)) (cdr (assoc 50 e))) pi pi) (+ pi pi)))) (ssdel (cdr (assoc -1 e)) sa) ) ) (if (< 0 (setq n (sslength sa))) (strcat "\nFound " (itoa n) " Arc" (if (= 1 n) "" "s") " shorter than 1/8\"") (progn (setq sa nil) "\nNo Arcs shorter than 1/8\" found." ) ) ) "\nNo Arcs found." ) ) ) (if (or se sp sl sa) (progn (command "_.-layer" "_n" "FIX" "_c" "5" "FIX" "" "_.change") (foreach s (list se sp sl sa) (if s (command s))) (command "" "_p" "_la" "FIX" "") ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 27, 2015 Author Share Posted April 27, 2015 Thanks a lot Lee Mac, Works good. Quote Link to comment Share on other sites More sharing options...
2andygs Posted April 27, 2015 Author Share Posted April 27, 2015 Hi Lee Mac, I just noticed one thing in routine... If you use the command twice... second time it is not recognising any ellipse, spline arc and lines... if I change the layer back to "0" then it will recognise. 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.