qball Posted January 11, 2008 Share Posted January 11, 2008 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. Quote Link to comment Share on other sites More sharing options...
CAB Posted January 12, 2008 Share Posted January 12, 2008 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) ) Quote Link to comment Share on other sites More sharing options...
WCCSAM Posted November 18, 2008 Share Posted November 18, 2008 this lisp is great..how can it be modified so I can choose the offset distance and it not default to 3/4" Quote Link to comment Share on other sites More sharing options...
thumper Posted December 7, 2009 Share Posted December 7, 2009 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" Quote Link to comment Share on other sites More sharing options...
qball Posted December 7, 2009 Author Share Posted December 7, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.