Counting and sum of the objects

Counting and sum of the objects

Gaganpatel
Collaborator Collaborator
1,639 Views
18 Replies
Message 1 of 19

Counting and sum of the objects

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

I want to count and make the sum of it by the help of lisp file. For example in drawing we have

3*M16x40

5*M16x45

4*M16x55

8*M16x50

6*M16x40

7*M16x45

 

Final result will be

M16x40-9

M16x45-12

M16x50-8

M16x55-4

0 Likes
Accepted solutions (2)
1,640 Views
18 Replies
Replies (18)
Message 2 of 19

pbejse
Mentor
Mentor
(Defun c:demo ( / Text alldata ss textlocation f entdata str qty label)
(defun Text (pt sty hgt str)
  (entmakex (list (cons 0 "TEXT")
                  (cons 10  pt)
		  (cons 7 sty)
                  (cons 40 hgt)
                  (cons 1  str))))
	(if
	  (and
	    (setq alldata nil
		 ss (ssget "_X" '((0 . "TEXT")(8 . "bolts length")(1 . "*#`*M*"))))
	    (setq textlocation (getpoint "\nText location"))
	    )
	 
		(progn
		  	(repeat (setq i (sslength ss))
			  	(setq entdata (entget (ssname ss (setq i (1- i)))))
			  	(setq str (cdr (assoc 1 entdata)))
			  	(setq qty (atoi str))
			  	(setq label (substr str (+ 2 (1+ (fix (/ (log qty) (log 10)))))))
			  	(setq alldata
			  	(if (setq f (assoc label alldata))
				  	(subst (list label (+ (cadr f) qty)) f alldata)
					(cons (list label qty) alldata)))
			  	)
		  (setq tstyle (cdr (assoc 7 entdata))
	                theight (cdr (assoc 40 entdata)))
		  
		  (foreach itm (vl-sort alldata '(lambda (a b)(< (car a)(car b))))
		    	(Text textlocation tstyle theight
			      (strcat (car itm) "-" (itoa (cadr itm))))
		    	(setq textlocation (polar textlocation (* pi 1.5) (* theight 2.0))))
			      
		    	
		  )
	 )
  (princ)
)

			
0 Likes
Message 3 of 19

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Please  Modify count and make the sum of it by the help of lisp file. For example in drawing we have.

out put result for select object not total drawing file

3*M16x40

5*M16x45

4*M16x55

8*M16x50

2*PW16*8

6*M16x40

7*M16x45

1*PW16*10

 

Final result will be

M16x40-9

M16x45-12

M16x50-8

M16x55-4

PW16*8-2

PW16*10-10

 
 
0 Likes
Message 4 of 19

pbejse
Mentor
Mentor

@Gaganpatel wrote:

 

 

M16x40-9

M16x45-12

M16x50-8

M16x55-4

PW16*8-2

PW16*10-10

 

Replace this

(setq alldata nil
		 ss (ssget "_X" '((0 . "TEXT")(8 . "bolts length")(1 . "*#`*M*"))))

 

with this

(setq alldata nil
		 ss (ssget "_X" '((0 . "TEXT")(8 . "bolts length")(1 . "*#`*@*"))))

HTH

 

0 Likes
Message 5 of 19

Gaganpatel
Collaborator
Collaborator

 

Dear Sir,

Please  Modify count and make the sum of it by the help of lisp file. For example in drawing we have.

output result for select object not total drawing file

0 Likes
Message 6 of 19

pbejse
Mentor
Mentor

@Gaganpatel wrote:

output result for select object not total drawing file


Replace this

 

(setq alldata nil
		 ss (ssget "_X" '((0 . "TEXT")(8 . "bolts length")(1 . "*#`*@*"))))

with this

 

 

(setq alldata nil
		 ss (ssget '((0 . "TEXT")(8 . "bolts length")(1 . "*#`*@*"))))

HTH

 

 

0 Likes
Message 7 of 19

Gaganpatel
Collaborator
Collaborator

 Dear Sir,

This problems solve but output result only select drawing not total drawing.

M16x40-9

M16x45-12

M16x50-8

M16x55-4

PW16*8-2

PW16*10-10

0 Likes
Message 8 of 19

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Please solve

output result only select drawing

0 Likes
Message 9 of 19

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Please solve

output result only select drawing.

please see the example video.

0 Likes
Message 10 of 19

pbejse
Mentor
Mentor

 

Replace

I understand what is required

With

I'm NOT understanding  what is required

Seriously  

0 Likes
Message 11 of 19

Gaganpatel
Collaborator
Collaborator

I Require command demo then select object and output text location.

0 Likes
Message 12 of 19

Gaganpatel
Collaborator
Collaborator

Please solve 

0 Likes
Message 13 of 19

pbejse
Mentor
Mentor

Tell you what

Post 2 sample drawings. Before and After

 

 

0 Likes
Message 14 of 19

Gaganpatel
Collaborator
Collaborator

Yes

 

two drawing  one drawing required bolt counting, next drawing not required.

then bolt required drawing select output text.

 

0 Likes
Message 15 of 19

Gaganpatel
Collaborator
Collaborator

Dear Sir,

 

Please see the attached drawing and solve 

0 Likes
Message 16 of 19

pbejse
Mentor
Mentor

@Gaganpatel wrote:

 

two drawing  one drawing required bolt counting, next drawing not required.

then bolt required drawing select output text.


 

I still don't understand what that means at ALL.

Attached a drawing sample of a BEFORE the program run  and AFTER [ as the RESULT ]

 

EDIT: LEt me check the drawing file you just uploaded.

That is exactly what the code is supposed to do, that is if you follow the instructions from the previous posts.

 

 

 

0 Likes
Message 17 of 19

Gaganpatel
Collaborator
Collaborator
Accepted solution

Dear Sir,

 this program run for all text counting.

but i require only select object text counting.

0 Likes
Message 18 of 19

Gaganpatel
Collaborator
Collaborator
Accepted solution

Thank You very much sir.

0 Likes
Message 19 of 19

pbejse
Mentor
Mentor

@Gaganpatel wrote:

Thank You very much sir.


You are welcome.

 

0 Likes