Jump to content

Angle from reference line


anindya

Recommended Posts

I need to draw a line in any direction say clock wise or anti clock wise with respect to a base line with a definite angle value in degree minute and second with a fixed length in meter.is it possible by any lisp which will just ask me the angle value (degree minute and second),,,,,the direction(clockwise or anti clockwise) and the length in meter,and will draw the angle after selecting the base line?????? I am attaching a sample for observation

NEED HELP 55.dwg

Link to comment
Share on other sites

Here, try this...

 

(defun c:angfromlin (/ angb angd li loop stp enp lia nas nar d ch san)
 (setq angb (getvar 'angbase))
 (setq angd (getvar 'angdir))
 (setvar 'angbase 0.0)
 (setvar 'angdir 0)
 (while (or (null li) loop)
   (setq li (car (entsel "\nPick reference line...")))
   (if (null li)
     (prompt "\nMissed... Try picking again...")
   )
   (if li
     (if (not (eq (cdr (assoc 0 (entget li))) "LINE"))
       (progn
         (prompt
           "\nPicked wrong entity type... Please choose 2D line... Try picking again..."
         )
         (setq loop t)
       )
       (progn
         (setq stp (cdr (assoc 10 (entget li))))
         (setq enp (cdr (assoc 11 (entget li))))
         (if (or (not (equal (last stp) 0.0 1e-6))
                 (not (equal (last enp) 0.0 1e-6))
             )
           (progn
             (prompt
               "\nLine is 3D line... Please choose 2D line... Try picking again..."
             )
             (setq loop t)
           )
           (setq loop nil)
         )
       )
     )
   )
 )
 (setq lia (angle stp enp))
 (setq nas
        (getstring
          "\nPlease specify new angle measured from reference picked line in form [XdX'X.X\"]  where X is number : "
        )
 )
 (setq nar (angtof nas 1))
 (initget 7)
 (setq d (getdist "\nPick or specify length of new line : "))
 (initget 1 "CW CCW")
 (setq ch (getkword "\nChoose side for new line [CW/CCW] : "))
 (if (eq ch "CCW")
   (progn
     (setq san (+ lia nar))
     (entmake (list '(0 . "LINE")
                    (cons 10 stp)
                    (cons 11 (polar stp san d))
              )
     )
   )
   (progn
     (setq san (- lia nar))
     (entmake (list '(0 . "LINE")
                    (cons 10 stp)
                    (cons 11 (polar stp san d))
              )
     )
   )
 )
 (setvar 'angbase angb)
 (setvar 'angdir angd)
 (princ)
)

M.R.

Edited by marko_ribar
localized variable "san" I missed
Link to comment
Share on other sites

Please note that third-party programs are not actually required to complete this task, as shown by the following demo:

 

linelengthangle.gif

 

If you align your UCS to the line in question, zero degrees will be parallel to the line, with positive angles measured counter-clockwise, and negative angles clockwise.

 

Lee

Link to comment
Share on other sites

But , I didn't see lee Enter "@ "

 

This is only required in older versions of CAD in which Dynamic Input is not available (or for command-line input).

 

Rotating the UCS is only two clicks...

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