Jump to content

Dimension String Verification


pinkguju

Recommended Posts

I need to be able to make sure that there are Dimension Strings in a CAD file that range from 0 to 210. So each dimension string has a number ("01") as the unit. I want to be able to pull an external file (txt) off all the numbers that are NOT in the file.

 

So if 200 and 151 were not in the file it would give me that.

 

Any thoughts?

Link to comment
Share on other sites

  • Replies 24
  • Created
  • Last Reply

Top Posters In This Topic

  • pinkguju

    10

  • Lee Mac

    8

  • alanjt

    4

  • BlackBox

    3

Top Posters In This Topic

Posted Images

A rough estimate, hacked together:

 

(defun c:test ( / _PadLeft )

 (defun _PadLeft ( s l )
   (if (< (strlen s) l) (_PadLeft (strcat "0" s) l) s)
 )

 (
   (lambda ( i / l )
     (while (<= (setq i (1+ i)) 210)
       (or (ssget "_X" (list '(0 . "DIMENSION") (cons 1 (_PadLeft (itoa i) 3))))
           (setq l (cons i l))
       )
     )
     (print l)
   )
   -1
 )  
)

 

File:

(defun c:test ( / _PadLeft f )

 (defun _PadLeft ( s l )
   (if (< (strlen s) l) (_PadLeft (strcat "0" s) l) s)
 )
 
 (if (setq f (getfiled "Output File" "" "txt" 1))
   (
     (lambda ( i / l )
         (while (<= (setq i (1+ i)) 210)
           (or (ssget "_X" (list '(0 . "DIMENSION") (cons 1 (_PadLeft (itoa i) 3))))
               (setq l (cons i l))
           )
         )
       (setq f (open f "a")) (princ l f) (close f)
     )
     -1
   )
 )
 (princ)
)

Edited by Lee Mac
Link to comment
Share on other sites

Lee Mac - This works but it's reporting all the dimension strings that are in the CAD file. Even the ones that i deleted and purged out of the drawing.

 

I deleted "178" and "180" from the file, saved and ran the LISP routine. 178 and 180 showed up on the report.

 

Is there a way to show which ones are missing versus which ones are in the file? We have the criteria (0-210)

Link to comment
Share on other sites

i tried the updated code.

 

it's still giving me all of the ones that are in the CAD file. I just need the ones that are not in the file.

 

it's also giving me the ones that i've deleted and purged from the file.

Link to comment
Share on other sites

So then should i change the original to have the ### convention?

 

That's why I asked for your format.

 

You say that the numbers run from 0 to 210, but then you give examples of 01, 02...

Link to comment
Share on other sites

Sorry. i misunderstood what you were asking for.

 

the strings are written as such "001", "002", "003", "004", "005". all the way up to "210"

 

is that better?

Link to comment
Share on other sites

I tried the original code and it's giving me the same result. Listing all the one that are in the file, as opposed to the ones that are not in the file. The ones that are not in the file are also coming up in the list.

Link to comment
Share on other sites

The strings have the quotation marks in them.

 

Once all strings ("001" to "210") have been verified i have a script that turns them into text.

 

if i have numbers without the quotes then the conversion text doesn't work.

Link to comment
Share on other sites

What about something like this?

 

(defun c:Test (/ ss)
 (vl-load-com)
 (if (setq ss (ssget "_X" '((0 . "DIMENSION") (-4 . "<NOT") (1 . "") (-4 . "NOT>"))))
   ((lambda (i n / lst e)
      (while (> (setq n (1- n)) 0) (setq lst (cons n lst)))
      (while (setq e (ssname ss (setq i (1+ i))))
        (setq lst (vl-remove
                    (atoi (vl-list->string
                            (vl-remove 34 (vl-string->list (cdr (assoc 1 (entget e)))))
                          )
                    )
                    lst
                  )
        )
      )
      (cond (lst (print lst)))
    )
     -1
     211
   )
 )
 (princ)
)

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