Jump to content

Recommended Posts

Posted

Hoping someone can help me out.

I found a lisp routine that labels a line with a bearing and distance.

It labels the line with both. Can some one figure out how to break

it into 2 seperate routines. One that just labels the line with the

bearing and the other with just the distance.

Note, the bearing routine needs to maintain the "degree" symbol behind

the first number, and the distance needs to maintain the "(')" symbol

at the end of the length of the line.

Thanks

bearing_and_distance.LSP

Posted

What about 3 separate routines

 

(defun c:bad ()(badder 3));

(defun c:badA ()(badder 1))

(defun c:badD ()(badder 2))

 

Hang on. is this a homework ? there's quite a number of posters requesting "help" but ending up just copying the code?

[ a code is at the ready ] Hope you don't mind us asking if this is one those cases.

Posted

There are other ways to do modify the code. Here's how i would approach this.

 

(defun badder (mode / _pad0 c_textstyle c_textsize c_ltscale pt1 pt2 mid p_)
 [color="blue"](defun _pad0 (st)
   (foreach itm '(("*d#'*" 100) ("*'#\"*" 39))
     (if (wcmatch st (Car itm))
       (setq st
              (strcat
                (substr st 1 (1+ (setq p (vl-string-position (cadr itm) st))))
                "0"
                (substr st (+ p 2))
              )
       )
     )
   )
   st
 )[/color]
 (setq c_textstyle (getvar "textstyle"))
 (setq c_textsize (getvar "textsize"))
 (setq c_ltscale (getvar "ltscale"))
 (if (= "textsize" 0)
   (setvar "textsize" 1)
 )
 (setq pt1 (getpoint "\nPick the first Point: ")
       pt2 (getpoint pt1 "\nPick the second Point: ")
 )
 [color="blue"](setq mid (mapcar '(lambda (m n)
                      (* 0.5 (+ m n))
                    )
                   pt1
                   pt2
           )
 )[/color]
[color="blue"] (entmakex
   (list
     (cons 0 "TEXT")
     (cons 10
           (Setq p_ (polar mid
                           (+ (setq ang (angle pt1 pt2)) (/ pi 2.0))
                           (* 0.75 c_textsize)
                    )
           )
     )
     (cons 11 p_) (cons 40 c_textsize) (Cons 50 ang)
     '(41 . 0.80) '(72 . 4) '(73 . 3)
     (cons 1
       (vl-string-subst "%%d" "d"
         (_pad0
           (cond
             ((eq mode 1) (angtos ang 4 4))
             ((eq mode 2) (strcat (rtos (distance pt1 pt2) 2 2) "'"))
             ((eq mode 3)
              (strcat (angtos ang 4 4) " " (rtos (distance pt1 pt2) 2 2) "'")
             )
           )
         )
       )
     )
   )[/color]
 )
 (princ)
)

 

(defun c:bad ()(badder 3));

(defun c:badA ()(badder 1))

(defun c:badD ()(badder 2))

 

HTH

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