Jump to content

offset and change lisp or macro


qball

Recommended Posts

i've been trying to create a macro or lisp that will offset a line and change it's layer.

the macro works fine

^C^C_offset;;\\ change Last;;P;La;S-Reveal;;

but i need to do this a lot. if i do the macro and finish it, i hit enter like i want to repeat the macro but it only repeats the last command on the command line "change".

can a macro repeat itself with user input to cancel? i think that's where lisp comes in. i've been looking over lisp tutorials and it doesn't make any sense to me. i learned it 8 years ago and have completely forgotten. here's my pathetic attempt at lisp to do the same thing:

; This command creates a 3/4" chamfer around window openings and panel edges
(defun c:CE ()
 (command "offset" "3/4" 
   ))

you'll notice it just kind of trails off like a kid with A.D.D.

is there a lisp tutorial that can help me learn it from scratch?

 

also, can a macro be assigned to command line entry? or button only?

 

edit:

well, my co-worker just solved the problem with "offset: layer" option. well, that was an afternoon wasted.

i'm still dumb and want to know more about lisp.

Link to comment
Share on other sites

You may abuse this one. :)

;;  Offset 0.75 to layer "0"
(defun c:ce (/ ent pt)
 (while (and
          (setq ent (car (entsel "\nSelect object to offset 3/4 or <exit>:")))
          (setq pt (getpoint "\nSpecify point on side to offset:"))
        )
   (command "._offset" 0.75 ent "_non" pt "")
   (command "._change" (entlast) "" "_P" "_LA" "0" "")
 )
 (princ)
)

Link to comment
Share on other sites

  • 10 months later...
  • 1 year later...

Try this (start the command by typing "ol"):

 

;OffsetCurrent.lsp - Offsets a line to the current layer and linetype

(defun *error* (s)

(repeat 3 (command))

(cond ( (member s '("Function cancelled" "console break"))

(princ "*cancel*"))

(t (princ (strcat "\nError: " s))))

(setvar "highlight" 1)

(setq *error* olderr)

(princ)

)

(defun get_offspec ( / e d)

(cond ( (setq e (entsel "\nObject to offset/CR for new distance:")))

(t (setq ofst (xgetdist "\nNew offset distance" ofst))

(if (= ofst nil) (setq ofst ofst3))

; (while (not (setq e (entsel "\nObject to offset: "))))

))

e

)

(defun xgetdist (msg def)

(cond ( (getdist (cond (def (strcat msg " :"))

(t ": ")))))

)

(defun C:ol (/ clay *error* lastent lastinfo olderr uecho offit offpnt ofst ofst2 ofst3 x)

(setq olderr *error*)

(setq uecho (getvar "cmdecho"))

(setvar "cmdecho" 0)

(setq ofst2 ofst)

(if (= ofst nil) (setq ofst 0))

(prompt "\n Offset Distance

(prin1 ofst)

(prompt "> :")

(setq ofst (getdist))

(if (= ofst nil) (setq ofst ofst2))

(setq x 0)

;(while (

(setq offit (get_offspec))

(setq offpnt (getpoint "\nChoose side to offset :"))

(command "OFFSET" ofst offit offpnt "")

(setq ofst3 ofst)

(setq clay (getvar "CLAYER"))

(setq lastent (entlast))

(setq lastinfo (entget lastent))

(setq lastinfo (subst (cons 6 "BYLAYER") (assoc 6 lastinfo) lastinfo))

(setq lastinfo (subst (cons 62 256) (assoc 62 lastinfo) lastinfo))

(setq lastinfo (subst (cons 8 clay) (assoc 8 lastinfo) lastinfo))

(entmod lastinfo)

(setq *error* olderr)

(princ)

)

 

 

dont k how to get rid of the smiley face, it should be defun c: and the letter "O"

Link to comment
Share on other sites

oops. this was a really old thread I started. Had I just paid more attention to the command line I would have noticed that when you enter OFFSET there's options of "Through/Erase/Layer". Make Layer "Current" rather than default "source" does what I need it to do.

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