Jump to content

Close off a door Autolisp


alevans

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Edited by ronjonp
  • Like 1
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

Sorry guys, not around everyday. Just wanted to say thanks again everyone, and to everyone else looking for similar solutions, it will work as illustrated above.

 

A

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...