Jump to content

lisp for for sum text number before a specific alphabet character


Recommended Posts

Posted
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. :)

  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

  • anjan008

    17

  • Snownut

    13

  • pBe

    4

  • BIGAL

    2

Top Posters In This Topic

Posted (edited)

Thanks for your support and i appropriate you help

Edited by anjan008
Posted

I think your Pack Washers are on a different layer, your also need to change to the proper layer.

Posted

is it possible to do for both layers which are

"7_Graphics"

"25_Bolt designation"

 

thanks

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

Posted

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.

Posted

Command: mk_lst ; error: too few arguments

 

Could not able to call that command after loading it

Posted

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

Posted

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.

Posted

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

Posted

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.

Posted (edited)
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
Posted

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

Posted

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?

Posted

Thanks for help for above program.

 

Sorry for asking,

 

i will try to do by learning slowly.

  • 4 months later...
Posted

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

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