Jump to content

Recommended Posts

Posted

I cobbled together this lisp years ago to essentially offset just a part of a line and would like to make it better.

 

The error trap doesn't seem to work.

I would like to have it change to a layer of the object picked, or maybe another layer to be specified later.

I imagine it can be cleaned up but I am not sure where to focus first.

 

 

;OffsetMeasure  offset a short line
(defun *error* (msg)
 (setvar "osmode" 0)
   (setq pt1 nil)
   (setq pt2 nil)
   (setq dist1 nil)
   (setq *seqpt nil)
 (princ "\n\n\nLeaving OM lisp routine, good day sir!\n")
 (princ)
)
(defun C:OM (/ pt1 pt2 dist1 srt)
 (setvar "cmdecho" 0)
 (setq srt (getvar "sortents"))
 (setvar "sortents" 3)
 (graphscr)
 (setq d "T")
   (while d
     (if (not *seqpt)(setq *seqpt 1.0))
     (princ "\nEnter Distance For Offset <")
     (princ *seqpt)
     (setq dist1 (getdist ">: ")
   )
 (setvar "osmode" 512)
   (setq pt1 (getpoint "\nPick point on object :")
         pt2 (getpoint "\nSecond point :")
       )
   (if (not dist1)(setq dist1 *seqpt)(setq *seqpt dist1)
 )
 (setvar "osmode" 0)
 (command ".line" pt1 pt2 "")
   (princ "\nSide to offset")
 (command ".offset" dist1 pt1 pause ""
           ".erase" pt1 ""
           ".move" pt1 "" "@" "@")
  (setq d1 (strcase (getstring "\nPress RETURN to continue or X to
quit ")))
  (if (= d1 "X")(setq d nil))
  )
  (setvar "sortents" srt)
   (princ)
)

 

Any help would be appreciated. Point me in a direction or do it all for me, I don't have a preference.:D

 

rkent

Posted

Having only skimmed your code, consider nesting the temporary *error* defun within the main code (c:OM), and be sure to localize the symbol so that once the main code completes the original *error* definition is restored. Pseudo code:

 

(defun c:OM ( / *error* ;|Other vars|
 (defun *error* (msg)
   ;; <-- Your error handler here
   )

 ;; <-- Main code here
 )

Posted

Renderman, that worked! Thanks, rkent

Posted
Renderman, that worked! Thanks, rkent

 

@ Rkent - Happy to help. :)

 

@ Lee - Well written tutorial, my friend. :beer:

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