Lee Mac Posted October 13, 2011 Share Posted October 13, 2011 I was recently looking for one which could draw a rectangle from two corner points but take the rotation from a selected polyline but I didn't find one. Why not just change your UCS? Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 14, 2011 Share Posted October 14, 2011 Why not just change your UCS? Because that would make too much sense. Quote Link to comment Share on other sites More sharing options...
Least Posted October 14, 2011 Share Posted October 14, 2011 Oh yeah, sorry I got my wires crossed. I thought snapline.lsp changed the ucs but it seems it doesn't as when I used it the rectangle was still drawn ortho. It seems this snapline.lsp only modifies the snapang. Ucs works great Good stuff Quote Link to comment Share on other sites More sharing options...
Least Posted October 14, 2011 Share Posted October 14, 2011 This is what I have come up: (defun c:RP (/ temperr p1 p3) (setq temperr *error*) ;store *error* (setq *error* trap1) ;re-assign *error* (command "undo" "m") ;undo mark (prompt "Select object to align UCS:") (command "_.ucs" "_OB" pause) (setq oldecho (getvar "cmdecho")) (setvar "cmdecho" 1) (command "rectangle" pause pause "") (setvar "cmdecho" oldecho) ;reset variable (command "_.ucs" "W") (prompt "\nReset UCS") (setq *error* temperr) ;restore *error* (princ) ) (prompt "\nRectangle By Polyline Angle Loaded, Enter RP to run.") (princ) (defun trap1 (errmsg) ;define function (command "undo" "b") ;undo back; (setvar "cmdecho" oldecho) ;restore vriable (setq *error* temperr) ;restore *error* (prompt "\nResetting System Variables") ;inform user (princ) ) but it doesn't reset the crosshairs on error any idea why?? Thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 14, 2011 Share Posted October 14, 2011 I thought the use of SnapAng was obsolete now - out of curiosity. what does SnapAng do that the UCS cannot? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 14, 2011 Share Posted October 14, 2011 but it doesn't reset the crosshairs on error any idea why?? For something like this, I would be inclined to retain the original command-line prompts so that the user can access the other options provided by the command, maybe something as simple as: (defun c:rp nil (command "_.ucs" "_ob" pause "_.rectangle") (while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) (command "_.ucs" "_P") (princ) ) Or to include the error handler to reset the UCS: (defun c:rp ( / *error* ) (defun *error* ( msg ) (command "_.ucs" "_P") (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)) ) (princ) ) (command "_.ucs" "_ob" pause "_.rectangle") (while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) (command "_.ucs" "_P") (princ) ) Quote Link to comment Share on other sites More sharing options...
ReMark Posted October 14, 2011 Share Posted October 14, 2011 I use SNAPANG when I temporarily want to change the angle of my cross-hairs for matching some geometry that I am editing. When done I click on a macro button that resets the snapang to "0". I know of one user that has set up SNAPANG buttons for the angles 22.5 and 45 for doing piping layouts in 2D. Quote Link to comment Share on other sites More sharing options...
Least Posted October 14, 2011 Share Posted October 14, 2011 Thanks Lee that works perfectly. My lisp now works after adding (command "_.ucs" "_P") to the error handler Yours is much prettier. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 14, 2011 Share Posted October 14, 2011 Thanks Lee that works perfectly. My lisp now works after adding (command "_.ucs" "_P") to the error handler Yours is much prettier. Thanks Least Quote Link to comment Share on other sites More sharing options...
RRS1987 Posted October 19, 2011 Author Share Posted October 19, 2011 Dear Mr. David, I want to modify Lisp (Polyline rectangle lisp) as per my one requirement, Which i got from here. I want to give offset width from the points P1 & P2, which showed in the attachment. Please refer the attachment. Thanks in advance. RECT.pdf Quote Link to comment Share on other sites More sharing options...
martinle Posted October 20, 2011 Share Posted October 20, 2011 (defun c:rect3v (/ p1 p2 d1 c1 c2 c3 c4) (initget 1) (setq p1 (getpoint "\nCenter Of 1st Side: ")) (initget 1) (setq p2 (getpoint p1 "\nCenter Of 2nd Side: ")) (grdraw p1 p2 2 1) (initget 7) (setq d1 (getdist "\nOpposing Width: ")) (setq c1 (polar p1 (+ (angle p1 p2) (* pi 0.5)) (* d1 0.5)) c2 (polar p1 (+ (angle p1 p2) (* pi -0.5)) (* d1 0.5)) c3 (polar p2 (+ (angle p2 p1) (* pi 0.5)) (* d1 0.5)) c4 (polar p2 (+ (angle p2 p1) (* pi -0.5)) (* d1 0.5))) (entmake (list (cons 0 "POLYLINE")(cons 66 1)(cons 70 1)(list 10 0 0 0))) (foreach v '(c1 c2 c3 c4) (entmake (list (cons 0 "VERTEX") (cons 10 (eval v))))) (entmake (list (cons 0 "SEQEND"))) (prin1)) Hello! This is a great Lisp! I manage not to rebuild Sun is not taken but the center of the left corner! Could someone show me? Please help! lg. Martin Quote Link to comment Share on other sites More sharing options...
SOliver Posted October 20, 2011 Share Posted October 20, 2011 I suspect Raman may be doing a small bit of cheating on a college assessment by requesting this script. Quote Link to comment Share on other sites More sharing options...
RRS1987 Posted October 24, 2011 Author Share Posted October 24, 2011 I am working as a draft man. I want to do my work as easily . that's why i asked lisp here. Please help me. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 24, 2011 Share Posted October 24, 2011 RRS, I used the offset distance as a default for the extensions: [b][color=BLACK]([/color][/b]defun c:rect4v [b][color=FUCHSIA]([/color][/b]/ p1 p2 d1 d2 m1 m2 c1 c2 c3 c4[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq p1 [b][color=NAVY]([/color][/b]getpoint [color=#2f4f4f]"\nCenter Of 1st Side: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq p2 [b][color=NAVY]([/color][/b]getpoint p1 [color=#2f4f4f]"\nCenter Of 2nd Side: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]grdraw p1 p2 2 1[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 7[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq d1 [b][color=NAVY]([/color][/b]getdist [color=#2f4f4f]"\nOpposing Width: "[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]initget 6[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq d2 [b][color=NAVY]([/color][/b]getdist [b][color=MAROON]([/color][/b]strcat [color=#2f4f4f]"\nExtension Distance <"[/color] [b][color=GREEN]([/color][/b]rtos d1 2 2[b][color=GREEN])[/color][/b] [color=#2f4f4f]">: "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]or d2 [b][color=NAVY]([/color][/b]setq d2 d1[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq m1 [b][color=NAVY]([/color][/b]polar p1 [b][color=MAROON]([/color][/b]angle p2 p1[b][color=MAROON])[/color][/b] d2[b][color=NAVY])[/color][/b] m2 [b][color=NAVY]([/color][/b]polar p2 [b][color=MAROON]([/color][/b]angle p1 p2[b][color=MAROON])[/color][/b] d2[b][color=NAVY])[/color][/b] c1 [b][color=NAVY]([/color][/b]polar m1 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p1 p2[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] c2 [b][color=NAVY]([/color][/b]polar m1 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p1 p2[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi -0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] c3 [b][color=NAVY]([/color][/b]polar m2 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p2 p1[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi 0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] c4 [b][color=NAVY]([/color][/b]polar m2 [b][color=MAROON]([/color][/b]+ [b][color=GREEN]([/color][/b]angle p2 p1[b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]* pi -0.5[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]* d1 0.5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]entmake [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]cons 0 [color=#2f4f4f]"POLYLINE"[/color][b][color=MAROON])[/color][/b][b][color=MAROON]([/color][/b]cons 66 1[b][color=MAROON])[/color][/b][b][color=MAROON]([/color][/b]cons 70 1[b][color=MAROON])[/color][/b][b][color=MAROON]([/color][/b]list 10 0 0 0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]foreach v '[b][color=NAVY]([/color][/b]c1 c2 c3 c4[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]entmake [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 0 [color=#2f4f4f]"VERTEX"[/color][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]cons 10 [b][color=BLUE]([/color][/b]eval v[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]entmake [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]cons 0 [color=#2f4f4f]"SEQEND"[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Quote Link to comment Share on other sites More sharing options...
martinle Posted October 24, 2011 Share Posted October 24, 2011 Hi David! Your Lisp is great. Could you change it to left instead of center point eckpunkt? love greetings Martin. Quote Link to comment Share on other sites More sharing options...
RRS1987 Posted October 24, 2011 Author Share Posted October 24, 2011 wow!!! fantastic!!!! Hi Mr.David, It is amazing. I am very grateful to you. Thank you very much. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 24, 2011 Share Posted October 24, 2011 David . I guess the grdraw needs the function *redraw* at the end to remove or disappear the appearance of grdraw drawn line . Regards. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 24, 2011 Share Posted October 24, 2011 RRS, You are welcome ! Tharwat, grdraw lines are a bit like blipmode tick marks, Some people like 'em, some detest 'em. I like 'em in most cases as they give a visual indication as to things that have just been added or changed. Martin, I really don't quite understand your request. The original function used middle left and middle right -David Quote Link to comment Share on other sites More sharing options...
martinle Posted October 25, 2011 Share Posted October 25, 2011 Hi David. I mean the entry of the width is set in the middle of p1, p2. The rectangle should be set but completely left or right of p1 p2. I hope the Google translator is now well rested and does his job well! Best regards Martin:) Quote Link to comment Share on other sites More sharing options...
David Bethel Posted October 27, 2011 Share Posted October 27, 2011 Hi David.I mean the entry of the width is set in the middle of p1, p2. The rectangle should be set but completely left or right of p1 p2. I hope the Google translator is now well rested and does his job well! Best regards Martin:) Sorry, I just saw your request. What you've listed basically makes a square. Is that what you need? -David 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.