Extract footprint from volumes, mesh or solids

Extract footprint from volumes, mesh or solids

Haider_of_Sweden
Collaborator Collaborator
5,082 Views
27 Replies
Message 1 of 28

Extract footprint from volumes, mesh or solids

Haider_of_Sweden
Collaborator
Collaborator

Take a look at this screenshot

exampleexample

 

Can LISP extract the footprint, for example the top-face and bottom-face of these volumes, which could be meshes or solids?

I have a solution how it can be done in 3dsMax, but I am investigating this to be done directly in AutoCAD environment.

0 Likes
Accepted solutions (1)
5,083 Views
27 Replies
Replies (27)
Message 21 of 28

Haider_of_Sweden
Collaborator
Collaborator

@devitg wrote:

Please download the LSP . I forgot a defun and the LAY-COLL 



IN your DWG the regions were in the wrong elevation.

And when I tried out your latest LISP I got an error: ; error: no function definition: ACTV

 

 

@Kent1Cooper wrote:

But I find that the boxy Solids Explode into Regions that all seem to be triangles, and the Solids' faces are made of multiple triangles, not rectangles:
Solid-to-Regions.JPG

@Kent1Cooper  - yeah, this particular model was originally a [very triangulated] mesh - this is how I received it. In real life, things like this can happen - you receive models that aren't exactly how you wish they were.
I thought this could be easily repaired in 3dsMax and then exporting back to DWG. It wasn't really that easy, but doable. 

The "good" thing from real life examples (with problems) is that we're forced to investigate other methods. For example the script from CodeDing that worked perfectly nice with clean solids didn't work at all with this triangulated mesh.

 

@doaiena wrote:

@Haider_of_Sweden wrote:


please keep in mind that the polylines need to be in their correct elevation in 3D. SOLPROF is a 2D tool for layouts.


Are you sure?

If this is the expected result, i might be on to something.


😲 Incredible! I didn't investigate the error message that said "You must be in a Layout to use SOLPROF." more clearly because I assumed it would be a 2d-tool. One might wonder why you have to go to Layout to make it work...

Thank you @doaiena 

 

