Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

single door Lisp......... again!

23 REPLIES 23
SOLVED
Reply
Message 1 of 24
Rroger_D
10733 Views, 23 Replies

single door Lisp......... again!

Hi,

 

I know this has been done to death, sorry. Just searched and it came up with 7+ pages! However, a cheeky one if anyone doesn't mind. Perhaps a 10 minute task for those who know how? :-).

 

With CAD speed all about reducing key-strokes I reckon (hope) to reduce a door insertion from 30 key-strokes to 4 key strokes with a Lisp.

 

Aim

Creates a 2D Polyline of width 15mm at 90degs to the wall opening, of length as per the opening, with an arc from end of the line to the end of the opening. All on layer 'door'. Leaving door opening itself, clear.

 

Aim for operator use:

- 'd'

- 'start point?'

- 'end point?'

- 'side?'

 

If I explain the current operations, in full, then you will see what I am aiming to automate:

- F8 (ortho off)

- C (circle)

- click start of door opening

- click end of door door opening

- SN (snap-angle)

- click start of door opening

- click end of door door opening

- F8 (ortho on)

- PL (Polyline)

- click start of door opening

- click to door opener side past circle circumference (90 degs)

- T (trim)

- select newly created PL, circle and bounding line currently at the end point of the opening

- select all parts to be trimmed (end of PL) and three-quarters of the circle

- click PL

- change it's global width to 0.015 (units are already set to be metres)

- click the arc (as well as the PL)

- change both elements to layer 'Door'

 

I think that's it. Simple in operation but lengthy. I know that there is a better solution.

 

Many thanks in advance. I accept that I may be told to 'go off and learn Lisp' but, worth a try.

 

Thanks.

 

R

 

PS - Another one simple one. Completely different if I may ...... 🙂

 

Operator aim:

- press 'K'

- initiates the 3DORBITERCTR command with the snap to NOD

 

 

 

Currently, I have to every time, press 'k' (why 'k' I don't know) and then 'n', 'o', 'd', enter. It seems silly to have to do this EVERY time.

 

Thanks.

 

R

23 REPLIES 23
Message 2 of 24
hak_vz
in reply to: Rroger_D

Try this.

I hope it covers all combination, for horizontal, vertical and inclined wall.

By mixing start and end point create opposite side.

 

 

(defun c:dd ()
(setq lyr (tblsearch "layer" "door"))
(if (not lyr)  (command "._layer" "_M" "door"  "_Lt" "Continuous" "door" ""))
(initget 1 "l r")
(setq side (getkword "\nside l/r >"))
	(cond 
		((eq side "L")
			(setq
				pt1 (getpoint "\nselect start point left >")
				pt2 (getpoint "\nselect end point right >")
				di (distance pt1 pt2)
				ang1 (angle pt1 pt2)
				ang2 (+ ang1 (/ pi 2))
				pt3 (polar pt1 ang2 di)
				di (distance pt1 pt2)
			)
			(entmake
				(list
					(cons 0  "lwpolyline") 
					(cons 8 "door")
					(cons 90 4)	
					(cons 43 0.015)					
					(cons 10 pt1)
					(cons 42 0)
					(cons 10 pt2)
					(cons 42 0.414214)
					(cons 10 pt3)
					(cons 42 0)
					(cons 10 pt1)
					(cons 42 0)
				)
			)	
		)
	)
	(cond 
		((eq side "R")
			(setq 
				pt1 (getpoint "\nselect start point right >")
				pt2 (getpoint "\nselect end point left >")
				di (distance pt1 pt2)
				ang1 (angle pt1 pt2)
				ang2 (- ang1 (/ pi 2))
				pt3 (polar pt1 ang2 di)
				di (distance pt1 pt2)
			)
			(entmake
				 (list
					(cons 0  "lwpolyline") 
					(cons 8 "door")
					(cons 90 4)	
					(cons 43 0.015)						
					(cons 10 pt1)
					(cons 42 0)
					(cons 10 pt3)
					(cons 42 0.414214)
					(cons 10 pt2)
					(cons 42 0)
					(cons 10 pt1)
					(cons 42 0)
				)	
			)				
		)
	)
(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 3 of 24
marko_ribar
in reply to: Rroger_D

I've modified it slightly (localization of variables, some minor lacks,...), but all the job is done by @hak_vz...

 

(defun c:dd ( / lyr side pt1 pt2 di ang1 ang2 pt3 )
(setq lyr (tblsearch "layer" "door"))
(if (not lyr)  (command "._layer" "_M" "door"  "_Lt" "Continuous" "door" ""))
(initget 1 "Left Right")
(setq side (getkword "\nSide [Left/Right] : "))
(if (eq side "Left")
 (progn
  (setq
   pt1 (getpoint "\nPick or specify start point left >")
   pt2 (getpoint "\nPick or specify end point right >")
   di (distance pt1 pt2)
   ang1 (angle pt1 pt2)
   ang2 (+ ang1 (/ pi 2.0))
   pt3 (polar pt1 ang2 di)
  )
  (entmake
   (list
    (cons 0 "LWPOLYLINE")
    (cons 100 "AcDbEntity")
    (cons 100 "AcDbPolyline")
    (cons 8 "door")
    (cons 90 3)
    (cons 70 (1+ (* 128 (getvar 'plinegen))))
    (cons 43 0.015)
    (cons 10 pt1)
    (cons 42 0.0)
    (cons 10 pt2)
    (cons 42 (/ (sin (/ pi 8.0)) (cos (/ pi 8.0))))
    (cons 10 pt3)
    (cons 42 0.0)
   )
  )
 )
 (progn
  (setq 
   pt1 (getpoint "\nPick or specify start point right >")
   pt2 (getpoint "\nPick or specify end point left >")
   di (distance pt1 pt2)
   ang1 (angle pt1 pt2)
   ang2 (- ang1 (/ pi 2.0))
   pt3 (polar pt1 ang2 di)
  )
  (entmake
   (list
    (cons 0 "LWPOLYLINE")
    (cons 100 "AcDbEntity")
    (cons 100 "AcDbPolyline")
    (cons 8 "door")
    (cons 90 3)	
    (cons 70 (1+ (* 128 (getvar 'plinegen))))
    (cons 43 0.015)
    (cons 10 pt1)
    (cons 42 0.0)
    (cons 10 pt3)
    (cons 42 (/ (sin (/ pi 8.0)) (cos (/ pi 8.0))))
    (cons 10 pt2)
    (cons 42 0.0)
   )
  )
 )
)
(princ)
)

HTH., M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 4 of 24
hak_vz
in reply to: marko_ribar

Thank you @marko_ribar for fine tuning my unpolished code, written on the fly during my coffee brake.   

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 5 of 24
zph
Collaborator
in reply to: Rroger_D

Rroger_D,

 

Have you considered creating a dynamic block to accomplish this task?

 

~Z

Message 6 of 24
hak_vz
in reply to: marko_ribar

Just a single correction   (getvar "plinegen") instead of (getvar 'plinegen)

 

 

 

(defun c:dd ( / lyr side pt1 pt2 di ang1 ang2 pt3 )
(setq lyr (tblsearch "layer" "door"))
(if (not lyr)  (command "._layer" "_M" "door"  "_Lt" "Continuous" "door" ""))
(initget 1 "Left Right")
(setq side (getkword "\nSide [Left/Right] : "))
(if (eq side "Left")
 (progn
  (setq
   pt1 (getpoint "\nPick or specify start point left >")
   pt2 (getpoint "\nPick or specify end point right >")
   di (distance pt1 pt2)
   ang1 (angle pt1 pt2)
   ang2 (+ ang1 (/ pi 2.0))
   pt3 (polar pt1 ang2 di)
  )
  (entmake
   (list
    (cons 0 "LWPOLYLINE")
    (cons 100 "AcDbEntity")
    (cons 100 "AcDbPolyline")
    (cons 8 "door")
    (cons 90 3)
    (cons 70 (1+ (* 128 (getvar "plinegen"))))
    (cons 43 0.015)
    (cons 10 pt1)
    (cons 42 0.0)
    (cons 10 pt2)
    (cons 42 (/ (sin (/ pi 8.0)) (cos (/ pi 8.0))))
    (cons 10 pt3)
    (cons 42 0.0)
   )
  )
 )
 (progn
  (setq 
   pt1 (getpoint "\nPick or specify start point right >")
   pt2 (getpoint "\nPick or specify end point left >")
   di (distance pt1 pt2)
   ang1 (angle pt1 pt2)
   ang2 (- ang1 (/ pi 2.0))
   pt3 (polar pt1 ang2 di)
  )
  (entmake
   (list
    (cons 0 "LWPOLYLINE")
    (cons 100 "AcDbEntity")
    (cons 100 "AcDbPolyline")
    (cons 8 "door")
    (cons 90 3)	
    (cons 70 (1+ (* 128 (getvar "plinegen"))))
    (cons 43 0.015)
    (cons 10 pt1)
    (cons 42 0.0)
    (cons 10 pt3)
    (cons 42 (/ (sin (/ pi 8.0)) (cos (/ pi 8.0))))
    (cons 10 pt2)
    (cons 42 0.0)
   )
  )
 )
)
(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 7 of 24
Rroger_D
in reply to: hak_vz

Hi,

 

Sorry for the delay in getting back. Just wanted to try a few things out etc.

 

Thank you very much for your time spent each of you in putting together this Lisp. Certainly not a five minute job it seems 🙂 Certainly thank you all the same.

 

 

What are my chances of having a few changes made to it, perhaps....? The Lisp routine certainly does the job but for my needs, just needs a couple of tweaks.

 

I've attached a screen-shot of where we're at (bottom) and the desired (top).

 

- it is only the door leaf that needs to be 'global-width' 0.015, not the arc;

- the line across the door opening should be omitted.

 

- Is there a possibility of having the 'side' determined by a mouse click rather than having to type it in? ie start-point, end-point, side.

- And then finishing off by exploding the block?

 

I know I'm being cheeky in asking but as they say, if you don't ask you don't get 🙂

 

In answer to zph, I did try a dynamic block but that seems to change the door thickness as the block is scaled bigger or smaller.

 

Thanks again to everyone.

 

R

 

Message 8 of 24
hak_vz
in reply to: Rroger_D


@Rroger_D wrote:

Hi,

 

Sorry for the delay in getting back. Just wanted to try a few things out etc.

 

 

- it is only the door leaf that needs to be 'global-width' 0.015, not the arc;

- the line across the door opening should be omitted.


What should be thickness of arc. Line across the door will be fixed.

 



- Is there a possibility of having the 'side' determined by a mouse click rather than having to type it in? ie start-point, end-point, side.

- And then finishing off by exploding the block?


We use those two points to determine door width. Alternative would be to create functions for standard door widths, or to wait for user to enter value.

Each element will be created separately, and side determined by mouse click.

 

Best option.

Procedure starts at first pick point (arc origin), second pick point determines door width and alignment, and third point door side.

 

If needed, door element could be mirrored (vertical at midpoint between first two points, or horizontal).

 

Decide what would you like most.

 

 

 

 

 

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 9 of 24
marko_ribar
in reply to: Rroger_D

Hi @Rroger_D

 

Here is just a little sophisticated version, near the one you're searching for... I assume you know to use OSNAPs for picking wall points and previously choose already created layer - I've removed this line as in my work I never know in what layer doors should be placed... So this is perhaps the best for working - I already use this version :

 

(defun c:dd ( / mid clockwise-p p1 p2 di a1 a2 pp1 pp2 pp p311 p312 p321 p322 w p3 ) ; *doorwidth* is global variable

  (defun mid ( p1 p2 )
    (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p1 p2)
  )

  (defun clockwise-p ( p1 p2 p3 )
    (minusp (- (* (car (mapcar '- p3 p1)) (cadr (mapcar '- p2 p1))) (* (cadr (mapcar '- p3 p1)) (car (mapcar '- p2 p1)))))
  )

  (initget 1)
  (setq p1 (getpoint "\nPick or specify first wall point : "))
  (initget 1)
  (setq p2 (getpoint p1 "\nPick or specify second wall point : "))
  (setq di (distance p1 p2))
  (setq a1 (angle p1 p2))
  (setq a2 (angle p2 p1))
  (setq pp1 (polar (polar p1 a1 (/ di 2)) (+ a1 (* 0.5 pi)) (/ di 2)))
  (setq pp2 (polar (polar p1 a1 (/ di 2)) (- a1 (* 0.5 pi)) (/ di 2)))
  (grdraw p1 p2 1 1)
  (grdraw pp1 pp2 1 1)
  (setq p311 (polar p1 (+ a1 (* 0.5 pi)) di))
  (setq p312 (polar p1 (- a1 (* 0.5 pi)) di))
  (setq p321 (polar p2 (+ a2 (* 0.5 pi)) di))
  (setq p322 (polar p2 (- a2 (* 0.5 pi)) di))
  (grdraw (mid p1 p311) (mid p1 p312) 1 1)
  (grdraw (mid p2 p321) (mid p2 p322) 1 1)
  (grdraw (mid p1 p311) (mid p2 p322) 1 1)
  (grdraw (mid p1 p312) (mid p2 p321) 1 1)
  (initget 1)
  (setq pp (getpoint "\nPick or specify side point inside marked squares : "))
  (if (null *doorwidth*)
    (progn
      (initget 7)
      (setq w (getdist "\nPick or specify width of door panel : "))
    )
    (progn
      (initget 6)
      (setq w (getdist (strcat "\nPick or specify width of door panel <" (rtos *doorwidth* 2 8) "> : ")))
      (if (null w)
        (setq w *doorwidth*)
      )
    )
  )
  (setq *doorwidth* w)
  (cond
    ( (and (not (inters p1 p2 pp (mid p1 p311))) (not (inters pp1 pp2 pp (mid p1 p311))))
      (setq p3 p311)
    )
    ( (and (not (inters p1 p2 pp (mid p1 p312))) (not (inters pp1 pp2 pp (mid p1 p312))))
      (setq p3 p312)
    )
    ( (and (not (inters p1 p2 pp (mid p2 p321))) (not (inters pp1 pp2 pp (mid p2 p321))))
      (setq p3 p321)
    )
    ( (and (not (inters p1 p2 pp (mid p2 p322))) (not (inters pp1 pp2 pp (mid p2 p322))))
      (setq p3 p322)
    )
  )
  (if (< (distance p3 p2) (distance p3 p1))
    (mapcar 'set '(p1 p2) (list p2 p1))
  )
  (entmake
    (list
      (cons 0 "LWPOLYLINE")
      (cons 100 "AcDbEntity")
      (cons 100 "AcDbPolyline")
      (cons 90 3)
      (cons 70 (* 128 (getvar 'plinegen)))
      (cons 10 p1)
      (cons 40 w)
      (cons 41 w)
      (cons 42 0.0)
      (cons 10 p3)
      (cons 42 (if (clockwise-p p1 p2 p3) (- (/ (sin (/ pi 8.0)) (cos (/ pi 8.0)))) (/ (sin (/ pi 8.0)) (cos (/ pi 8.0)))))
      (cons 10 p2)
      (cons 42 0.0)
    )
  )
  (redraw)
  (princ)
)

HTH., M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 10 of 24
hak_vz
in reply to: marko_ribar

I have been following @marko_ribar for many years  and I know that he always got right solution to any task.

This time he has created a sophisticated  and dynamic code I don't have a reason to beat. Something I was thinking

about in my previous post.

 

Here is my simplified solution so you may choose the one that suites you most.

 

(defun c:dd ( /  lyr side pt1 pt2 di ang1 ang2 pt3 *error*  ss mid1 mid 2 flip) ;
(defun *error* ()(princ))
(setq lyr (tblsearch "layer" "door"))
(if (not lyr)  (command "._layer" "_M" "door"  "_Lt" "Continuous" "door" ""))
(setq
  pt1 (getpoint "\nPick or specify start point > ")
  pt2 (getpoint "\nPick or specify end point > ")
  di (distance pt1 pt2)
  ang1 (angle pt1 pt2)
  ang2 (+ ang1 (/ pi 2.0))
  pt3 (polar pt1 ang2 di)
  ss (ssadd)
)
  (entmake
   (list
    (cons 0 "LWPOLYLINE")
    (cons 100 "AcDbEntity")
    (cons 100 "AcDbPolyline")
    (cons 8 "door")
    (cons 90 2)
    (cons 70 0)
    (cons 10 pt2)
	(cons 40 0.00018)
	(cons 41 0.00018)
    (cons 42 (/ (sin (/ pi 8.0)) (cos (/ pi 8.0))))
    (cons 10 pt3)
   )
  )
(setq ss (ssadd (entlast) ss))
   (entmake
   (list
    (cons 0 "LWPOLYLINE")
    (cons 100 "AcDbEntity")
    (cons 100 "AcDbPolyline")
    (cons 8 "door")
    (cons 10 pt3)
	(cons 40 0.015)
	(cons 41 0.015)
    (cons 42 0.0)
	(cons 10 pt1)
   )
  )
(setq ss (ssadd (entlast) ss))
(setq mid1 (mapcar '* (mapcar '+ pt1 pt2)(list 0.5 0.5)))
(setq mid2 (polar mid1 (+( angle pt1 pt2)(/ pi 2.0))100))
(initget 1 "Yes No")
(setq flip (getkword "\nFlip vertically [Yes/No] : "))
(if (eq flip "Yes")
  (command "mirror" ss "" pt1 pt2 "y" )
)
(initget 1 "Yes No")
(setq flip (getkword "\nFlip horizontally [Yes/No] : "))
(if (eq flip "Yes")
  (command "mirror" ss "" mid1 mid2 "y" )
)
(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 11 of 24
marko_ribar
in reply to: Rroger_D

My newest version... Now door is opening for 22.5 degrees on chosen side... I think that this is it and thanks for kind words @hak_vz...

 

(defun c:dd ( / mid clockwise-p vl-position-fuzz osm p1 p2 di a1 a2 pp1 pp2 pp p311 p312 p321 p322 w p3 al ll gr aa pos ax k b ) ; *doorwidth* is global variable

  (defun mid ( p1 p2 )
    (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p1 p2)
  )

  (defun clockwise-p ( p1 p2 p3 )
    (minusp (- (* (car (mapcar '- p3 p1)) (cadr (mapcar '- p2 p1))) (* (cadr (mapcar '- p3 p1)) (car (mapcar '- p2 p1)))))
  )

  (defun vl-position-fuzz ( e l fuzz / car-vl-member-if )
    (defun car-vl-member-if ( f l / ff r )
      (setq ff '(lambda ( x ) (if (apply f (list x)) (setq r x))))
      (if (vl-some ff l)
        r
      )
    )
    (vl-position (car-vl-member-if '(lambda ( x ) (equal e x fuzz)) l) l)
  )

  (setq osm (getvar 'osmode))
  (initget 1)
  (setq p1 (getpoint "\nPick or specify first wall point : "))
  (initget 1)
  (setq p2 (getpoint p1 "\nPick or specify second wall point : "))
  (setq di (distance p1 p2))
  (setq a1 (angle p1 p2))
  (setq a2 (angle p2 p1))
  (setq pp1 (polar (polar p1 a1 (/ di 2)) (+ a1 (* 0.5 pi)) (/ di 2)))
  (setq pp2 (polar (polar p1 a1 (/ di 2)) (- a1 (* 0.5 pi)) (/ di 2)))
  (grdraw p1 p2 1 1)
  (grdraw pp1 pp2 1 1)
  (setq p311 (polar p1 (+ a1 (* 0.5 pi)) di))
  (setq p312 (polar p1 (- a1 (* 0.5 pi)) di))
  (setq p321 (polar p2 (+ a2 (* 0.5 pi)) di))
  (setq p322 (polar p2 (- a2 (* 0.5 pi)) di))
  (grdraw (mid p1 p311) (mid p1 p312) 1 1)
  (grdraw (mid p2 p321) (mid p2 p322) 1 1)
  (grdraw (mid p1 p311) (mid p2 p322) 1 1)
  (grdraw (mid p1 p312) (mid p2 p321) 1 1)
  (setvar 'osmode 0)
  (initget 1)
  (setq pp (getpoint "\nPick or specify side point inside marked squares : "))
  (if (null *doorwidth*)
    (progn
      (initget 7)
      (setq w (getdist "\nPick or specify width of door panel : "))
    )
    (progn
      (initget 6)
      (setq w (getdist (strcat "\nPick or specify width of door panel <" (rtos *doorwidth* 2 8) "> : ")))
      (if (null w)
        (setq w *doorwidth*)
      )
    )
  )
  (setq *doorwidth* w)
  (cond
    ( (and (not (inters p1 p2 pp (mid p1 p311))) (not (inters pp1 pp2 pp (mid p1 p311))))
      (setq p3 p311)
    )
    ( (and (not (inters p1 p2 pp (mid p1 p312))) (not (inters pp1 pp2 pp (mid p1 p312))))
      (setq p3 p312)
    )
    ( (and (not (inters p1 p2 pp (mid p2 p321))) (not (inters pp1 pp2 pp (mid p2 p321))))
      (setq p3 p321)
    )
    ( (and (not (inters p1 p2 pp (mid p2 p322))) (not (inters pp1 pp2 pp (mid p2 p322))))
      (setq p3 p322)
    )
  )
  (if (< (distance p3 p2) (distance p3 p1))
    (mapcar 'set '(p1 p2) (list p2 p1))
  )
  (setq al (mapcar '(lambda ( a ) (cvunit (rem (+ ((if (clockwise-p p1 p3 p2) - +) (cvunit (angle p1 p2) "radian" "degree") a) 360.0) 360.0) "degree" "radian")) (setq ll (list 0.0 22.5 45.0 67.5 90.0 112.5 135.0 157.5 180.0)))) 
  (while (= (car (setq gr (grread t))) 5)
    (redraw)
    (setq pp (cadr gr))
    (setq aa (angle p1 pp))
    (setq pos (vl-position-fuzz aa al (cvunit 22.5 "degree" "radian")))
    (if (null pos)
      (setq pos (vl-position-fuzz (rem (+ aa pi) (* 2 pi)) al (cvunit 22.5 "degree" "radian")))
    )
    (setq aa (nth pos al))
    (grdraw p1 (polar p1 aa di) 3 1)
    (setq ax (cvunit (/ (nth pos ll) 36) "degree" "radian"))
    (setq k -1)
    (repeat 36
      (setq pp1 (polar p1 ((if (clockwise-p p1 p3 p2) - +) (angle p1 p2) (* (setq k (1+ k)) ax)) di))
      (setq pp2 (polar p1 ((if (clockwise-p p1 p3 p2) - +) (angle p1 p2) (* (1+ k) ax)) di))
      (grdraw pp1 pp2 3 1)
    )
  )
  (setq b (/ (sin (cvunit (/ (nth pos ll) 4.0) "degree" "radian")) (cos (cvunit (/ (nth pos ll) 4.0) "degree" "radian"))))
  (entmake
    (list
      (cons 0 "LWPOLYLINE")
      (cons 100 "AcDbEntity")
      (cons 100 "AcDbPolyline")
      (cons 90 3)
      (cons 70 (* 128 (getvar 'plinegen)))
      (cons 10 p1)
      (cons 40 w)
      (cons 41 w)
      (cons 42 0.0)
      (cons 10 (polar p1 aa di))
      (cons 42 (if (clockwise-p p1 p3 p2) b (- b)))
      (cons 10 p2)
      (cons 42 0.0)
    )
  )
  (redraw)
  (setvar 'osmode osm)
  (princ)
)

HTH., M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 12 of 24
Rroger_D
in reply to: marko_ribar

Hi guys,

 

Thank you for your replies. It looks like an unbelievable amount of time and effort you've both put into this. Many, many thanks.

 

Not had a chance to look at them just yet. My CAD is at work. I'll try and get to it today and feed back how I get on.

 

Thank you again though for your work. I'm surprised just how complicated it turned out to be.

 

Cheers,

 

R

Message 13 of 24
Rroger_D
in reply to: Rroger_D

Hi Marko_ribar and Hak_vz,

 

Had a chance to test the Lisps. Fab-a-rooney!

 

Thank you!

 

The doors draw great and am super-impressed with the multi-angle options.

 

One query but not a show-stopper, I notice that when / if I explode the door block it reverts to a 'Line' string rather than a 'Polyline' and thus loses it's thickness. Any ideas why?

 

The boss says that he prefers everything exploded. I'll just have tell him "too bad" 🙂

 

Thanks again.

 

R

Message 14 of 24
marko_ribar
in reply to: Rroger_D

Well that's true, when you explode polyline with width - it is lost... So you shouldn't explode it... If you want outlined - it can be done, but it will reflect all fills - it's also quirk that you can't specify no fill property to single entity - you can only try FILLMODE set to 0 and then REGEN, but it will reflect all filled objects... I couldn't figure out how to overcome this issue...

One revision in solution code, though - it concerns previewing door openings - if you want reflection while moving cursor around origin of rotation, replace line :

(if (null pos)

  ...

); end if

 

with :

 

    (if (null pos)
      (progn
        (setq pp1 (trans pp 0 (mapcar '- p2 p1)))
        (setq pp2 (trans p1 0 (mapcar '- p2 p1)))
        (setq pp2 (list (car pp2) (cadr pp2) (caddr pp1)))
        (setq pp (trans (mapcar '+ pp2 (mapcar '- pp2 pp1)) (mapcar '- p2 p1) 0))
        (setq aa (angle p1 pp))
        (setq pos (vl-position-fuzz aa al (cvunit 22.5 "degree" "radian")))
      )
    )

 

It should be better when choosing 180, or 0 degree angles and symmetry will be preserved along direction of 0-180 degree angle axis, so that when angle is closer to 0 degree above or below axis - opening angle will be smaller, and when closer to 180 degree below or above axis - opening angle will be bigger...

 

Regards, M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 15 of 24
hak_vz
in reply to: Rroger_D

My code creates all elements separately , don't  to explode them.

 

  (entmake
   (list
    (cons 0 "LWPOLYLINE")
    (cons 100 "AcDbEntity")
    (cons 100 "AcDbPolyline")
    (cons 8 "door")
    (cons 90 2)
    (cons 70 0)
    (cons 10 pt2)
	(cons 40 0.00018)  ;
	(cons 41 0.00018)
    (cons 42 (/ (sin (/ pi 8.0)) (cos (/ pi 8.0))))
    (cons 10 pt3)
   )
  )
(setq ss (ssadd (entlast) ss))
   (entmake
   (list
    (cons 0 "LWPOLYLINE")
    (cons 100 "AcDbEntity")
    (cons 100 "AcDbPolyline")
    (cons 8 "door")
    (cons 10 pt3)
	(cons 40 0.015)
	(cons 41 0.015)
    (cons 42 0.0)
	(cons 10 pt1)
   )
  )

You just have to set line thickness by replacing values for (cons 40 0.015) (cons 41 0.015) - door leaf and (cons 40 0.00018) (cons 40 0.00018) for arc.

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 16 of 24
marko_ribar
in reply to: hak_vz

Inspired by @hak_vz, I thought ab this issue once again and figured out, why don't we create 2 separate plines - one just for symbolic presentation of opening and the other for door plate rectangle... And I succeed in doing it my way - beside symbolic pline I've crated the other rectangle for door plate presentation, so that 2 plines don't disrupt each other... So here is my final code, only thing that remains is wall frames - rectangles in dimension of wall width :

 

(defun c:dd ( / mid clockwise-p vl-position-fuzz osm p1 p2 di a1 a2 pp1 pp2 pp p311 p312 p321 p322 w p3 al ll gr aa pos ax k b ) ; *doorwidth* is global variable

  (defun mid ( p1 p2 )
    (mapcar '(lambda ( a b ) (/ (+ a b) 2.0)) p1 p2)
  )

  (defun clockwise-p ( p1 p2 p3 )
    (minusp (- (* (car (mapcar '- p3 p1)) (cadr (mapcar '- p2 p1))) (* (cadr (mapcar '- p3 p1)) (car (mapcar '- p2 p1)))))
  )

  (defun vl-position-fuzz ( e l fuzz / car-vl-member-if )
    (defun car-vl-member-if ( f l / ff r )
      (setq ff '(lambda ( x ) (if (apply f (list x)) (setq r x))))
      (if (vl-some ff l)
        r
      )
    )
    (vl-position (car-vl-member-if '(lambda ( x ) (equal e x fuzz)) l) l)
  )

  (setq osm (getvar 'osmode))
  (initget 1)
  (setq p1 (getpoint "\nPick or specify first wall point : "))
  (initget 1)
  (setq p2 (getpoint p1 "\nPick or specify second wall point : "))
  (setq di (distance p1 p2))
  (setq a1 (angle p1 p2))
  (setq a2 (angle p2 p1))
  (setq pp1 (polar (polar p1 a1 (/ di 2)) (+ a1 (* 0.5 pi)) (/ di 2)))
  (setq pp2 (polar (polar p1 a1 (/ di 2)) (- a1 (* 0.5 pi)) (/ di 2)))
  (grdraw p1 p2 1 1)
  (grdraw pp1 pp2 1 1)
  (setq p311 (polar p1 (+ a1 (* 0.5 pi)) di))
  (setq p312 (polar p1 (- a1 (* 0.5 pi)) di))
  (setq p321 (polar p2 (+ a2 (* 0.5 pi)) di))
  (setq p322 (polar p2 (- a2 (* 0.5 pi)) di))
  (grdraw (mid p1 p311) (mid p1 p312) 1 1)
  (grdraw (mid p2 p321) (mid p2 p322) 1 1)
  (grdraw (mid p1 p311) (mid p2 p322) 1 1)
  (grdraw (mid p1 p312) (mid p2 p321) 1 1)
  (setvar 'osmode 0)
  (initget 1)
  (setq pp (getpoint "\nPick or specify side point inside marked squares : "))
  (if (null *doorwidth*)
    (progn
      (initget 7)
      (setq w (getdist "\nPick or specify width of door panel : "))
    )
    (progn
      (initget 6)
      (setq w (getdist (strcat "\nPick or specify width of door panel <" (rtos *doorwidth* 2 8) "> : ")))
      (if (null w)
        (setq w *doorwidth*)
      )
    )
  )
  (setq *doorwidth* w)
  (cond
    ( (and (not (inters p1 p2 pp (mid p1 p311))) (not (inters pp1 pp2 pp (mid p1 p311))))
      (setq p3 p311)
    )
    ( (and (not (inters p1 p2 pp (mid p1 p312))) (not (inters pp1 pp2 pp (mid p1 p312))))
      (setq p3 p312)
    )
    ( (and (not (inters p1 p2 pp (mid p2 p321))) (not (inters pp1 pp2 pp (mid p2 p321))))
      (setq p3 p321)
    )
    ( (and (not (inters p1 p2 pp (mid p2 p322))) (not (inters pp1 pp2 pp (mid p2 p322))))
      (setq p3 p322)
    )
  )
  (if (< (distance p3 p2) (distance p3 p1))
    (mapcar 'set '(p1 p2) (list p2 p1))
  )
  (setq al (mapcar '(lambda ( a ) (cvunit (rem (+ ((if (clockwise-p p1 p3 p2) - +) (cvunit (angle p1 p2) "radian" "degree") a) 360.0) 360.0) "degree" "radian")) (setq ll (list 0.0 22.5 45.0 67.5 90.0 112.5 135.0 157.5 180.0)))) 
  (while (= (car (setq gr (grread t))) 5)
    (redraw)
    (setq pp (cadr gr))
    (setq aa (angle p1 pp))
    (setq pos (vl-position-fuzz aa al (cvunit 22.5 "degree" "radian")))
    (if (null pos)
      (progn
        (setq pp1 (trans pp 0 (mapcar '- p2 p1)))
        (setq pp2 (trans p1 0 (mapcar '- p2 p1)))
        (setq pp2 (list (car pp2) (cadr pp2) (caddr pp1)))
        (setq pp (trans (mapcar '+ pp2 (mapcar '- pp2 pp1)) (mapcar '- p2 p1) 0))
        (setq aa (angle p1 pp))
        (setq pos (vl-position-fuzz aa al (cvunit 22.5 "degree" "radian")))
      )
    )
    (setq aa (nth pos al))
    (grdraw p1 (polar p1 aa di) 3 1)
    (setq ax (cvunit (/ (nth pos ll) 36) "degree" "radian"))
    (setq k -1)
    (repeat 36
      (setq pp1 (polar p1 ((if (clockwise-p p1 p3 p2) - +) (angle p1 p2) (* (setq k (1+ k)) ax)) di))
      (setq pp2 (polar p1 ((if (clockwise-p p1 p3 p2) - +) (angle p1 p2) (* (1+ k) ax)) di))
      (grdraw pp1 pp2 3 1)
    )
  )
  (setq b (/ (sin (cvunit (/ (nth pos ll) 4.0) "degree" "radian")) (cos (cvunit (/ (nth pos ll) 4.0) "degree" "radian"))))
  (entmake
    (list
      (cons 0 "LWPOLYLINE")
      (cons 100 "AcDbEntity")
      (cons 100 "AcDbPolyline")
      (cons 90 3)
      (cons 70 (* 128 (getvar 'plinegen)))
      (cons 10 p1)
      (cons 42 0.0)
      (cons 10 (polar p1 aa di))
      (cons 42 (if (clockwise-p p1 p3 p2) b (- b)))
      (cons 10 p2)
      (cons 42 0.0)
    )
  )
  (entmake
    (list
      (cons 0 "LWPOLYLINE")
      (cons 100 "AcDbEntity")
      (cons 100 "AcDbPolyline")
      (cons 90 4)
      (cons 70 (1+ (* 128 (getvar 'plinegen))))
      (cons 10 p1)
      (cons 42 0.0)
      (cons 10 (polar p1 aa di))
      (cons 42 0.0)
      (cons 10 (polar (polar p1 aa di) ((if (clockwise-p p1 p3 p2) + -) aa (* 0.5 pi)) w))
      (cons 42 0.0)
      (cons 10 (polar p1 ((if (clockwise-p p1 p3 p2) + -) aa (* 0.5 pi)) w))
      (cons 42 0.0)
    )
  )
  (redraw)
  (setvar 'osmode osm)
  (princ)
)

HTH., M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 17 of 24
OM805
in reply to: marko_ribar

Marko,

 

First off, thanks for providing this code.  I'm running into an issue.  When I try to create a door using the lower right quadrant, it does not allow for a complete 90 degrees.  All other quadrants have no issues.  Please, reference attached image for an example.

 

Regards,

 

OM

Message 18 of 24
Sea-Haven
in reply to: marko_ribar

Hi Marco tried out the code got a error message that DD was a reserved function running CIV3D 2020 easy fix made it c:ddd then it worked. Thought I would let you know if some one contacts you about the error, will try to find the DD command.

 

Command: DD
DD must be called from within another command

 

 

Message 19 of 24
Sea-Haven
in reply to: OM805

I have a inexpensive packagethat does more than doors, walls, windows, roof etc

 

IF intersted PM 

 

Pretty sure there was a dynamic block door posted here was very impressive. Try google.

 

 

Message 20 of 24
Sea-Haven
in reply to: Sea-Haven

Was having problems posting image.

 

3dhouse.jpg

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Customer Advisory Groups


Autodesk Design & Make Report