Jump to content

Custom Pedit width command Lisp help needed.


Recommended Posts

Posted

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.

Posted

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)
)

Posted
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.

Posted

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)
)

Posted
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.

Posted

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.

Posted

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.

Posted

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)
)

Posted

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...