Jump to content

How can I modify this code to allow me to select a base point as basis?


AeJay

Recommended Posts

6 hours ago, BIGAL said:

Try this still thinking about an auto angle approach. Make sure Multi Radio buttons.lsp is saved in a support path directory.Multi radio buttons.lsp

 

; https://www.cadtutor.net/forum/topic/77391-how-can-i-modify-this-code-to-allow-me-to-select-a-base-point-as-basis/
; Dimensions a shape with a 200 offset for 4 sides Right Left Top Bottom.
; By AlanH May 2023 

(defun c:dim200 ( / dr200 dl200 db200 dt200 lst ans)

(defun dr200 ( / pt1 pt2 x lst2 j pt3)
(setq lst2 '())
(foreach pt lst
(setq lst2 (cons (cadr pt) lst2))
)
(setq X (car (vl-sort lst2 '>)))
(setq pt3 (list (+ x 200.) (cadr (car lst))))
(setq x (length lst))
(setq j 0)
(setvar 'osmode 0)
(repeat (- x 1)
(command "dim" "ver" (nth j lst) (nth (1+ j) lst) pt3 "" "exit")
(setq j (1+ j))
)
(setvar 'osmode oldsnap)
(princ)
)

(defun dl200 ( / pt1 pt2 x lst2 j pt3)
(setq lst2 '())
(foreach pt lst
(setq lst2 (cons (car pt) lst2))
)
(setq X (car (vl-sort lst2 '<)))
(setq pt3 (list (- x 200.) (cadr (car lst))))
(setq x (length lst))
(setq j 0)
(setvar 'osmode 0)
(repeat (- x 1)
(command "dim" "ver" (nth j lst) (nth (1+ j) lst) pt3 "" "exit")
(setq j (1+ j))
)
(setvar 'osmode oldsnap)
(princ)
)

(defun dt200 ( / pt1 pt2 y lst2 j pt3)
(setq lst2 '())
(foreach pt lst
(setq lst2 (cons (cadr pt) lst2))
)
(setq Y (car (vl-sort lst2 '>)))
(setq pt3 (list (car (car lst)) (+ y 200.) ))
(setq x (length lst))
(setq j 0)
(setvar 'osmode 0)
(repeat (- x 1)
(command "dim" "hor" (nth j lst) (nth (1+ j) lst) pt3 "" "exit")
(setq j (1+ j))
)
(setvar 'osmode oldsnap)
(princ)
)

(defun db200 ( / pt1 pt2 y lst2 j pt3)
(setq lst2 '())
(foreach pt lst
(setq lst2 (cons (cadr pt) lst2))
)
(setq Y (car (vl-sort lst2 '<)))
(setq pt3 (list (car (car lst)) (- y 200.) ))
(setq x (length lst))
(setq j 0)
(setvar 'osmode 0)
(repeat (- x 1)
(command "dim" "hor" (nth j lst) (nth (1+ j) lst) pt3 "" "exit")
(setq j (1+ j))
)
(setvar 'osmode oldsnap)
(princ)
)

;;;;;;; starts here

(setq oldsnap (getvar 'osmode))
(setq lst '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
)
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(setq ans (ah:butts 1 "V" '("Choose a side" "Right" "Left" "Top" "Bottom")))
(cond
((= ans "Right")(dr200))
((= ans "Left")(dl200))
((= ans "Top")(dt200))
((= ans "Bottom")(db200))
)
(setvar 'osmode oldsnap)
(princ)
)

 

Tried this but somehow weird outputs especially for Right option.

Output for Left:
image.thumb.png.1b3df3bfa4266901f5e9faf632117b2f.png

 

Output for Right:
image.png.796a55aa07bfbffece957aacac0be273.png

 

image.thumb.png.2c4e21a26cf206ec42f6f0fc7bd9997a.png

Output for Top:
image.thumb.png.8950a17a55c0595ef42a05f8658967ae.png

Output for Bottom:
image.thumb.png.19339cef54cedf93691fa571ffc35942.png

Edited by AeJay
Link to comment
Share on other sites

  • 2 weeks later...

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