Automatic length, width and area calculation of rectangle into tabular form.

Automatic length, width and area calculation of rectangle into tabular form.

kcsushantkc
Explorer Explorer
5,203 Views
21 Replies
Message 1 of 22

Automatic length, width and area calculation of rectangle into tabular form.

kcsushantkc
Explorer
Explorer

Hi, guys hope all of you are staying safe and doing best from yourself. I am an electrical engineer by profession while doing some of the research for my work I came across this .lsp code written by our lee mac programming kudos to them. This code calculates the area of the rectangle and shows it in tabular form. I wanted to edit this code which can also display the length, width, and area of the selected rectangle respectively. Can anybody help me with this one? I've attached the code and recent output and wanted output pictures herewith for reference.
PS: I don't want to change anything on code it is working flawlessly just wanted to add length and width column sections on the above code. Feel free to contact me regarding any confusions 🙂
Thanks in advance.
Stay safe, stay home.

0 Likes
Accepted solutions (1)
5,204 Views
21 Replies
Replies (21)
Message 2 of 22

Sea-Haven
Mentor
Mentor

I am pretty sure rather than start editing code just goggle your question is a pretty standard request.

0 Likes
Message 3 of 22

pbejse
Mentor
Mentor

Where are the Length and Width information stored? Assuming every point the user select is rectangular in shape? are they the objects Length and Width? What of irregular shape rooms/plot/etc.. ?

 

 

 

0 Likes
Message 4 of 22

kcsushantkc
Explorer
Explorer

Hi, thank you for your reply. Right now I'm assuming every point user select is rectangular shape only. If an irregular shape is considered then there my might be too much conflict so I want it to be simple.
And, for length and width information storage I didn't get you.

0 Likes
Message 5 of 22

kcsushantkc
Explorer
Explorer

Thank you for your enthusiasm. Yes, I've searched a lot this is the nearest which will fulfill my current demand. I've found another code but, it shows length and width only and creates the one table at a time rather than a continuous array. This code only fulfills only the dimensional requirement (ie: extraction of length and width only). I've attached that code if you want to have a look at it.

0 Likes
Message 6 of 22

pbejse
Mentor
Mentor

@kcsushantkc wrote:

..And, for length and width information storage I didn't get you.


 

I was hoping there would be another source for that data, Anyway, we will add the options of Lenght and Width without too much altering the original code.

 

Writing mod...

 

 

 

0 Likes
Message 7 of 22

pbejse
Mentor
Mentor
Accepted solution

Wish i could spend more time with this. I made a quick mod of the lisp file AreaLabelV1-9.lsp

Added Length and Width 

 

The value would be "-" for both Length and Width

  • if an irregular shape  is selected object
  • if a region is selected
  • if the boundary detected by "pick" mode
  • if the HPMODE is 0

Field values for Area only for "Object" mode [ as per original routine ]

 

The additional columns will only be available for table mode only  [ AT ]

AreaLabelV1-9.1.lsp

Screencast: https://autode.sk/2xC3CmG

 

Message 8 of 22

kcsushantkc
Explorer
Explorer

This is exactly what I've been looking after thank you so much.

If that area column could be on "column 4" and width table could be on "column 2" that would help me more🙂.

Thanks to @pbejse 

0 Likes
Message 9 of 22

pbejse
Mentor
Mentor

@kcsushantkc wrote:

If that area column could be on "column 4" and width table could be on "column 2" that would help me more🙂.


 

Sure

AREA to WIDTH , WIDTH TO AREA, got it ...

Refer to attached lisp file | AreaLabelV1-9.2.lsp

 


@kcsushantkc wrote:

Thanks to @pbejse 


 

You are Welcome

 

Cheers

 

Message 10 of 22

Woon22
Contributor
Contributor

Hi, I know this is an older discussion but I am curious if it would be possible to modify this lisp to do a few things: 

1. Number areas that are the same size as the same number?

2. Add a quantity for the areas in the table? 

I have been trying to learn some lisp programming to accomplish this but so far I am still in the beginner stages and feel like I have a lot to learn about it (and probably about proper forum educate). Let me know if you have any thoughts on this. 

Thanks, 

0 Likes
Message 11 of 22

Sea-Haven
Mentor
Mentor

There was code for do a table and have the area numbers corresponding in a cell, would that be useful ? But will have to look for it.

 

To add the numbers like A1 A2 etc requires a list containing areas and the entity names, then can be matched a bit involved but doable just not a 5 minute job unless code exists.