Here are the steps again

  1. Enter a layout-view
  2. Be in TOP-view
  3. SOLPROF
    1. select objects
    2. Display hidden profile lines on separate layer? NO (choose YES if the model is complex. You might get more more lines. But then, you might also need to do fixes by hand)
    3. Project profile lines onto a plane: NO (if YES; then you get a 2D projection which we do not want in this case)
    4. Delete tangential edges? YES (tangential edges are the side edges and we don't need them either)
  4. We now have a block of all lines. This block needs to be exploded and the lines need to be joined together.

If you need the volumes bottom-footprint as well, follow the above steps but be on the BOTTOM-view.

 

This is one of the best solutions since its fast and doesn't require much and it worked with messy "triangulated solids" (mesh that were converted to solids).

 

Downsides

  • If two identical volumes are next to each other, you will end up having overlapping lines where they touch each other side by side. When selecting all lines to join them, the footprint can end up wrong.
  • if we have two volumes with different heights next to eachother, SOLPROF will catch the upper edge and might miss the lower edge if you selected both of them at the same time during the operation. We will need to select them individually and run SOLRPOF individually.

 

Solution with LISP

I would be thankful if someone is willing to take a look at this. LISP can solve this  by running SOLPROF individually on each of the selected solids, something like this:

  1. go to top view (alternatively layout and then top-view)
  2. run this operation on the solids individuall: SOLPROF NO NO YES
  3. rename layers PH-XXX > TOP-footprint-hidden & PV-XXX > TOP-footprint
  4. go to bottom view (alternatively layout and then bottom-view)
  5. same as above
  6. rename layers to BOTTOM-footprint-hidden & BOTTOM-footprint
0 Likes
Message 22 of 28

devitg
Advisor
Advisor

Hi Haider, please download the new LSP.

As I can see there are  some footprint  with a elevation difference no more than 0.01 m   

The fact is that for some building the BOUNDARYBOX is a little bigger, in that case such point are downward the building bottom.  

My lisp look for the boundarybox point and do a SECTION.

Be clear that the RED footprint are shown apart from the building as a way to see it. But it are at the building botton too

Please show me that elevation difference. 

 

 

 

Message 23 of 28

doaiena
Collaborator
Collaborator
Accepted solution

Just go to a layout, set TOP view and run the command, set BOTTOM view and run again.

(defun c:test ( / ss ctr ent lastEnt ssBlocks ctr2 blk ssLines)

(if (setq ss (ssget '((0 . "3DSOLID"))))
(progn

(setq ctr 0)
(repeat (sslength ss)
(setq ent (ssname ss ctr))

(setq lastEnt (entlast))
(setq ssBlocks (ssadd))
(command "_.solprof" ent "" "n" "n" "y")
(while (setq lastEnt (entnext lastEnt)) (ssadd lastEnt ssBlocks))

(setq ctr2 0)
(repeat (sslength ssBlocks)
(setq blk (ssname ssBlocks ctr2))
(setq lastEnt (entlast))
(setq ssLines (ssadd))
(command "explode" blk)
(while (setq lastEnt (entnext lastEnt)) (ssadd lastEnt ssLines))
(command "pedit" "M" ssLines "" "" "J" 0 "")

(setq ctr2 (1+ ctr2))
);repeat

(setq ctr (1+ ctr))
);repeat ss

));if ss

(princ)
);defun
Message 24 of 28

Haider_of_Sweden
Collaborator
Collaborator
Thanks to everyone providing knowledge and insight!

@CodeDing, I didn't solution-mark your script since it didn't meet the full requirements for this particular task, and to prevent confusion for future visitors of this thread. I did however save it in my library. I am sure the code will come in handy later 😄
Message 25 of 28

CADaSchtroumpf
Advisor
Advisor

Hi,

For mark the minimum z of solids with points.

(defun acis_translate(string / item letter lst)
	(setq string (strcat string" ") item "")
	(while (> (strlen string) 0)
		(setq letter (substr string 1 1) string (substr string 2))
		(if (= " " letter)
			(setq lst (append lst (list item)) item "")
			(setq item (strcat item (chr (- 79 (- (ascii letter) 80)))))
		)
	)
	lst
)
(defun c:mark_Zmin ( / js n pt_lst dxf_ent el data pt pt_lst z_min l_10)
	(setq js (ssget "_X" '((0 . "3DSOLID"))))
	(cond
		(js
			(repeat (setq n (sslength js))
				(setq pt_lst nil)
				(foreach i
					(setq dxf_ent (entget (ssname js (setq n (1- n)))))
					(and
						(= (car i) 1)
						(setq el (acis_translate (cdr i)))
						(cond
							((eq (car el) "point")
								(setq
									data (cdr (cdddr el))
									pt (list (atof (car data)) (atof (cadr data)) (atof (caddr data)))
									pt_lst (cons pt pt_lst)
									z_min (apply 'min (mapcar 'caddr pt_lst))
									pt_lst (vl-remove-if-not '(lambda (x) (equal (caddr x) z_min 1E-13)) pt_lst)
									l_10 (mapcar '(lambda (x) (cons 10 (list (car x) (cadr x)))) pt_lst)
								)
							)
						)
					)
				)
				(if l_10
					(repeat (length l_10)
						(entmake
							(list
								(cons 0 "POINT")
								(cons 100 "AcDbEntity")
								(assoc 67 dxf_ent)
								(assoc 410 dxf_ent)
								(cons 8 (getvar "CLAYER"))
								(if (assoc 62 dxf_ent) (assoc 62 dxf_ent) (cons 62 256))
								(if (assoc 6 dxf_ent) (assoc 6 dxf_ent) (cons 6 "BYLAYER"))
								(if (assoc 370 dxf_ent) (assoc 370 dxf_ent) (cons 370 -1))
								(cons 100 "AcDbPoint")
								(append (car l_10) (list z_min))
								'(210 0.0 0.0 1.0)
							)
						)
						(setq l_10 (cdr l_10))
					)
				)
			)
		)
	)
)

 

Message 26 of 28

Haider_of_Sweden
Collaborator
Collaborator
@CADaSchtroumpf - thank you! This can come in handy. Maybe I can use the points to create Land Areas in Infraworks (need to investigate)
For the sake of having options - could you create one more LISP for points at the maximum z of the solids? 🙂
0 Likes
Message 27 of 28

CADaSchtroumpf
Advisor
Advisor

@Haider_of_Sweden  a écrit :
@CADaSchtroumpf
For the sake of having options - could you create one more LISP for points at the maximum z of the solids? 🙂

It's easy, the most important find and replace 'min by 'max

you can also change variable name: find and replace z_min by z_max and replace the function name c:mark_Zmin by c:mark_Zmax.

NB: Work only with 3Dsolid mesh, not with box!

0 Likes
Message 28 of 28

devitg
Advisor
Advisor

Using any 3 point you can SECTION , and get the building bottom area 

 

(setq basepoint pt_lst)
(setq pt0 (nth 0 basepoint))
(setq pt1 (nth 1 basepoint))
(setq pt2 (nth 2 basepoint))

(setq pt0-vl (vlax-3d-point pt0))
(setq pt1-vl (vlax-3d-point pt1))
(setq pt2-vl (vlax-3d-point pt2))

(setq section (vla-SectionSolid 3d-obj pt0-vl pt1-vl pt2-vl))

 

0 Likes