Jump to content
alevans

Close off a door Autolisp

Recommended Posts

alevans

Hi everyone, I'm looking to close off a door in auto cad. Basically I want to extend a line between the center of an arc and its start point. Basically though, I am trying to loop through a drawing and do this for all doors (there are many!). I've attached a picture, where the door is in purple, and the part I am trying to extend is blue. It would be even better if I could get the wall (in red), to do this extension. Note: The arc and connecting purple line are not one solid poly line but separate entities (however they are on the same layer), and the wall (in red) is a separate layer.

 

Thanks,

 

A

 

doors.PNG.2a312923c316c87b22ce570dddb1da72.PNG

Share this post


Link to post
Share on other sites
marko_ribar

If I were you, I would already drawn that line manually - I mean - how did you draw door specification - you certainly haven't used automatic insertions between wall openings... Even if you had door block - but you stated that it's line and arc, you probably had to manually position them in correct orientation according to wall... So my suggestion - you don't have millions of doors to process, just draw that line and at the end freeze layer of doors...

  • Like 1

Share this post


Link to post
Share on other sites
alevans
Posted (edited)

Hi Marko, thanks for the reply.

 

I actually have not designed these drawings, and am not an architect or civil engineer. I am fairly new to autocad and autolisp (basic working proficiency), and am tasked with automating certain things. The idea behind these lines is the eventual creation of a boundary. I have managed to simplify my floor plan down to a before and after, with the differences highlighted. The reason I cannot manually draw these lines is that I do not know how many of these dwg files will eventually need to be processed, so am looking for a general solution.

 

Right now I have 3 layers of broken walls and am trying to connect them via 90 degree angles. A picture would probably better illustrate this.

 

This is what I am looking to accomplish.

 

[EDIT: Please don't worry about the text, I have deleted that. Also the yellowed circle object is not a big problem either]

 

Thanks,

 

A

 

before.PNG.bc401a4149f96e72999cf0007307836c.PNGAfter.thumb.PNG.60c800d16eafa649ac6559f879b74ad1.PNG

Differences.PNG

Edited by alevans
Forgot to include some specifications, sorry

Share this post


Link to post
Share on other sites
BIGAL

Agree with Marko If I draw a door I draw all of it including the door frame but I have a lisp to do it, it asks the relevant questions how far from edge size of door left right in/out and all done. It copyrighted.

 

 

3dhouse.jpg

  • Like 1

Share this post


Link to post
Share on other sites
ronjonp
Posted (edited)

If your doors are blocks just add that linework to the block definition on a different layer. Never mind just read your post more closely.

Edited by ronjonp
  • Like 1

Share this post


Link to post
Share on other sites
BIGAL

Serach for door lisp I am sure there are some free ones out there, mine takes into account intelligence about the wall its inserting into.

  • Like 1

Share this post


Link to post
Share on other sites
ronjonp

You could use a dynamic block with a mask, then you don't need to break the walls.

  • Like 1

Share this post


Link to post
Share on other sites
alevans

Thanks everyone, I will try to implement these solutions.

 

A

Share this post


Link to post
Share on other sites
ronjonp

Post a sample of your drawing, if you need code to cleanup these existing plans I have an idea.

Edited by ronjonp
  • Like 1

Share this post


Link to post
Share on other sites
alevans

Hey ron(or jon?), here's the sample. Cheers man, Thanks.

 

A

Sample.dwg

Share this post


Link to post
Share on other sites
ronjonp
On 10/11/2018 at 6:34 PM, alevans said:

Hey ron(or jon?), here's the sample. Cheers man, Thanks.

 

A

Sample.dwg

Give this a try for closing the doors that consist of a line and an arc on layer "A_DOOR_FULL" .. looking at that drawing I'd recommend some consistency first 😜

(defun c:foo (/ _get b c d s)
  ;; RJP » 2018-10-12
  ;; Closes doors on a common layer that consist of an arc and a line
  (defun _get (e) (list (vlax-curve-getstartpoint e) (vlax-curve-getendpoint e)))
  (cond
    ;; Layer filter below '(8 . "A_DOOR_FULL")'
    ((setq s (ssget "_x" '((0 . "line,arc") (8 . "A_DOOR_FULL"))))
     (foreach a	(vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
       (if (= "LINE" (cdr (assoc 0 (entget a))))
	 (setq b (cons (_get a) b))
	 (setq c (cons (_get a) c))
       )
     )
     (foreach p	b
       (cond
	 ((setq	d (vl-some '(lambda (x)
			      (if (or (equal (setq e (car p)) (car x) 1e-8)
				      (equal (setq e (car p)) (cadr x) 1e-8)
				      (equal (setq e (cadr p)) (car x) 1e-8)
				      (equal (setq e (cadr p)) (cadr x) 1e-8)
				  )
				x
			      )
			    )
			   c
		  )
	  )
	  (setq d (vl-remove-if '(lambda (x) (equal e x 1e-8)) (append d p)))
	  (entmakex (list '(0 . "LINE") (cons 10 (car d)) (cons 11 (cadr d)) '(8 . "DoorClosed")))
	 )
       )
     )
    )
  )
  (princ)
)

 

2018-10-12_6-50-56.png

Edited by ronjonp
  • Like 1

Share this post


Link to post
Share on other sites
alevans

Ronjon, you're a genius! Thank you so much man.

 

It works for the yellow checked doors, but not the other ones (hinged?). I tried to switch this line

(0 . "line,arc") (8 . "A_DOOR_FULL")

to ( 0 . "polyline, arc") to see if it would select the other ones, but no luck.

 

Exploding all of the poly-lines gets something close, and we end up with the other picture.

 

I have spent some time trying to disassemble your code to modify it slightly, but was unsuccessful.

 

I tried to delete inner line of door, merge layers, fiddle with the code variables, but no luck.

 

I really appreciate the help everyone, my head is spinning.

 

I'll pay it forward.

 

EDIT: For certain drawings this is perfectly ok. Once again, thanks everyone

 

A

acad.PNG

Other.PNG

Edited by alevans
Forgot to add something

Share this post


Link to post
Share on other sites
ronjonp
On 10/13/2018 at 5:53 PM, alevans said:

Ronjon, you're a genius! Thank you so much man.

 

It works for the yellow checked doors, but not the other ones (hinged?). I tried to switch this line


(0 . "line,arc") (8 . "A_DOOR_FULL")

to ( 0 . "polyline, arc") to see if it would select the other ones, but no luck.

 

Exploding all of the poly-lines gets something close, and we end up with the other picture.

 

I have spent some time trying to disassemble your code to modify it slightly, but was unsuccessful.

 

I tried to delete inner line of door, merge layers, fiddle with the code variables, but no luck.

 

I really appreciate the help everyone, my head is spinning.

 

I'll pay it forward.

 

EDIT: For certain drawings this is perfectly ok. Once again, thanks everyone

 

A

 

Glad to help out :) . Your other doors get a bit more complicated to check. That's why I suggested some consistency ... dynamic blocks are perfect for this application.

Share this post


Link to post
Share on other sites
BIGAL

Whilst ronjonp has provide a real good answer I would still look at ignoring what you have and start from scratch and make some draw door routines there are not that many combos, 2 line walls or 4 lines wall etc and the door its self has only 4 combinations left-right, in-out.    

 

You start by picking say near an end of a line, nominate offset from say corner then width of door and other wall side then break and draw door. 

 

 

Screen Shot 10-16-18 at 01.01 PM.PNG

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×