HELP=Extract pline Rectangle Dimension To Table

Anonymous

HELP=Extract pline Rectangle Dimension To Table

Anonymous
Not applicable

Hello

 

I've been working with something I never had to: Rectangle dimension extraction and count in drawing to  table.
Since now I've been trying to handle a massive amount of drawings that need a high criteria count, my AutoCad study demand got higher.
I Have Too Many types of Rectangle.And I write pline rectangle L x H dimension and drawing count one by one in Exel.

 

I have Lisp But ıt Extract A rectangle Dimension and no count  to table.

but I want to Extract Multiselect rectangle in drawing and extract them length x height x drawing count in to table.

I Have pline rectangle Example drawing and lisp in attachment. 

Can We Change Or Rewrite LSP This Way. 

 

Please,help me.

Example Pline Rectangle.png

 

(defun c:recdim (/   acadobj doc len lenh modelspace mytable poly pt wid
		 )
      (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
  (setq poly (vlax-ename->vla-object (car (Entsel))))

  (if (and
	(= (vlax-curve-getendparam poly) 4.0)
	(= (vla-get-closed poly) :vlax-true)
	(= (setq len (vlax-curve-getdistatparam poly 1))
	   (- (vlax-curve-getdistatparam poly 3) (vlax-curve-getdistatparam poly 2))
	   )
	(or(= (abs(- (angle (vlax-curve-getpointatparam poly 0) (vlax-curve-getpointatparam poly 1))
	      (angle (vlax-curve-getpointatparam poly 1) (vlax-curve-getpointatparam poly 2))
	      ))
	   (/ pi 2)
	   )
	   (= (abs(- (angle (vlax-curve-getpointatparam poly 0) (vlax-curve-getpointatparam poly 1))
	      (angle (vlax-curve-getpointatparam poly 1) (vlax-curve-getpointatparam poly 2))
	      ))
	   (* 3(/ pi 2))
	   )
	   )
	)
    (progn
      (setq wid (- (vlax-curve-getdistatparam poly 2) (vlax-curve-getdistatparam poly 1)))
      (if (< len wid) (setq lenh len
			    len wid
			    wid lenh)
	)
      (setq pt (vlax-3d-point (getpoint "\n table insert point:")))
      (setq modelSpace (vla-get-ModelSpace doc))
      (setq MyTable (vla-Addtable modelSpace pt 3 2 10 40))
      (vla-SetCellValue MyTable 0 0 "Rectangle dimensions")
      (vla-SetCellValue MyTable 1 0 "Length")
      (vla-SetCellValue MyTable 1 1 (rtos len 2 3))
      (vla-SetCellValue MyTable 2 0 "Width")
      (vla-SetCellValue MyTable 2 1 (rtos wid 2 3))
    )
    (princ "\nSelected object is not rectangle.")
    )
  )
0 Likes
Reply
Accepted solutions (3)
3,233 Views
18 Replies
Replies (18)

phanaem
Collaborator
Collaborator
Accepted solution

Hi

 

A few weeks ago I needed the exact same thing.

See the attachment. Change file extension to lsp.

Hope it helps.

0 Likes

Anonymous
Not applicable

Wow, thank you PHANAEM! 

Perfect...

Happy lisping

Thanks for your efforts. It is working fine.

 

This Lsp solved problem for begining my Work.I use That .

But I need seperate these pline rectangles according to colors same table properties in one table.

CAN WE ADD DİMENSİON WİTH COLOR and different Row İN EXAMPLE ???

I add example.

I'll keep watch 


Best Regards,
Ümit Topçu

 

 

Wanted rectangle form example.png

0 Likes

phanaem
Collaborator
Collaborator

@Anonymous wrote:

Wow, thank you PHANAEM! 

Perfect...

Happy lisping

Thanks for your efforts. It is working fine.

 

This Lsp solved problem for begining my Work.I use That .

But I need seperate these pline rectangles according to colors same table properties in one table.

CAN WE ADD DİMENSİON WİTH COLOR and different Row İN EXAMPLE ???

I add example.

I'll keep watch 


Best Regards,
Ümit Topçu

 

 


Sure, why not.

 

0 Likes

phanaem
Collaborator
Collaborator

AcCmColor is version dependent.

In the previous attachment, please replace this line:

(vla-getinterfaceobject acobj  (strcat "AutoCAD.AcCmColor.19"))

with this

(vla-getinterfaceobject acobj  (strcat "AutoCAD.AcCmColor." (substr (vla-get-version acobj) 1 2)))

0 Likes

Anonymous
Not applicable
Accepted solution

I have problem with table ...

I replace :

 

(vla-getinterfaceobject acobj  (strcat "AutoCAD.AcCmColor." (substr (vla-get-version acobj) 1 2)))  this..

 

but  Table Not Working  just Before.

I Guess Some Command missing last Command.

Can You Help ME.

 

Can we extract this table to xls format??? 

Can you Send Me Tested Lsp. ????

 

Thanks :smileyhappy:

Best regards,

 

 

0 Likes

Anonymous
Not applicable
Thank you PHANAEM!
I handle it with your guide.
Best regards...
0 Likes

Anonymous
Not applicable

Hi Phanem..

I want to Ask some Opional Setup in this lisp.

 

we can Get  colored list perfectly.

 

but Can we Change Color row what we want  in lisp???

 

and

 

Can we extract the table list in exel file...

 

Thanks for your help.

 

be safe.

 

Best regards...

 

 

 

 

 

 

0 Likes

Anonymous
Not applicable

hi phanem

 

 

I wan to change table color row like below

How can We Change this code= " acol (vla-getinterfaceobject acobj (strcat "AutoCAD.AcCmColor." (substr (vla-get-version acobj) 1 2))))" this code to get color row like

I Add color code like this =>(substr (vla-get-version acobj) 1(yellow) 2(color 34) 3(white) 4(color 252) 5(color 173) )))

