Grigs Posted September 21, 2011 Share Posted September 21, 2011 Hi I am looking for a lisp routine that will ask for 2 points, then draw a rectangle using those 2 points, then offset that rectangle in a certain set amount the finally turn the outer rectangle's width into a thicker line. Does anyone have something like that? Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 22, 2011 Share Posted September 22, 2011 Some obfuscated fun... ([color=BLUE]defun[/color] c:test ( [color=BLUE]/[/color] _getdist _corners->list _offsetinside _rectangle a b c d ) ([color=BLUE]defun[/color] _getdist ( a b c ) ([color=BLUE]set[/color] a ([color=BLUE]cond[/color] ( ([color=BLUE]getdist[/color] ([color=BLUE]strcat[/color] b [color=MAROON]" <"[/color] ([color=BLUE]rtos[/color] ([color=BLUE]set[/color] a ([color=BLUE]cond[/color] ( ([color=BLUE]eval[/color] a) ) ( c )))) [color=MAROON]">: "[/color] ) ) ) ( ([color=BLUE]eval[/color] a) ) ) ) ) ([color=BLUE]defun[/color] _corners->list ( a b ) ([color=BLUE]mapcar[/color] ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]list[/color] ([color=BLUE]car[/color] a) ([color=BLUE]cadr[/color] b))) ) ([color=BLUE]list[/color] a b b a) ([color=BLUE]list[/color] a a b b) ) ) ([color=BLUE]defun[/color] _offsetinside ( a b ) ([color=BLUE]mapcar[/color] ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( b c ) ([color=BLUE]mapcar[/color] ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( b c ) (([color=BLUE]eval[/color] b) c a)) ) b c ) ) ) '(([color=BLUE]+[/color] [color=BLUE]+[/color]) ([color=BLUE]-[/color] [color=BLUE]+[/color]) ([color=BLUE]-[/color] [color=BLUE]-[/color]) ([color=BLUE]+[/color] [color=BLUE]-[/color])) b ) ) ([color=BLUE]defun[/color] _rectangle ( a b c ) ([color=BLUE]entmakex[/color] ([color=BLUE]append[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"LWPOLYLINE"[/color]) '(100 . [color=MAROON]"AcDbEntity"[/color]) '(100 . [color=MAROON]"AcDbPolyline"[/color]) '(90 . 4) '(70 . 1) ([color=BLUE]cons[/color] 43 a) ([color=BLUE]cons[/color] 210 c) ) ([color=BLUE]mapcar[/color] '([color=BLUE]lambda[/color] ( d ) ([color=BLUE]cons[/color] 10 ([color=BLUE]trans[/color] d 1 c))) b) ) ) ) (_getdist '*off* [color=MAROON]"\nSpecify Offset"[/color] 5.0) (_getdist '*thk* [color=MAROON]"\nSpecify Thickness"[/color] 1.0) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] a ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify First Corner: "[/color])) ([color=BLUE]setq[/color] b ( ([color=BLUE]if[/color] ([color=BLUE]zerop[/color] ([color=BLUE]getvar[/color] 'WORLDUCS)) [color=BLUE]getpoint[/color] [color=BLUE]getcorner[/color] ) a [color=MAROON]"\nSpecify Opposite Corner: "[/color] ) ) ) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] c ([color=BLUE]apply[/color] '_corners->list ([color=BLUE]mapcar[/color] ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( c ) ([color=BLUE]apply[/color] '[color=BLUE]mapcar[/color] ([color=BLUE]cons[/color] c ([color=BLUE]list[/color] a b))) ) ) '([color=BLUE]min[/color] [color=BLUE]max[/color]) ) ) d ([color=BLUE]trans[/color] '(0.0 0.0 1.0) 1 0 [color=BLUE]t[/color]) ) (_rectangle *thk* c d) (_rectangle 0.0 (_offsetinside *off* c) d) ) ) ([color=BLUE]princ[/color]) ) Should work in all UCS/Views too. Quote Link to comment Share on other sites More sharing options...
Grigs Posted September 22, 2011 Author Share Posted September 22, 2011 Wow!! That's works just perfect. Thanks. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 22, 2011 Share Posted September 22, 2011 Good stuff Grigs, I had fun writing it Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 23, 2011 Share Posted September 23, 2011 A variation on the theme draws two rectangs on an angle. ; draw pits with 100mm walls ; By Alan H 2011 (setq oldsnap (getvar "osmode")) (setq oldlayer (getvar "clayer")) (command "_layer" "n" "Design-Drainage-Pits" "c" 4 "Design-Drainage-Pits" "") (setvar "clayer" "Design-Drainage-Pits") (setq length (getreal "\nPlease enter length m eg 0.9: ")) (setq width (getreal "\nPlease enter width : ")) (setq pt1 (getpoint "\npick 1st point to place pit : ")) (setq pt2 (getpoint "\nPick 2nd point for orientation")) (setvar "osmode" 0) (setq pt7 (getpoint "\Pick pt on pit side : ")) (setq ang (angle pt1 pt2)) (setq ang5 (angle pt2 pt7)) (setq diffang (- ang ang5)) (if (> diffang 1.5707) (setq ang2 (- ang 1.570796)) (setq ang2 (+ ang 1.570796)) ) (setq ang3 (+ ang 3.1415926)) (setq ang4 (- ang 1.570796)) (setq pt3 (polar pt1 ang length)) (setq pt4 (polar pt3 ang2 width)) (setq pt5 (polar pt4 ang3 length)) (command "pline" pt1 pt3 pt4 pt5 "c") (setq pt6 (polar pt1 ang 50.0)) (command "offset" 0.1 pt4 pt6 "") (setvar "osmode" oldsnap) (setvar "clayer" oldlayer) (princ) Quote Link to comment Share on other sites More sharing options...
git_thailand Posted September 28, 2011 Share Posted September 28, 2011 hey guy . plaese set fix offset and two differrent layer thank you. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 28, 2011 Share Posted September 28, 2011 hey guy . plaese set fix offset and two differrent layerthank you. The standard offset command has this functionality: Command: OFFSET Current settings: Erase source=No Layer=Source OFFSETGAPTYPE=0 Specify offset distance or [Through/Erase/[color=red]Layer[/color]] <Through>: Quote Link to comment Share on other sites More sharing options...
Grigs Posted February 28, 2012 Author Share Posted February 28, 2012 Lee Mac, this routine works great. I really appreciate you taking the time to help. I do have one tweek. Would it be possible to change the thickness and offset based on the dimscale being used? The offset is defaulted to 1/16" and the thickness at 1/32". But would it be possible to use those base number and use the dimscale as a multiplier? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 28, 2012 Share Posted February 28, 2012 Hi Grigs, The first-time defaults are set by the values on these lines: (_getdist '*off* "\nSpecify Offset" [b][color=red]5.0[/color][/b]) (_getdist '*thk* "\nSpecify Thickness" [color=red][b]1.0[/b][/color]) Perhaps change these to: (_getdist '*off* "\nSpecify Offset" (* 5.0 (getvar 'DIMSCALE))) (_getdist '*thk* "\nSpecify Thickness" (getvar 'DIMSCALE)) Or some variation of that to suit. Quote Link to comment Share on other sites More sharing options...
Grigs Posted February 28, 2012 Author Share Posted February 28, 2012 Well, I tried that but adding that doesn't seem to change the values. It still says 1/16" and 1/32". Kinda weird. (_getdist '*off* "\nSpecify Offset" (* 0.0625 (getvar 'DIMSCALE))) (_getdist '*thk* "\nSpecify Thickness" (* 0.03125 (getvar 'DIMSCALE))) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted February 28, 2012 Share Posted February 28, 2012 It will stay the same in the same drawing, since the variables are global and so the program remembers the last entered input - you will need to start a new drawing to see the change. Quote Link to comment Share on other sites More sharing options...
Grigs Posted March 5, 2012 Author Share Posted March 5, 2012 Or reset them prior to existing the program? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 5, 2012 Share Posted March 5, 2012 If you don't want the program to remember the last value, just localise the variables *thk* and *off* Quote Link to comment Share on other sites More sharing options...
Grigs Posted March 5, 2012 Author Share Posted March 5, 2012 (edited) NM. Google is your friend Edited March 5, 2012 by Grigs 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.