Jump to content

it does not get given distance by user


taj250

Recommended Posts

hi all

 

i created door lisp for myself. i have an question when i select the line that line does not get the distance by user.i sure missed some codes here. kindly figure out my problem.

i attached code and image that image,i want to  exact me.

(defun c:door ()

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

  (setq off  (getdist "\nenter the offset hinge from wall: "));this is not work for me

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

  (setq in (atoi off))

  (setvar "osmode" 128 )
  (setq ow (getpoint in "\npick outside wall: "))

  (setvar "osmode" 0)

 

  (setq p1 (polar in 0 wid))

  (setq p2 (polar ow 0 wid))

  (setq p3 (polar in 0 0.05))

  (setq p4 (polar p3 (dtr 90.)wid))

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

  (command "break" in p1 ""
       "break" ow p2 ""
       "line"  in ow ""
       "line" p1 p2 ""
       "line" in p3 p4 p5 "c" ""
       "arc" p4 "e" p1 "d" 0.0 ""
       )

    

  

  )
  

 

 

thanks advance.

hussain

refernce.JPG

Link to comment
Share on other sites

1 hour ago, taj250 said:

hi all

 

i created door lisp for myself. i have an question when i select the line that line does not get the distance by user.i sure missed some codes here. kindly figure out my problem.

i attached code and image that image,i want to  exact me.

(defun c:door ()

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

  (setq off  (getdist "\nenter the offset hinge from wall: "));this is not work for me

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

  (setq in (atoi off));; this is wrong

  (setvar "osmode" 128 )
  (setq ow (getpoint in "\npick outside wall: "))

  (setvar "osmode" 0)

 

  (setq p1 (polar in 0 wid))

  (setq p2 (polar ow 0 wid))

  (setq p3 (polar in 0 0.05))

  (setq p4 (polar p3 (dtr 90.)wid))

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

  (command "break" in p1 ""
       "break" ow p2 ""
       "line"  in ow ""
       "line" p1 p2 ""
       "line" in p3 p4 p5 "c" ""
       "arc" p4 "e" p1 "d" 0.0 ""
       )

    

  

  )
  

 

 

thanks advance.

hussain

refernce.JPG

 

The polar function requires a point (x y z) or (x y). I have highlighted variable "in" above in two polar statements.

 

Variable "off" is a real. You are trying to (setq in (atoi off)), this is a function to convert a string to an integer. Even if it works, you cannot use an integer as a point in the polar function.  

Link to comment
Share on other sites

(setq pt pick wall near end and then find correct end pt so then do (getdist pt this will then show a distance or you can enter a value.

 

The code is copyrited but happy to provide further details. It works the way you want. Does way more than doors.

 

 

 

 

3dhouse.jpg

Link to comment
Share on other sites

hi bigal

thanks for the reply. i modified according your instruction although it does not work for me.i attached image.kindly see

(defun c:door ()

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

   
  (setq in (getpoint "\npick the wall:" ))

  (setq off  (getdist  in  "\nenter the offset hinge from wall: "))

  (setvar "osmode" 128 )
  (setq ow (getpoint in "\npick outside wall: "))

  (setvar "osmode" 0)

 

  (setq p1 (polar in 0 wid))

  (setq p2 (polar ow 0 wid))

  (setq p3 (polar in 0 0.05))

  (setq p4 (polar p3 (dtr 90.)wid))

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

  (command "break" in p1 ""
	   "break" ow p2 ""
	   "line"  in ow ""
	   "line" p1 p2 ""
	   "line" in p3 p4 p5 "c" ""
	   "arc" p4 "e" p1 "d" 0.0 ""
	   )

	

  

  )

 

refernce.JPG

Link to comment
Share on other sites

Ok in my code we use a method the request is "pick wall near end" this allows us to do two things, establish left or right end of wall and get the object at that pick point, then we can work out the correct angle of the line so the break works correct. I have posted many times the code to do the "near end". 

 

(setq tp1 (entsel "\nSelect left side inner wall near end : "))
	(setq tpp1 (entget (car tp1)))
	(setq pt1 (cdr (assoc 10 tpp1)))      
	(setq pt2 (cdr (assoc 11 tpp1)))      
	(setq pt3 (cadr tp1))
	(setq wallh (cdr (assoc 39 tpp1)))    
	(setq hts (caddr pt1))                
	(setq d1 (distance pt1 pt3))
	(setq d2 (distance pt2 pt3))
		(if (> d1 d2)
		(progn 
			(setq temp pt1)
			(setq pt1 pt2)
			(setq pt2 temp)
		)
		)
		(setq ang (angle pt1 pt2)) 

 

Link to comment
Share on other sites

5 hours ago, BIGAL said:

Ok in my code we use a method the request is "pick wall near end" this allows us to do two things, establish left or right end of wall and get the object at that pick point, then we can work out the correct angle of the line so the break works correct. I have posted many times the code to do the "near end". 

 


(setq tp1 (entsel "\nSelect left side inner wall near end : "))
	(setq tpp1 (entget (car tp1)))
	(setq pt1 (cdr (assoc 10 tpp1)))      
	(setq pt2 (cdr (assoc 11 tpp1)))      
	(setq pt3 (cadr tp1))
	(setq wallh (cdr (assoc 39 tpp1)))    
	(setq hts (caddr pt1))                
	(setq d1 (distance pt1 pt3))
	(setq d2 (distance pt2 pt3))
		(if (> d1 d2)
		(progn 
			(setq temp pt1)
			(setq pt1 pt2)
			(setq pt2 temp)
		)
		)
		(setq ang (angle pt1 pt2)) 

 

thank you so much your reply .i would follow this one.again thanks you did a lot for me.🙂

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...