Jump to content

List spline, ellipse, arc...


2andygs

Recommended Posts

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 by 2andygs
Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • 2andygs

    12

  • Lee Mac

    5

  • SLW210

    2

  • BIGAL

    1

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...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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"?

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...