but ıgot error like Error: no function definition: INSERT_TABLE

 

how can I Succes About this issue????????

 

1- yellow rectangle dimension

2- color 34 rectangle dimension

3- white rectangle dimension 

4- color 252 rectangle dimension 

5- color 173 rectangle dimension 

6- color 8 rectangle dimension 

7- color 254 rectangle dimension 

8- color 221rectangle dimension 

9- color 48 rectangle dimension 

10- color 165 rectangle dimension 

11- color 254 rectangle dimension 

12- color 10 rectangle dimension 

13- color 16 rectangle dimension 

14- color 62 rectangle dimension 

15- color 108 rectangle dimension 

16- color 130 rectangle dimension 

17- color 134 rectangle dimension 

18- color 151 rectangle dimension 

19- color 90 rectangle dimension 

20- color 94 rectangle dimension 

21- color 30 rectangle dimension 

22- color 245 rectangle dimension 

23- color magenta rectangle dimension 

24- color 192 rectangle dimension 

25- color 198 rectangle dimension 

26- color 216 rectangle dimension 

27- color 236 rectangle dimension 

28- color 51 rectangle dimension 

30- color 52 rectangle dimension 

31- color 152 rectangle dimension 

32- color 93 rectangle dimension 

33- color 170 rectangle dimension 

 

Best Regards...

Have Nice Day...

Be Happpyyy..

0 Likes

phanaem
Collaborator
Collaborator
Accepted solution

I'm not sure, but I guess you want to sort the colors in the table so that yellow is the first color, then 34, white and so on...

Try this lisp and tell me if I understood correct.

 

PS1. In your list, the color 254 apear twice, on 7 and 11 position. I changed in 255 for 11 position.

 

PS2. Again, I can't attach .lsp file. Save this .txt file and change the extension to .lsp

0 Likes

Anonymous
Not applicable
Thank you very much for your help.
Everything is now working fine.
The problem is solved.
0 Likes

Anonymous
Not applicable

The problem is solved.

Thank you.

0 Likes

pitperez
Observer
Observer

Hi. Greetings to all. I am new to the forum.
I didn't want to open a new topic, being this closely related to my query.
I am an autocad user in my work, but I don't know how to program in autolisp.
In my work I use many rectangles, both different and equal measures. This lisp (rectangle dims by color.lsp) suits me very well. But I ask for help from here:
You can have him draw a number inside the rectangle, and in the table ?, that is, reference the measurements one by one or by grouping them, but have them located in the drawing where each measure of the table in the drawing belongs.
I hope I have explained myself sufficiently.
Best regards

0 Likes

Sea-Haven
Mentor
Mentor

This will get the mid point of the rectang, you need to add a column to the table ie rectang num. You need to add to the settext part of the table as well.

(setq x 0)
(setq poly (vlax-ename->vla-object (car (Entsel)))) (setq pt1 (vlax-curve-getpointatparam poly 0)) (setq pt2 (vlax-curve-getpointatparam poly 2)) (setq pt3 (mapcar '+ pt1 pt2) ) ; adds (setq pt3 (mapcar '(lambda (x) (/ x 2.0)) pt3)) ; divide by 2 is midpoint (command "text" pt3 "" "" (rtos x 2 0)) (setq x (+ x 1))
0 Likes

devitg
Advisor
Advisor

As to comply with it ..

 

 Hope explained myself sufficiently.

Please upload your sample.dwg

 

And the lisp you use.

 

0 Likes

pitperez
Observer
Observer

Thank you for responding quickly
Forgive my ignorance, in which park of the lisp should I copy the code you give me, at the beginning? at the end?

Best regards

0 Likes

pitperez
Observer
Observer

Good morning.
I attach a file with an example of what I need.
I also attached the lisp that is in this same post.

Best regards

0 Likes

Sea-Haven
Mentor
Mentor

This is a question before Devitg does something do you want 1 table only  with all rectangs ?

0 Likes

pitperez
Observer
Observer

Hi. The table with the data of the rectangles is already done by the lisp that you attached above (rectangle dims by color.lsp), and separated by colors. What I intend is a table like that of the lisp, but that adds a graphic numbering, in the cad drawing, within each rectangle (1, 2, 3, 4, 5, ..... 56) and that numbering also go in the table. For example, that seeing the table see rect n ° 23-27 width 0.37 long 1.34 units 2, and in the cad drawing see at a glance where rectangles 23 and 27 are located. Best regards

0 Likes