AutoCAD/stuck on lisp
Expert: Bill DeShawn - 3/14/2005
QuestionHi Bill -- I asked SCOTT this-- unfortunately, he came up with the same solution I had offered my client, which they hated-- now he is maxed out and they press me -- any chance you can help? What is needed is a rectangle with an x- in lines crossing center. BOB
COPY OF EXCHANGE
Subject DRAW RECTANGLE WITH X. SPECIFIED LAYER AND COLOR
Question Hi -- I am the guy that answers the general questions you don't want: now I have to admit I slept through some/all of the programming in class.
SOFTWARE: LT 2005 - with SlingShot Max from Drcauto added, for its layer toolbar.
STORY:
--client in very unusual business,decorating model homes (big firm) very simple drawings, but very quirky drawings
--they called me to try to fix some old customization for LT2002-- it was very esoteric, and most of it was not needed (like having things drawn at several Z values instead of using "bring to front")
--the only thing I could not replace that they still want is the ability to draw a rectangle with an x on a certain layer. This is used for to mark ceiling fans, central light fixtures, etc I think it's odd, but it works for them.
--the old tool worked by keyboard shortcut or toolbar-- naturally, I would prefer a tool that goes on a palette, but when i pull this one it it degerates to a plain pl.
-- DUH I THOUGHT I COULD DO THIS BUT I CANT ATTACH DWG Wth 2 x-rectangles on the proper layers, colors, linetypes.
--I thought that LT and Autolisp are not supposed to be pals, but the guy who did their old setup made this work.
IF YOU CAN POSSIBLY SOLVE THIS, I WOULD APPRECIATE IT-- MAY I SEND YOU THE SMALL DWG? OTHERWISE I HAVE TO ASK YOU HOW TO PLUG IN THE LAYER AND COLOR INFO (THESE OBJECTS ARE NOT COLOR BY LAYER)
THANKS,
BOB 310 766 4605
Answer Is the X text or lines? If it's just lines, I'd make a 1x1 block with the X and insert it, dragging the xyscale. Hardcode layers into the block as needed. Explode last if desired.
Let me know if it's text, that would require some more thinking
END OF COPY
BILL-- THE ITEM WAS A RECTANGLE WITH CROSSING X, ALL DRAWN AT ONCE, NO TEXT
BOB
AnswerIf you have DRCAUTO, why are you using diesel? DRCAUTO is supposed to provide Autolisp capability to LT.
I use this routine for skylights:
; SKY.LSP
(defun skyerror (s) ; If an error (such as CTRL-C) occurs
; while this command is active...
(if (/= s "Function cancelled")
(princ (strcat "\nError: " s))
)
(setvar "cmdecho" ocmd) ; Restore saved modes
(setvar "blipmode" oblp)
(setq *error* olderr) ; Restore old *error* handler
(princ)
)
(defun c:sky (/ plw olderr ocmd oblp pt1 ortho pt2 pt3 pt4 l w)
(setq plw (getvar "plinewid"))
(setvar "plinewid" 0.0)
(setq os (getvar "osmode"))
(setvar "osmode" 0)
(setq olderr *error* *error* skyerror)
(setq ocmd (getvar "cmdecho"))
(setq oblp (getvar "blipmode"))
(setvar "cmdecho" 0)
(initget 1) ;3D point can't be null
(setq pt1 (getpoint (strcat "\nCorner of rectangle or square: ")))
(setq ortho (getvar "orthomode"))
(setvar "ORTHOMODE" 1)
(initget 7) ;Length can't be 0, neg, or null
(setq l (getdist pt1 "\nX DIM: "))
(setq pt2 (list (+ (car pt1) l) (cadr pt1) (caddr pt1)))
(grdraw pt1 pt2 2)
(initget 7 "Square") ;Width can't be 0, neg, or null
(setq w (getdist pt1 "\nSQUARE / <Y DIM>: "))
(if (= w "Square")
(setq w l)
)
(setq pt3 (list (car pt2) (+ (cadr pt2) w) (caddr pt2)))
(setq pt4 (list (car pt1) (+ (cadr pt1) w) (caddr pt1)))
(grdraw pt2 pt3 2)
(grdraw pt3 pt4 2)
(grdraw pt4 pt1 2)
(setvar "ORTHOMODE" 0)
(command "_.dim" "_exit" "_.pline" pt1 pt2 pt3 pt4 "_close")
(command "_.line" pt1 pt3 "" "line" pt2 pt4 "")
(setvar "cmdecho" ocmd)
(setvar "blipmode" oblp)
(setvar "osmode" os)
(setvar "orthomode" ortho)
(setvar "plinewid" plw)
(setq *error* olderr) ; Restore old *error* handler
(REDRAW)
(princ)
)
This creates three objects, a closed rectangular polyline and two diagonal lines. I can make this to be one polyline object, but one leg will have to overlap. I have no idea what the "right layer" or the "right color and linetype" are. Can you clue me in?
Keep in touch
Bill DeShawn
http://my.sterling.net/~bdeshawn