Lisp to get total length (or areas) for different walls as per their thickness in auto cad

Lisp to get total length (or areas) for different walls as per their thickness in auto cad

sajid727
Contributor Contributor
1,158 Views
15 Replies
Message 1 of 16

Lisp to get total length (or areas) for different walls as per their thickness in auto cad

sajid727
Contributor
Contributor

I need a lisp to get the total length (or area) of walls for different thickness of walls of 100mm, 150mm, 200mm and 300 thickness. Drawing is attached for the walls.

 If there is a lisp which can do different hatch for different thickness areas, the result area can be obtained.

The result has to be:

Total length (or area) for 100mm thick wall=________m (or m2)

Total length (or area) for 150mm thick wall=________m (or m2)

Total length (or area) for 200mm thick wall=________m (or m2)

Total length (or area) for 300mm thick wall=________m (or m2)

0 Likes
1,159 Views
15 Replies
Replies (15)
Message 2 of 16

Moshe-A
Mentor
Mentor

@sajid727  hi,

 

i suggest on a different layer put separate closed polylines around the walls according to wall width. if you do that, it would be easy to select the walls and put hatch on them and take length \ area

 

Moshe

 

0 Likes
Message 3 of 16

-didier-
Advisor
Advisor

Bonjour @sajid727 

 

I propose you an example of drawing that will easily allow to make a listing of the different lengths and surfaces.

All wall types have an axis line, just measure it and multiply it by the value of the wall, and it’s done.
Do you need help to create this listing?

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 4 of 16

sajid727
Contributor
Contributor

Is it possible to have a lisp so as to hatch areas of walls of same widths with same pattern and the walls of other widths with different pattern.

For example- all 200mm thickness walls as one pattern and so on for other walls.

0 Likes
Message 5 of 16

Moshe-A
Mentor
Mentor

@sajid727 ,

 

well, that's depend on what CAD system you have, on AutoCAD for Architects if you use wall tool, you can get hatch and others properties, but if you only have AutoCAD vanila the walls you see on yours eyes,  form AutoCAD eyes it only simples lines. you can achieve what you want only if you make it close plines.

 

Moshe

 

0 Likes
Message 6 of 16

-didier-
Advisor
Advisor

Bonjour @sajid727 

 

Of course, it is possible, but, to avoid errors and make the programming easier, it is better to have a perfectly structured drawing.
The best solution is a serious management of layers.
We can do it without, but with it is much simpler and more precise.

Here is a new example of correct drawing.

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 7 of 16

Sea-Haven
Mentor
Mentor

The external walls in the image are 4 layers so could get a list of their lengths. Like others walls have been drawn on multi layers. You almost need non plot layers that are one side of the walls, these can be found and tallied, I can not see any quick way to work out length of a wall that is say 150 then go 90 degrees and is 300. I have some drag over functions that are used in the software that made image they set wall thickness for new walls. That would mean labelling every wall section manually. I think only way is to make a pline with width as was previously mentioned as make skinny rectangs, on a layer that you turn off. You need a draw walls function so the pline is made at same time as wall linework. 

 

This works for some of the line work, just an idea. Note freeze the exploded hatch a problem.

(defun c:plinwall ( / pt1 pt2 pt3 pt4 mp dist)

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(while (setq pt1 (getpoint "\nPick pt1 "))
(setq pt2 (getpoint pt1 "\nPick pt1 2 "))
(setq pts (list pt1 pt2))
(setq ss (ssget "F" pts '((0 . "LINE"))))
(setq pt3 (vlax-curve-getclosestpointto (vlax-ename->vla-object (ssname ss 0)) pt1))
(setq pt4 (vlax-curve-getclosestpointto (vlax-ename->vla-object (ssname ss 1)) pt1))
(setq mp (mapcar '* (mapcar '+ pt4 pt3) '(0.5 0.5)))
(setq dist (distance pt3 pt4))
(setq d1 (distance pt1 pt3))
(setq d2 (distance pt1 pt4))
(if (> d1 d2)
  (command "offset" (/ dist 2.0) (ssname ss 1) mp "")
  (command "offset" (/ dist 2.0) (ssname ss 0) mp "")
)
(command "pedit" (entlast) "Y" "w" dist "")
)

(princ)
)

 

 

0 Likes
Message 8 of 16

sajid727
Contributor
Contributor

I tried the lisp ,not working. It shows: Error, bad argument.

0 Likes
Message 9 of 16

sajid727
Contributor
Contributor

Hello. Can you please help to create the listing and also guide how to draw centerline (axis line) as shown in the drawing you attached. Is there any lisp for it?

0 Likes
Message 10 of 16

Sea-Haven
Mentor
Mentor

Did you turn off the hatching which is actually lines in your Wall.dwg. This will stuff up the selection.

 

SeaHaven_0-1734653832937.png

Also note in some places you have 3 lines two yellow and a brown, you need to turn that layer off as well. Or pick carefully between the yellow and brown.

SeaHaven_1-1734654003658.pngSeaHaven_2-1734654060367.png

 

 

0 Likes
Message 11 of 16

sajid727
Contributor
Contributor

Hello. Thanks for your support. Can you please help to create the listing and also guide how to draw centerline (axis line) as shown in the drawing you attached. Is there any lisp for it?

0 Likes
Message 12 of 16

-didier-
Advisor
Advisor

Bonjour @sajid727 

 

I did not work for the drawing of axis lines.
I let you do it because you can do it. It’s your drawing, and you know the thicknesses, it’s very easy.
Of course, we can imagine a lisp, but we must not believe that programming is there for that, we program to do more complicated tasks than drawing by hand.

I started from the assumption that axis polylines exist and in the right layers
Here is the rendering of my program, tell me if it’s ok and I deliver you the program.

 

Amicalement.


2024-12-22_13-58-01.gif

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 13 of 16

sajid727
Contributor
Contributor

Hello @-didier- 

Yes, it's perfect. Thank you. Please deliver the program to me.

0 Likes
Message 14 of 16

sajid727
Contributor
Contributor

Hello Sir, Can you please deliver the program. 

0 Likes
Message 15 of 16

Sea-Haven
Mentor
Mentor

"I started from the assumption that axis polylines exist and in the right layers" 

 

@sajid727 I did not see in your dwg any Axis lines. So you need to draw those as part of the drawing walls procedure, the code suggested by @-didier- uses those lines. What I posted makes those lines with a pline width. 

 

Looking at this image may be a way to make the center line, I have picked two wall edges so that I get a start and end length for all the wall may be more than 2 nibs. No code at moment. 

 

SeaHaven_0-1735446908463.png

What I previously posted sometimes would overlap walls. This idea may be better. Need some time.

0 Likes
Message 16 of 16

-didier-
Advisor
Advisor

Bonjour @sajid727 

 

Sorry for the late, this holiday season keeps us away from computers, and that’s a good thing from time to time.


As I said, it is necessary that the axes exist (polylines), in layers with specific names, it is drawing “by hand”.

I have not made a code for this currently.

I wish you a good use and I will look at your comments to know how to react.

I give you a drawing example and the program.

 

Amicalement

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes