how to solve cond function if same angle?

how to solve cond function if same angle?

Anonymous
Not applicable
1,084 Views
10 Replies
Message 1 of 11

how to solve cond function if same angle?

Anonymous
Not applicable

hi everyone 

I attached here door code. i used it a cond function that the cond function worked one side only but the angle is the same. The user selects whether the left side or right sideline to want to make a door. let say two vertical parallel lines when i select right  sideline the doors coming left side? how to handle it cond function here.

 

(defun c:16 ()

 

(setq wid (getdist "\nenter the width: "))

(if (null wid) (setq wid 1.00)
)

(setq off (getdist "\nenter the hinge distance from adjacent wall: "))

(if (null off) (setq off 0.1)
)

(setvar "osmode" 640 )

 

(setq sel (cadr (entsel "\nselect the wall: ")))



(setq pt (polar (osnap sel "end") (angle (osnap sel "end") (osnap sel "mid")) off))

(setq ow (getpoint pt"\npick outside wall: "))

 


(setvar "osmode" 0)

(cond

((= (angle (osnap sel "end") (osnap sel "mid")) (dtr 270.0)) (left side door)

(setq p1 (polar pt (dtr 270.0) wid))

(setq p2 (polar ow (dtr 270.0) wid))

(setq p3 (polar pt (dtr 270.0) 0.05))

(setq p4 (polar p3 (dtr 180.0) wid))

(setq p5 (polar p4 (dtr 90.0) 0.05))

(command "break" pt p1
"break" ow p2
"pline" pt p3 p4 p5 "cl" ""
"line" pt ow ""
"line" p1 p2 "" )

(command "arc" p4 "e" p1 "d" 270.0)

)


((= (angle (osnap sel "end") (osnap sel "mid")) (dtr 270.0)) (right side door)

(setq p1 (polar pt (dtr 270.0) wid))

(setq p2 (polar ow (dtr 270.0) wid))

(setq p3 (polar pt (dtr 270.0) 0.05))

(setq p4 (polar p3 (dtr 0.0) wid))

(setq p5 (polar p4 (dtr 90.0) 0.05))

(command "break" pt p1
"break" ow p2
"pline" pt p3 p4 p5 "cl" ""
"line" pt ow ""
"line" p1 p2 "" )

(command "arc" p4 "e" p1 "d" 270.0)

)

 

 


((=(angle (osnap sel "end") (osnap sel "mid")) (dtr 90.0) )

 

(setq p1 (polar pt (dtr 90.0) wid))

(setq p2 (polar ow (dtr 90.0) wid))

(setq p3 (polar pt (dtr 90.0) 0.05))

(setq p4 (polar p3 (dtr 0.0) wid))

(setq p5 (polar p4 (dtr 270.0) 0.05))

(command "break" pt p1
"break" ow p2
"pline" pt p3 p4 p5 "cl" ""
"line" pt ow ""
"line" p1 p2 "" )

(command "arc" p4 "e" p1 "d" 90.0)
)

)

 

 

(princ)

)

0 Likes
Accepted solutions (1)
1,085 Views
10 Replies
Replies (10)
Message 2 of 11

hak_vz
Advisor
Advisor

Here you have a nice solution for drawing doors by @marko_ribar . Previous posts in that topic explain about defining angles.

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.
0 Likes
Message 3 of 11

Sea-Haven
Mentor
Mentor

I think it was Rlx over at Cadtutor has the best door routine I have seen it uses a dynamic block which has 4 states 2xL-R you drag the mouse and it will flip the door left to right or put on other side of wall, obviously door size is an option, I will try to find.

0 Likes
Message 4 of 11

hak_vz
Advisor
Advisor

@Sea-HavenYou can test solution by @marko_ribar , it uses grdraw, opens doors in steps , and it is result from members of this site, it isn't a jaw dropping solution  but it's decent. It doesn't use blocks or dinamic block  what is my oppinion is better solution.  In other case op can Google it itself. 

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.
0 Likes
Message 5 of 11

Anonymous
Not applicable

hi hak_vz

thanks for the reply. that one is fine lisp which one post here but very hard to understand that lisp. could you tell me particularly my lisp how to solve this because for my learning purpose? sorry for the inconvenience.

 

thanks 

hussain

0 Likes
Message 6 of 11

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

(cond

((= (angle (osnap sel "end") (osnap sel "mid")) (dtr 270.0)) (left side door)

....


((= (angle (osnap sel "end") (osnap sel "mid")) (dtr 270.0)) (right side door)

....


Those two conditional test functions are identical.  That means that if that is the condition of things, the first one will be satisfied, and it will do what is called for there, and will never look at the second one.  Should there be something different about the tests?

Kent Cooper, AIA
0 Likes
Message 7 of 11

CADaSchtroumpf
Advisor
Advisor

@Anonymous  a écrit :

hi hak_vz

thanks for the reply. that one is fine lisp which one post here but very hard to understand that lisp. could you tell me particularly my lisp how to solve this because for my learning purpose? sorry for the inconvenience.

 

thanks 

hussain



Hi,

Can help you?

(vl-load-com)
(defun c:what_side ( / e_sel ename pt ob deriv alpha v1 v2 det_or)
	(while (not (setq e_sel (entsel))))
	(setq
		ename (car e_sel)
		pt (trans (cadr e_sel) 1 0)
		ob (vlax-ename->vla-object ename)
		pt (vlax-curve-getClosestPointTo ob pt)
		deriv (vlax-curve-getfirstderiv ob (vlax-curve-getparamatpoint ob pt))
		alpha (atan (cadr deriv) (car deriv))
		v1 (mapcar '- (polar pt alpha 1.0) pt)
		v2 (mapcar '- (trans (getpoint "\nGive a point: ") 1 0) pt)
		det_or (apply '(lambda (x1 y1 z1 x2 y2 z2) (- (* x1 y2) (* y1 x2))) (append v1 v2))
	)
	(cond
		((> det_or 0.0) (princ "\nThe point is at LEFT, you can add pi/2 at the angle \"alpha\" of object selected"))
		((< det_or 0.0) (princ "\nThe point is at RIGHT, you can substract pi/2 at the angle \"alpha\" of object selected"))
	)
	(prin1)
)
0 Likes
Message 8 of 11

Anonymous
Not applicable

hi kent

sorry for the delay. yes, that two condition function is identical. there is no way to do for the door if the angle is the same here, but the polar function is different. so, how to execute the door here. kindly give the solution.

 

hussain

0 Likes
Message 9 of 11

pbejse
Mentor
Mentor
Accepted solution

Based on what you have on your code

 

(defun c:16 ()
  (setq wid (getdist "\nenter the width: "))
  (if (null wid)(setq wid 1.00))

  (setq off (getdist "\nenter the hinge distance from adjacent wall: "))
  (if (null off)(setq off 0.1))
  
  (setvar "osmode" 640)
  (setq sel (cadr (entsel "\nselect the wall: ")))  
  (setq	pt (polar (osnap sel "end")
		  (angle (osnap sel "end") (osnap sel "mid"))
		  off
	   )
  )    
  (setq ow (getpoint pt "\npick outside wall: "))
  (setvar "osmode" 0)
  (cond
    (	(=  (setq angleAt  (angle pt (osnap sel "mid"))) (dtr 270.0))	  
	     (setq p1 (polar pt (dtr 270.0) wid))
	     (setq p2 (polar ow (dtr 270.0) wid))
	     (setq p3 (polar pt (dtr 270.0) 0.05))
	     (setq p4 (polar p3 (if (< (car ow)(car pt)) 0.0 (dtr 180.0))  wid))
     	     (setq p5 (polar p4 (dtr 90.0) 0.05))
     	     (setq DoorAngle 270.0)
     )
    (	(= angleAt  (dtr 90.0))	  	  
	     (setq p1 (polar pt (dtr 90.0) wid))
	     (setq p2 (polar ow (dtr 90.0) wid))
	     (setq p3 (polar pt (dtr 90.0) 0.05))
	     (setq p4 (polar p3 (if (< (car ow)(car pt)) 0.0 (dtr 180.0)) wid))
	     (setq p5 (polar p4 (dtr 270.0) 0.05))
     	     (setq DoorAngle 90.0)	
	)
    )

     (command "break"	    pt	   p1	  "break"	ow     p2
	      "pline"	    pt	   p3	  p4	 p5	"cl"   ""
	      "line" pt	    ow	   ""	  "line" p1	p2     ""
	     )

     (command "arc" p4 "e" p1 "d" DoorAngle)
  
 (princ)
)

 

I will leave to you to figure out what to set if the angle is either 0.0 or 180 

 

images.jfif

 

HTH

 

 

Message 10 of 11

Anonymous
Not applicable

 Hi 

 

  you solved my problem with cond function.

i learned some code from you.i am grateful thank you so much for those whose reply to me.

 

hussain

 

0 Likes
Message 11 of 11

Anonymous
Not applicable

hi 

 

sorry to ask again. i would like to know.why you added here? what is actually doing here instead of using just dtr 180 or user will decide? could you explain?

(if (< (car ow)(car pt)) 0.0 (dtr 180.0))-pls explain this

 Hussain

0 Likes