Jump to content

Recommended Posts

Posted (edited)

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

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

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 3
  • 2 months later...
Posted

Updated my stretch commands to use a better ssget. AD in there infinite wisdom decided it best to, when crossing an associative hatch when using the stretch command it moves the hatch therefore making it non associative.

 

I've added removing xlines in there too as it pulls them out of line also.

 

; Stretch all in X direction
(defun c:SX (/ *error* var_cmdecho var_osmode var_orthomode ss1 sf) 

  (setq *error* SS:error)
  (SS:startundo)

  (setq var_cmdecho (getvar "cmdecho"))
  (setq var_osmode (getvar "osmode"))
  (setq var_orthomode (getvar "orthomode"))
  (setvar 'cmdecho 0)
  (setvar 'osmode 223)
  (setvar 'orthomode 1)

  ;; Select everything except hatches that are associative and xlines.
  (setq sf (list 
             '(-4 . "<AND") ; Start the AND condition
             '(-4 . "<OR") ; Start the OR condition
             '(0 . "~XLINE") ; Exclude xlines
             '(0 . "HATCH") ; Include hatches but filter them below
             '(-4 . "OR>") ; End the OR condition
             '(-4 . "<NOT") ; Start the NOT condition to exclude associative hatches
             '(71 . 1) ; Associative property of hatches (71 set to 1)
             '(-4 . "NOT>") ; End the NOT condition
             '(-4 . "AND>") ; End the AND condition
           )
  )

  (while (= 0 (logand 0 (getvar 'cmdactive))) 
    (command "_.stretch" (setq ss1 (ssget sf)) "" PAUSE ".yz" "@")
    (vl-cmdf "\\")
  )

  (*error* nil)
  (princ)
)

; Stretch all in Y direction

(defun c:SY (/ *error* var_cmdecho var_osmode var_orthomode ss1 sf) 

  (setq *error* SS:error)
  (SS:startundo)

  (setq var_cmdecho (getvar "cmdecho"))
  (setq var_osmode (getvar "osmode"))
  (setq var_orthomode (getvar "orthomode"))
  (setvar 'cmdecho 0)
  (setvar 'osmode 223)
  (setvar 'orthomode 1)

  ;; Select everything except hatches that are associative and xlines.
  (setq sf (list 
             '(-4 . "<AND") ; Start the AND condition
             '(-4 . "<OR") ; Start the OR condition
             '(0 . "~XLINE") ; Exclude xlines
             '(0 . "HATCH") ; Include hatches but filter them below
             '(-4 . "OR>") ; End the OR condition
             '(-4 . "<NOT") ; Start the NOT condition to exclude associative hatches
             '(71 . 1) ; Associative property of hatches (71 set to 1)
             '(-4 . "NOT>") ; End the NOT condition
             '(-4 . "AND>") ; End the AND condition
           )
  )

  (while (= 0 (logand 0 (getvar 'cmdactive))) 
    (command "_.stretch" (setq ss1 (ssget sf)) "" PAUSE ".xz" "@")
    (vl-cmdf "\\")
  )

  (*error* nil)
  (princ)
)

 

 

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