AutoCAD lisp to insert dimensions value to excel sheet or table

AutoCAD lisp to insert dimensions value to excel sheet or table

Anonymous
Not applicable
4,983 Views
14 Replies
Message 1 of 15

AutoCAD lisp to insert dimensions value to excel sheet or table

Anonymous
Not applicable

Hi I am new on this forum 

can any body help me for a lisp which can do a routine work for me, 

A lisp which can automatically take data of dimensions value and put in excel sheet or table in same file, ( number , length, width )

I am in marble industry where I have to take thousand of dimensions for marble cutting on daily basis which is so much time costing and hard work

i would appreciate for any help

0 Likes
Accepted solutions (1)
4,984 Views
14 Replies
Replies (14)
Message 2 of 15

devitg
Advisor
Advisor

You can try with DATAEXTRACTION . 

 

Would you , please , upload a sample.dw

0 Likes
Message 3 of 15

Anonymous
Not applicable

Thanks for your reply 

I have already tried to export dimensions data by DATAEXTRACTION  but unable to do so, in data extraction it showS only number of dimensions not values, 

I need some thing like this as in screen shot I have 3 pcs with number and dimensions, need lisp to put data in table as shown 

5BBBF58E-9FC5-4970-9AF7-0B1B15E6AC3D.png

 

0 Likes
Message 4 of 15

Sea-Haven
Mentor
Mentor

Did you Google pretty sure this exact request has been answered before.

0 Likes
Message 5 of 15

Anonymous
Not applicable

Thanks for your kind reply, 

I have googled but didn’t find any solution for this, if some one write a LISP for me i will be thank full to him, because I don’t know much about writing lisp, 

0 Likes
Message 6 of 15

Sea-Haven
Mentor
Mentor

Ok a quick method comes to mind one pick are the shapes numbered already or do you want that added also ?

 

If one edge is always horizontal very quick to do. Come to think about it do you want the dims added as well ? Just draw the shape, even that can be automated further as they are basic shapes. 

 

Please post a sample dwg for dim style and table style with shapes.

 

Message 7 of 15

Sea-Haven
Mentor
Mentor

Threw this together, code required 

(if (not AH:getvalsimg)(load "Multi Getvals img.lsp"))
(setq ans (AH:getvalsimg "D:\\Acadtemp\\Shapes" 40 (list "Enter values" "Shape number" 5 4 "1" "Enter width" 5 4 "900" "Enter Ht" 5 4 "1000" "Enter L off" 5 4 "300" "Enter R offset" 5 4 "300")))

 

 

screenshot175.png

0 Likes
Message 8 of 15

Anonymous
Not applicable
Shapes are numbered already and yes one edge is horizontal always ,
0 Likes
Message 9 of 15

Sea-Haven
Mentor
Mentor

You can try this, have 2 choices a new table or add to an existing table it will add table rows as you pick. 

 

It can be very much automated but this is a start and the free version. Need your dwg to check table. I would consider the drawing shapes can do much faster. 

 

You must save the multi radio buttons.lsp to your lisp support path or it will not be found that's the dcl. 

screenshot176.png

 

; Make a table of shapes based on bounding box.
; By Alan H march 2020 info@alanh.com.au

(defun c:dimtab ( / dolabel dotext enddimtab AH:maketable objtable obj1 obj2 tsr len ht)

(defun enddimtab ()
(alert "Object is not a pline, please join and do again")
(exit)
)
; now do table 
(defun AH:maketable ( / pt1 numrows numcolumns rowheight colwidth )
(setvar 'ctab "Model")
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq curspace (vla-get-modelspace doc))
(setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table:  "))) 
(setq numrows 3)
(setq numcolumns 3)
(setq rowheight 0.3)
(setq colwidth 1.8)
(setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth))
(vla-settext objtable 0 0 "Dimension table")
(vla-settext objtable 1 0 "Number") 
(vla-settext objtable 1 1 "Width")
(vla-settext objtable 1 2 "Length")
(setq objtable (vlax-ename->vla-object (entlast)))
) ; defun

(defun AH:addlinet ( / rowcnt rowhgt)
(setq rowcnt (vla-get-rows objtable))
(setq rowhgt (vla-getRowHeight objtable 2))
(vla-InsertRows objTable rowcnt rowhgt 1)
(vla-settext objtable (- rowcnt 1) 0 tsr)
(vla-settext objtable (- rowcnt 1) 1 len)
(vla-settext objtable (- rowcnt 1) 2 ht)
)

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= but nil)(setq but 1))
(setq ans (ah:butts but "h"  '("Table " "Make New " "Use existing ")))

(if (= but 1)
(AH:maketable)
(setq objtable (vlax-ename->vla-object (car (entsel "pick existing table"))))
)

(while (setq ent (entsel "Pick text "))
(setq obj1 (vlax-ename->vla-object (car ent)))
(setq tsr (vlax-get Obj1 'Textstring))
(setq obj2 (vlax-ename->vla-object (car (entsel "Pick pline object "))))
(if (= (vla-get-objectname obj2) "AcDbPolyline")
(progn
(vla-GetBoundingBox obj2 'minpoint 'maxpoint)
(setq pointmin (vlax-safearray->list minpoint))
(setq pointmax (vlax-safearray->list maxpoint))
(setq len (rtos (abs (- (car pointmin)(car pointmax))) 2 3))
(setq Ht (rtos (abs (- (cadr pointmin)(cadr pointmax))) 2 3))
(AH:addlinet)
)
(enddimtab)
)
)

 

0 Likes
Message 10 of 15

devitg
Advisor
Advisor

Would you , please , upload such sample.dwg

0 Likes
Message 11 of 15

devitg
Advisor
Advisor
Accepted solution

Please, find attached , dwg lsp and csv  

0 Likes
Message 12 of 15

Anonymous
Not applicable
I am out of office in morning I will add sample drawing 👍
0 Likes
Message 13 of 15

Sea-Haven
Mentor
Mentor

Did you try what I posted I did test it.

0 Likes
Message 14 of 15

Anonymous
Not applicable

thanks a lot that do some work for me although it saves data in notepad but ok i can easily copy it to excel sheet instead of typing each dimension again and again 

thanks a lot bro 

0 Likes
Message 15 of 15

Anonymous
Not applicable

i tried but this code not working for me 

0 Likes