0 Likes
Message 12 of 22

Woon22
Contributor
Contributor

It could be useful, at the moment anyway to combine parts that are alike would be greatly beneficial for this lisp. I found a lisp program that creates a table of height and width for a rectangle, along with a count for the parts. This lisp program combines alike parts, but it does not number them. I thought it may be possible to combine parts by having the code compare area values, with if statements to declare the names as the same. Once again, I do not know too much, and I have only just been reading and watching a lot of YouTube tutorials on lisp trying to get somewhere (I have multiple ideas for lisps that would be useful to me but this would be best). 

 

 

0 Likes
Message 13 of 22

Woon22
Contributor
Contributor

Since I have no idea what I am doing but I do want to begin to learn, I wrote code to extract the length and width of a rectangle and set those variables to len and wid. I had to do it step by step and I know there are faster ways out there, but I am starting somewhere. The next goal is to add numbers centered in the rectangle and then count them (if two rectangles' lengths and width are the same then it will give them the same number). Any advise for this code would be greatly appreciated, (even if it's just explaining better ways of obtaining the data). I don't expect to be able to accomplish my goals over one weekend but I have been obsessing over this lol.

 

;;Program that prompts user to pick area, then stores length and width to variable;;
(defun c:Rectanglenwid()
	(setq pt1(getpoint))
	(setq pt2 (entlast))
	(command "_.BPoly" pt1 "")
	(setq poly(entlast))
	(setq pbd(entget poly)) 
			 (foreach sublist pbd
			 	(if (= (car sublist) 10)
					(setq list1(cons (cdr sublist) list1))))
		(setq list1x(car(car list1)))
		(setq list1y(cadr(car list1)))
		(setq list2x(car(caddr list1)))
		(setq list2y(cadr(caddr list1)))
		(setq len(abs (- list1x list2x)))
		(setq wid(abs (- list1y list2y)))
);end
	

 

0 Likes
Message 14 of 22

edCLUK9
Community Visitor
Community Visitor

I'm not an Autodesk guy but a marketing guy.  A "Square inch analysis" is done to analyze the Value of block of common advertised products.  i.e. measure the space and divide the sqin into the sales (or profit ).

This is typically done manually by a clerk measuring the sides, computing the sqin and entering into a spreadsheet.

Per the attached, I would like to "automate" this process.  We produce multiple catalogs varying from 65 to 184 pages several times a year and it behooves us to manually do all of these calculations for every issue.

Per the thread i "googled" you seem to have a handle on automating these calculations - perhaps by custom code or an organic part of the program built in.

Refer to my attached image;

In the best of all worlds, I would like to "mark up" the blocks by page, scan the pages and create a spreadsheet of all of the sqin by marked area.

Attached is one of 184 catalog pages to give a sense of the problem.

By the way, Solving this problem would find HUGE interest in the Catalog industry who all experience the identical problem.  It could be sold as an online service or a standalone app.

0 Likes
Message 15 of 22

Woon22
Contributor
Contributor

The program Bluebeam has an area calculator built into it, if you use Bluebeam you can use the measurement tool to create a rectangle over the area and set the scale so that 1"=1" so if you have the catalogs scanned this may be an option. Maybe that'll help?

0 Likes
Message 16 of 22

pbejse
Mentor
Mentor

@edCLUK9 wrote:

Attached is one of 184 catalog pages to give a sense of the problem.

...


Its not much of a problem if theres a pattern that we can follow and organize.

Dont tell me all you have are scanned pages of the catalog? You could've at least use a scanner with OCR capability.

 

0 Likes
Message 17 of 22

edCLUK9
Community Visitor
Community Visitor
I have .pdf of the entire catalog.
0 Likes
Message 18 of 22

Sea-Haven
Mentor
Mentor

Going back a step what software made the catalog ? Or do you only have the pdf. 

 

Very limited like photoshop etc but each section may be something that software can output.

 

Like Pbe if red lines can be recognised as CAD lines somehow then may be doable. Else just bring in page and draw a sequence of rectangs with a few smarts like where to start next. But 180 times phew !

0 Likes
Message 19 of 22

Kyle.Pederson
Advocate
Advocate

@pbejse Would it be possible to have this lisp shown as instead of Number 1, Number 2 etc shown as Section A, Section B etc?

0 Likes
Message 20 of 22

edCLUK9
Community Visitor
Community Visitor
Yes can do it that way
0 Likes