Saqib_theleo Posted November 7, 2012 Posted November 7, 2012 Hi to all, I want to make a custom Pedit width command Lisp. I want that after "pe" command it takes auto "multiple" value instead of hitting "M", then after selecting objects it takes auto "width" value instead of hitting "W" and asks for value of width. I tried to make one but this is not working well. (defun c:pew nil (command "_.pedit" "_multiple" "_width" "") (princ)) If someone can make this command Lisp I'll be thankful. Quote
MSasu Posted November 7, 2012 Posted November 7, 2012 An alternative: (defun c:pew( / ssetPlines theWidth ) (if (and (setq ssetPlines (ssget '((0 . "LWPOLYLINE")))) (setq theWidth (getreal "\nWidth: "))) (command "_.PEDIT" "_M" ssetPlines "" "_W" theWidth "") ) (princ) ) Quote
Saqib_theleo Posted November 7, 2012 Author Posted November 7, 2012 An alternative: (defun c:pew( / ssetPlines theWidth ) (if (and (setq ssetPlines (ssget '((0 . "LWPOLYLINE")))) (setq theWidth (getreal "\nWidth: "))) (command "_.PEDIT" "_M" ssetPlines "" "_W" theWidth "") ) (princ) ) Helo MSasa, Thanks for reply, your lisp is working fine but only on polylines where Pedit command works on lines and arcs too. Is this possible to make this lisp to work on Plines, Lines, Arcs etc. Thanks. Quote
MSasu Posted November 7, 2012 Posted November 7, 2012 Please try this: (defun c:pew( / ssetPlines theWidth oldPedAccept ) (setq oldPedAccept (getvar "PEDITACCEPT")) (setvar "PEDITACCEPT" 1) (if (and (setq ssetPlines (ssget '((0 . "*LINE,ARC")))) (setq theWidth (getreal "\nWidth: "))) (command "_.PEDIT" "_M" ssetPlines "" "_W" theWidth "") ) (setvar "PEDITACCEPT" oldPedAccept) (princ) ) Quote
Saqib_theleo Posted November 7, 2012 Author Posted November 7, 2012 Try this: (defun c:pew( / ssetPlines theWidth oldPedAccept ) (setq oldPedAccept (getvar "PEDITACCEPT")) (setvar "PEDITACCEPT" 1) (if (and (setq ssetPlines (ssget '((0 . "*LINE,ARC")))) (setq theWidth (getreal "\nWidth: "))) (command "_.PEDIT" "_M" ssetPlines "" "_W" theWidth "") ) (setvar "PEDITACCEPT" oldPedAccept) (princ) ) Thanks, now its working on Lines and arcs too. Just one last question and request (if this is possible plz... otherwise no problem), in pedit command when you are in width command and you give the width value and press enter it keeps the selected objects so that if we entered wrong value you can give width again to these selected objects. Thanks again. Quote
MSasu Posted November 7, 2012 Posted November 7, 2012 Like this? (defun c:pew( / ssetPlines theWidth oldPedAccept ) (setq oldPedAccept (getvar "PEDITACCEPT")) (setvar "PEDITACCEPT" 1) (if (and (setq ssetPlines (ssget '((0 . "*LINE,ARC")))) (setq theWidth (getreal "\nWidth: "))) (progn (command "_.PEDIT" "_M" ssetPlines "") (setvar "PEDITACCEPT" oldPedAccept) (command "_W" theWidth pause) ) ) (princ) ) No offence, but I'm not sure if is a good idea to quote (at least entirely) the previous message; is very clear to what you were referring to and make the thread difficult to follow. Quote
Saqib_theleo Posted November 7, 2012 Author Posted November 7, 2012 Thanks MSasu, now this is working fine. Apologize for that, I'll be careful in future and will go to reply rather than reply with quote. Thanks again. Quote
Lee Mac Posted November 7, 2012 Posted November 7, 2012 Some really old programs... may be of interest http://lee-mac.com/polylineprograms.html Quote
nod684 Posted November 8, 2012 Posted November 8, 2012 mircea, hope you don't mind me modfying your code a bit... (defun c:pew ( / ssetPlines theWidth oldPedAccept ) (setq oldPedAccept (getvar "PEDITACCEPT")) (setvar "PEDITACCEPT" 1) (prompt "\nSelect Objects to Modify Width: ") (while (null (setq ssetPlines (ssget '((0 . "*LINE,ARC"))))) (princ "\nInvalid Selection. Try Again!") ) (initget (+ 1 4 )) (while (= theWidth nil) (setq theWidth (getreal "\nEnter New Width: ")) ) (progn (command "_.PEDIT" "_M" ssetPlines "") (setvar "PEDITACCEPT" oldPedAccept) (command "_W" theWidth "") ) (princ "\nDone!") (princ) ) Quote
MSasu Posted November 8, 2012 Posted November 8, 2012 For sure I don’t mind; in fact I like to see other programmers visions. Regarding the change on input I’m not sure that I like to constrain the user to input a value – both SSGET and GETREAL had built-in input filters and may repeat interrogation if case. The solution you proposed prevents the exit using (that it, a null answer – user changed his/her mind; also this is the way native tools behave) and allow to exit only by . In this case is recommended to add an error management sub-routine to ensure a clear exit. Quote
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.