Intersect objects

Intersect objects

t_ott
Contributor Contributor
1,273 Views
0 Replies
Message 1 of 1

Intersect objects

t_ott
Contributor
Contributor

Hello everyone,

I found the LISP "foo" (2019) by Ron Perez (ronjonp) here:

https://www.cadtutor.net/forum/topic/67156-create-polygons-at-intersections/

 

(Compared to the original, I have already removed the deletion of the original polygon.)

 

(defun c:foo (/ r o n s)
  ;; RJP » 2019-04-03
  (cond	((and (setq s (ssget ":L" '((0 . "circle,ellipse,lwpolyline,spline"))))
	      (setq s (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
	      (setq s (vl-remove-if-not '(lambda (x) (vlax-curve-isclosed x)) s))
	      (setq n (vlax-ename->vla-object (cdr (assoc 330 (entget (car s))))))
	      (setq s (vl-sort (mapcar 'vlax-ename->vla-object s)
			       '(lambda (a b) (> (vlax-curve-getarea a) (vlax-curve-getarea b)))
		      )
	      )
	 )
	 (setq r (car (vlax-invoke n 'addregion (list (car s)))))
	 (setq o (vlax-invoke n 'addregion (cdr s)))
	 (mapcar (function (lambda (x) (vla-boolean (vla-copy r) acintersection x))) o)
	)
  )
  (princ)
)
(vl-load-com)

 

 

I think it's really great and would like to use it for my purposes if I may?

But then it would have to be changed and unfortunately I'm failing at that.

That's why I'm asking here in the hope that someone can help me?

I've attached an example file that should help you understand what I want.

Here's a short summary of the question:

I have several holding areas (layer: Flaeche)

Then there are road areas (Strasse) and building areas (Gebaeude)

In the DWG the layer is called "Gebaude", I made a typo.

Now I want the road and building areas to be intersected with the holding areas.

If possible, the newly created polygons should then be saved on a new layer:
Road areas = Strasse_cut
Building areas = Gebaeude_cut

Now it would be great if this Lisp could work in a loop until all the areas have been processed.
If that doesn't work, that wouldn't be a problem, then I would control it using Excel and VBA via the handles of the polygons.

I would be happy if someone could help me with this.

 

Thanks in advance,

Tom

0 Likes
1,274 Views
0 Replies
Replies (0)