Make table for Counting dimension in Autocad

Make table for Counting dimension in Autocad

jchua3
Participant Participant
1,022 Views
11 Replies
Message 1 of 12

Make table for Counting dimension in Autocad

jchua3
Participant
Participant

Good day, is it possible to make lisp that makes a table to count selected dimensions that separates per layer. and if possible also export the table to excel? I'm not very familiar making lisp. Any help is much appreciated Thank you.

0 Likes
Accepted solutions (1)
1,023 Views
11 Replies
Replies (11)
Message 2 of 12

baksconstructor
Advocate
Advocate

1.1.PNG1.2.PNG1.3.PNG2.PNG3.PNG

 

Use this -MyPropertiesCAD 
Set the settings as shown in the pictures.
And for each polyline, enter a name in the properties panel.

 

 

Message 3 of 12

ec-cad
Collaborator
Collaborator

Please attach a small sample drawing, perhaps the one in your screen shots.

I'm sure someone here can create a Lisp for that. (been done several times before).

 

ECCAD

Message 4 of 12

Sea-Haven
Mentor
Mentor

Try this export table to excel. Like others can make a custom solution that sorts the info say by layer name, before making the table. Do a Google.

 

Message 5 of 12

jchua3
Participant
Participant

Hello I've searched LISPs and the only one that comes close to what I want to do was the post Extract Rectangle Dimension To Table (Count & Numbering). But instead of the rectangles what I need is only the selected dimension Lengths. LISP to make CAD table or in excel too. Just to automate the process to make work faster. Thank you.

0 Likes
Message 6 of 12

baksconstructor
Advocate
Advocate

@jchua3 wrote:

Hello I've searched LISPs and the only one that comes close to what I want to do was the post Extract Rectangle Dimension To Table (Count & Numbering). But instead of the rectangles what I need is only the selected dimension Lengths. LISP to make CAD table or in excel too. Just to automate the process to make work faster. Thank you.


 

What's wrong with the proposed solution?

0 Likes
Message 7 of 12

hak_vz
Advisor
Advisor
Accepted solution

Try this

(defun c:dim2excel  ( / Number2Alpha AH:putcell excel ss i j k layers el measures mea old new)

	(defun Number2Alpha (Num# / Val#)
	  (if (< Num# 27)
		(chr (+ 64 Num#))
		(if (= 0 (setq Val# (rem Num# 26)))
		  (strcat (Number2Alpha (1- (/ Num# 26))) "Z")
		  (strcat (Number2Alpha (/ Num# 26)) (chr (+ 64 Val#)))
		)
	  )
	);defun Number2Alpha

	(defun AH:putcell (cellname val1 / )
		(setq myRange (vlax-get-property  (vlax-get-property excel "ActiveSheet") "Range" cellname))
		(vlax-put-property myRange 'Value2 val1)
	)

	(if (= (setq excel (vlax-get-object "Excel.Application") ) nil)
	(setq excel (vlax-get-or-create-object "Excel.Application"))
	(vlax-invoke-method (vlax-get-property excel 'WorkBooks) 'Add)
	)


	(setq ss (ssget '((0 . "DIMENSION"))) i -1 layers nil)
	(while (< (setq i (1+ i))(sslength ss))
		(setq el (vlax-ename->vla-object (ssname ss i)))
		(if (not (member (vla-get-layer el) layers))
			(setq layers (cons (vla-get-layer el) layers))
		)
	)
	(setq j 0 k 0)
	(foreach layer layers
		(setq i -1 measures (list))
		(while (< (setq i (1+ i))(sslength ss))
			(setq el (vlax-ename->vla-object (ssname ss i)))
			(cond
				((= layer (vla-get-layer el))
					(setq mea (rtos (vla-get-measurement el) 2 2))
					(cond 
						((setq old(assoc mea measures))
							(setq new (cons mea (1+ (cdr old))))
							(setq measures (subst new old measures))
						)
						(T
							(setq measures (cons (cons mea 1) measures))
						)
					)
				)
			)	
		)
		(vla-put-visible excel :vlax-true)
		(vlax-put-property excel 'ScreenUpdating :vlax-true)
		(vlax-put-property excel 'DisplayAlerts :vlax-true)
		
		(foreach measure measures
				(AH:putcell (strcat (Number2Alpha (+ j 1)) (itoa (1+ k))) (car measure))
				(AH:putcell (strcat (Number2Alpha (+ j 2)) (itoa (1+ k)))(itoa(cdr measure)))
				(AH:putcell (strcat (Number2Alpha (+ j 3)) (itoa (1+ k))) layer)
				(setq k (1+ k))
		)

	)

	(vlax-release-object excel)
	(princ)
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 8 of 12

jchua3
Participant
Participant
wow, this is what I'm looking for thanks a lot! Is it possible to have an option to make the table in CAD?
0 Likes
Message 9 of 12

jchua3
Participant
Participant
I'm looking for an LISP that makes a table like the one posted in Extract Rectangle Dimension To Table (Count & Numbering), but instead of rectangle, just the dimension length.
0 Likes
Message 10 of 12

baksconstructor
Advocate
Advocate
Have you looked at my example?
It has everything you need. Exactly as you showed.
Message 11 of 12

Sea-Haven
Mentor
Mentor

@hak_vz I have some updated lisp defuns in this version, a (xlsetcelltext row col val) no need to work out the "A1" etc. I keep adding stuff to it as I find a need. yes AH: is me.

 

 

 

0 Likes
Message 12 of 12

jchua3
Participant
Participant
Hello I will give a try today to see which I can work with the fastest. Thank you.
0 Likes