Jump to content

Help with toggling with a button press


3dwannab

Recommended Posts

@Steven P Nice coding. 👍 I am currently studying it and good move to use point capture to create the selection window ahead of time.

 

However - It doesn't seem to work for me in my AutoCAD 2025. No sure why yet. The prompts all work fine, but it's not switching the pickbox to the to the base point selection for me, even though the prompt is saying so. When I try selecting it with the pickbox cursor, it seems to select a point, but then does nothing when I select the 2nd point, except exit out.

 

However, if the OP is happy and it's working for him - then great!

Edited by pkenewell
  • Like 1
Link to comment
Share on other sites

Thanks.

 

Strange, I am still on 2022 though about time to update. Sounds like it is running through the code OK but the code isn't doing what it should.

 

I'm not happy with the code yet, aiming next time I look at it to pick all points before the stretch which might fix that, or it might add a whole world of problems. Pick all points before stretching then OP can switch X to Y at any point in the routine. Got Lee Macs grsnap to add into it too - snaps would be handy (grread doesn't do snaps). Next change is to specify a distance rather than mouse clicks

 

 

  • Like 1
Link to comment
Share on other sites

On 9/10/2024 at 10:19 PM, Steven P said:

This is taking the above a little further, but is not as finished as I might want.

 

 

I commend all your hard work with this. It's ended up more complex than I ever thought. Thank you.

 

It's lacking the ability to shift select to deselect objects. Looking at the code I wouldn't even know where to begin adding this in to it.

 

 

  • Like 1
Link to comment
Share on other sites

What I use in my day-to-day work is basically something like this. I'd normally type the right command name in and go about that approach. As Steven pointed out, once the direction is set, most users are happy with it. (Only works in 2D):

 

(defun c:lx nil (CommandDirection (list "_.LINE" pause) ".Y"))
(defun c:ly nil (CommandDirection (list "_.LINE" pause) ".X"))
(defun c:cx (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_.COPY" ss "" "_M" pause) ".Y")))
(defun c:cy (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_.COPY" ss "" "_M" pause) ".X")))
(defun c:mx (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_MOVE" ss "" pause) ".Y")))
(defun c:my (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_MOVE" ss "" pause) ".X")))
(defun c:sx (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_STRETCH" ss "" pause) ".Y")))
(defun c:sy (/ ss) (if (setq ss (ssget "_:L")) (CommandDirection (list "_STRETCH" ss "" pause) ".X")))

;; Command Direction - Jonathan Handojo
;; Creates a command that constraints point prompts to X, Y or Z axis.
;; cmd - a list of strings to pass into the AutoCAD command function.
;;      => The next prompt following the string list supplied must be a point selection.
;; dir - a string of either ".X", ".Y" or ".Z"

(defun CommandDirection (cmd dir)
    (apply 'command cmd)
    (while (not (zerop (getvar "cmdactive"))) 
        (command dir "_non" "@0,0,0" pause)
    )
    (princ)
)

 

  • Like 2
Link to comment
Share on other sites

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