Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Make table for Counting dimension in Autocad

11 REPLIES 11
Reply
Message 1 of 12
jchua3
339 Views, 11 Replies

Make table for Counting dimension in Autocad

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.

11 REPLIES 11
Message 2 of 12
baksconstructor
in reply to: jchua3

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
in reply to: jchua3

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
in reply to: jchua3

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
in reply to: Sea-Haven

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.

Message 6 of 12
baksconstructor
in reply to: jchua3


@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?

Message 7 of 12
hak_vz
in reply to: jchua3

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
in reply to: hak_vz

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

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.
Message 10 of 12
baksconstructor
in reply to: jchua3

Have you looked at my example?
It has everything you need. Exactly as you showed.
Message 11 of 12
Sea-Haven
in reply to: hak_vz

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

 

 

 

Message 12 of 12
jchua3
in reply to: baksconstructor

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report