Jump to content

lisp for for sum text number before a specific alphabet character


anjan008

Recommended Posts

Thanks so nice of you

 

No worries anhan008, as it turned out, the sort thingy is an easy mod so i updated the code above. the table will definitely wait tomorrow. :)

Link to comment
Share on other sites

  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

  • anjan008

    17

  • Snownut

    13

  • pBe

    4

  • BIGAL

    2

Top Posters In This Topic

is it possible to do for both layers which are

"7_Graphics"

"25_Bolt designation"

 

thanks

 

It seems your Packing Washer text is laid out completely different, I see no * as a separator in it.

Link to comment
Share on other sites

If the text was laid out the same this would work for both;

 


(defun c:Mk_lst (ltr LName / an txt)

 (defun addme (an LName txt /  trunc data ss i e match)
   ;;;    pBe04Mar2014    ;;;
   (defun trunc (s m)
     (atoi    (if m
         (substr s (+ 2 (vl-string-position an s)))
         (substr s (+ 2 (vl-string-position 42 s nil t)))
         )
       )
     )
   (if (setq data nil
         ss     (ssget    "_X"
               (list
                 '( 0 . "TEXT")
                  (cons 1 txt)
                  (cons 8 LName)
                 )
               )
         )

     (progn
   (repeat (setq i (sslength ss))
     (setq e (ssname ss (setq i (1- i))))
     (setq data (cons (cdr (assoc 1 (entget e))) data))
     )
   (setq
     data (vl-sort    data
           '(lambda (b c)
              (cond
                ((< (setq d (trunc b t)) (setq f (trunc c t))) t)
                ((= d f) (< (trunc b nil) (trunc c nil)))
              )
            )
          )
     )
   (While (setq a (car data))
     (setq ref (substr a (1+ (vl-string-position an a))))
     (setq match (vl-remove-if-not
           '(lambda (s) (wcmatch s (strcat "*" ref)))
           data
           )
       )
     (princ (strcat "\n"
            ref
            " = "
            (itoa (apply '+
                     (mapcar '(lambda (k)
                        (if (zerop (atoi k))
                          1
                          (atoi k)
                          )
                        )
                         match
                         )
                     )
                  )
            )
        )
     (setq data (vl-remove-if '(lambda (y) (member y match)) data))
     )
   )
     )
   (princ)
   )

 (setq an (ascii ltr)
   txt (strcat "*" ltr "##`**")
   )
 (addme an LName txt)
 );
(vl-load-com)

You would use this to call the function at Autocad command prompt;

 

(Mk_lst "P" "7_Graphics")

(Mk_lst "M" "25_Bolt designation")

 

Depending on what outcome you where looking for.

Link to comment
Share on other sites

My bad use this dropped the accidentally c: ;

 

"(c:Mk_lst "P" "7_Graphics")"

"(c:Mk_lst "M" "25_Bolt designation")"

 

You need to type everything between the quotes, not just "Mk_lst"

 

Example;

 

Command: (c:Mk_lst "M" "25_Bolt designation")

 

Works fine for the Bolt List, you did not answer the question regarding the Packing Washer Text...

Link to comment
Share on other sites

Does this 4PW-10mm mean there are 4, PW-10mm washers, if so you need to have text read 4*PW-10mm to utilize the lisp provided by pBe.

Link to comment
Share on other sites

Yes 4PW-10mm mean there are 4, PW-10mm washers

 

I dont want like Bolts...

 

Only bolts will have *

 

For washers its not working

(c:Mk_lst "P" "7_Graphics")

 

Thanks

Link to comment
Share on other sites

I know that, due to text format being completely different than bolts.

 

If you noticed this forum is called "CADTutor", now that you have the code for the bolts list, maybe you could give the washers a try on your own.

Link to comment
Share on other sites

Thanks for your support.

 

Same way i want to calculate PW (Pack washer)quantity also

 

I'll have a look see in a bit.

 

If the text was laid out the same this would work for both;

 

(defun c:Mk_lst (ltr LName / an txt)...

 

You would use this to call the function at Autocad command prompt;

 

(Mk_lst "P" "7_Graphics")

(Mk_lst "M" "25_Bolt designation")

 

Depending on what outcome you where looking for.

 

Looks interesting Snownut, I think i can find a way to incorporate both options on the _trunc sub-function. Thank you for your assistance kind sir. :)

 

CODE UPDATED at post #14

@anjan008,

Kindly remove the code you posted at post number 22 :)

Edited by pBe
Link to comment
Share on other sites

Thanks for your help,

 

Which variable i have to change if the bolts and washer are indicated like below

 

5-A

8-B

1-C

 

2W-6

5W-8

3W-10

4W-12

 

Thanks and regards

Link to comment
Share on other sites

You may want to contact pBe, to see how much he is going to charge you to keep customizing your custom built application, since you seem to be unable to post just what it is you are looking for.

 

How much time is application saving you & your company?

Link to comment
Share on other sites

  • 4 months later...

Dear Pbe

 

Can you please help me to suite addme lisp to calculate bolts and washers as below

 

5-A

8-B

1-C

 

2PW-6

5PW-8

3PW-10

4PW-12

 

Thanks for previous lisp

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