Jump to content

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


AeJay

Recommended Posts

I currently have been using this code:

(defun c:DLA ( / sel ent txp al ar mp uALR s txpp uvt tp exss exssent exssl exssindex)
	
	(defun deg2rad (ang / )
	  (/ (* PI ang) 180.0)
	)

	(defun rad2deg ( ang / )
	  (/ (* 180.0 ang) PI)
	)

	;; midpoint of 2 given points
	(defun mid ( pt1 pt2 / )
	  (mapcar '(lambda (x y) (+ (* 0.5 x) (* 0.5 y)))
	  pt1
	  pt2
	  )
	)
	
	;;;  Calculate unit vector of vector a 
	(defun uvec 
	  (a / d)
	  (setq	d (distance '(0 0 0) a)
		a (mapcar '/ a (list d d d))
	  )
	)
	
	; Compute the dot product of 2 vectors a and b
	(defun dot ( a b / dd)
	  (setq dd (mapcar '* a b))
	  (setq dd (+ (nth 0 dd) (nth 1 dd) (nth 2 dd)))
	)					;end of dot  

	  (princ "\nInput Desired Distance: ")
	  (setq dist (getreal))
	  
	  (princ "\nSelect Dimension(s) To Change: ")  
	  
		(setq exss (ssget '((0 . "*dim*"))))                           
		(setq exssl (sslength exss))                                   
		(setq exssindex 0) 
		
		(repeat exssl                                                    
			(setq exssent (entget (ssname exss exssindex)))              

			 (setq ent (cdr (car exssent)))                                 
			 (setq txp (cdr (assoc 10 (entget ent))))
			 (setq al (cdr (assoc 13 (entget ent))))
			 (setq ar (cdr (assoc 14 (entget ent))))

			 (setq mp (mapcar '/
						 (mapcar '+ al ar)
				 '(2. 2. 2.)
				 )
			 )

			; uALR = unit vector from al to ar
			(setq uALR (uvec (mapcar '- ar al)))
			(setq s (dot uALR (mapcar '- txp al)))
			
			; txpp = projection of txp onto the line    
			(setq txpp
				   (mapcar '+ al (mapcar '* uALR (list s s s)))
			)
			
			(setq uvt (uvec (mapcar '- txp txpp)))
			(setq tp (mapcar '+ mp (mapcar '* uvt (list dist dist dist))))
			
			(entmod
			  (subst (cons 10 tp) (assoc 10 (entget ent)) (entget ent))
			)
			
			(entmod
			  (subst (cons 11 tp) (assoc 11 (entget ent)) (entget ent))
			)

			 
			 (setq exssindex (+ exssindex 1))     
		)
		
	(princ)
)


However, this somehow messes up when there are selected dimension lines that are not level with each other. Please see the attached images.

 

Before:
before.png.b45116fba67e9f2bf3a92cf147c1640c.png

 

During usage of DLA:
dla1.thumb.png.7921c404cdf024c2567cb803c2d75334.png

 

dla2.thumb.png.55203fc7710da26be78faafd36dba695.png

 

Actual Output: As you can see the dim lines with value of 511 are not inline with the 200mm distanced dimension lines of 464.
outpute.thumb.png.fbd469f6517af1a14d2217a278cf8e8c.png

 

Desired Output: should be the image below where you can see the the 464 dim lines are at 200mm. 
doutput.png.366e7cc105941194b81e0b7c367a3822.png


Is there a way that after the "select objects" prompt that there will be a  "select base point" prompt which will be the basis to adjust all dim lines to the inputted distance. Or as long as there is a way to achieve the desired output.

 

sample.dwg

Edited by AeJay
Link to comment
Share on other sites

Ok I am sure already suggested this somewhere. I do not plan on fixing the dims rather just make them what you want 1st go.

 

This is vertical dim to the right 200 offset from the 2nd pick point. NOTE 2ND point.

 

(defun c:dr200 ( / pt1 pt2)
(while (setq pt1 (getpoint "\nPick 1st point "))
  (setq pt2 (getpoint "\nPick point 2 "))
  (command "dim" "ver" pt1 pt2 (mapcar '+ pt2 (list 200.0 0.0 0.0)) "" "exit")
)
(princ)
)

You want to learn lisp so your task is, the extra defuns, Left, top and bottom the last 2 are hor dims, a hint. Look at "list" in code (list X Y Z) for offsets.

dl200

db200

dt200

Edited by BIGAL
  • Thanks 1
Link to comment
Share on other sites

12 hours ago, marko_ribar said:

Do you know for QDIM command?

I am not familiar with that command :(

 

1 hour ago, BIGAL said:

Ok I am sure already suggested this somewhere. I do not plan on fixing the dims rather just make them what you want 1st go.

 

This is vertical dim to the right 200 offset from the 2nd pick point. NOTE 2ND point.

 

(defun c:dr200 ( / pt1 pt2)
(while (setq pt1 (getpoint "\nPick 1st point "))
  (setq pt2 (getpoint "\nPick point 2 "))
  (command "dim" "ver" pt1 pt2 (mapcar '+ pt2 (list 200.0 0.0 0.0)) "" "exit")
)
(princ)
)

You want to learn lisp so your task is, the extra defuns, Left, top and bottom the last 2 are hor dims, a hint. Look at "list" in code (list X Y Z) for offsets.

dl200

db200

dt200


Thanks for the clues, I got it :)

 

(defun c:dr200 ( / pt1 pt2)
(while (setq pt1 (getpoint "\nPick 1st point "))
  (setq pt2 (getpoint "\nPick point 2 "))
  (command "dim" "ver" pt1 pt2 (mapcar '+ pt2 (list 200.0 0.0 0.0)) "" "exit")
)
(princ)
)

(defun c:dl200 ( / pt1 pt2)
(while (setq pt1 (getpoint "\nPick 1st point "))
  (setq pt2 (getpoint "\nPick point 2 "))
  (command "dim" "ver" pt1 pt2 (mapcar '+ pt2 (list -200.0 0.0 0.0)) "" "exit")
)
(princ)
)

(defun c:dt200 ( / pt1 pt2)
(while (setq pt1 (getpoint "\nPick 1st point "))
  (setq pt2 (getpoint "\nPick point 2 "))
  (command "dim" "hor" pt1 pt2 (mapcar '+ pt2 (list 0.0 200.0 0.0)) "" "exit")
)
(princ)
)

(defun c:db200 ( / pt1 pt2)
(while (setq pt1 (getpoint "\nPick 1st point "))
  (setq pt2 (getpoint "\nPick point 2 "))
  (command "dim" "hor" pt1 pt2 (mapcar '+ pt2 (list 0.0 -200.0 0.0)) "" "exit")
)
(princ)
)


Questions:
1. Is there a way to make this command dynamic by asking user to select with mouse which direction (top, bot, left, right)?
2. Is there really a way to make this code be an adjustment type of tool, like what I mentioned in this thread? 😅

Edited by AeJay
Link to comment
Share on other sites

If you don't need the dimensions to be at that specific spot, I've already released the program Align To Direction that can align the dimensions to any direction you wish. But if not, I can probably adjust the program to suit.

 

In response to your question 1, have a look at using initget and getkword, this will give you a good start.

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Jonathan Handojo said:

If you don't need the dimensions to be at that specific spot, I've already released the program Align To Direction that can align the dimensions to any direction you wish. But if not, I can probably adjust the program to suit.

 

In response to your question 1, have a look at using initget and getkword, this will give you a good start.

Thanks! I didn't even notice that there were a list of other programs in https://www.cadtutor.net/forum/files/category/1-programs-and-scripts/ if you didn't link your program, great!

Is it possible to make a variation that would allow the user to select dim line(s) then still have the "specify alignment direction" option but instead of having infinite elasticity in that direction, only limit it to 200mm?

BTW, this was the result when I used it in the sample.dwg, somehow 3 of the other dim lines were not adjusting correctly.

1. p1.png.49625ce361997dc8ed3e601c40f9168c.png  2. p2.png.8fee9b72811a6b9fd3be6ad8a00961c1.png
 

3p3.png.ba9c648e32f9e9d994dd443d863411e8.png. 4. p4.png.1b9bd8fc23855115e946e824c00b52c8.png

 





 

Link to comment
Share on other sites

The ones labelled 511 and 501 are horizontal dimensions as opposed to vertical dimensions, so of course the result would be as shown in your result. It is a different case than the original post after all.

 

As for one of the dimensions labelled 464, you have the property of the text movement set to "Move text, add leader". The program simply moves the texts, so you may want to change that to "Keep dim line with text", as shown below.

 

image.png.1c3c722d14161072cf56816dbaa92b9a.png

 

With regards to the restricted distance, I will integrate your idea, much like the OFFSET command. I'll let you know when I'm done.

Edited by Jonathan Handojo
  • Thanks 1
Link to comment
Share on other sites

3 hours ago, Jonathan Handojo said:

The ones labelled 511 and 501 are horizontal dimensions as opposed to vertical dimensions, so of course the result would be as shown in your result. It is a different case than the original post after all.

 

As for one of the dimensions labelled 464, you have the property of the text movement set to "Move text, add leader". The program simply moves the texts, so you may want to change that to "Keep dim line with text", as shown below.

 

image.png.1c3c722d14161072cf56816dbaa92b9a.png

 

With regards to the restricted distance, I will integrate your idea, much like the OFFSET command. I'll let you know when I'm done.

 
With regards to "The ones labelled 511 and 501 are horizontal dimensions as opposed to vertical dimensions, so of course the result would be as shown in your result. It is a different case than the original post after all."

Can the current ATD function be modified for horizontal dims as well?

Thanks, I will surely wait for the modified ATD for restricted distance :)

EDIT:
Can the option of allowing Osnap to work too after selecting which direction (when dim line is elastic and selecting till where to align) be possible?

image.thumb.png.568c8609ee9a034dab995d299fb68c62.png
 

As is seen that I have endpoint oSnap turned on but it doesn't appear.

Edited by AeJay
Link to comment
Share on other sites

2 hours ago, AeJay said:

Can the current ATD function be modified for horizontal dims as well?

Are you saying that you want the horizontal dimension to "rotate" to be a vertical dimension? If so, it's possible, but it's out of the scope of the original intention of the program. I will not modify the program to go off scope. It's purely for the intention of aligning every "point" along a direction.

 

2 hours ago, AeJay said:

Can the option of allowing Osnap to work too after selecting which direction (when dim line is elastic and selecting till where to align) be possible?

It's possible, but I opt that out since it can lag quite a lot when working with drawings containing many objects of high density. Originally it's not possible, but with Lee Mac's help, it's doable. I'll implement the distance restriction feature, and then setting a distance of 0 should work similar to snapping.

  • Thanks 1
Link to comment
Share on other sites

On 4/28/2023 at 5:59 PM, Jonathan Handojo said:

Are you saying that you want the horizontal dimension to "rotate" to be a vertical dimension? If so, it's possible, but it's out of the scope of the original intention of the program. I will not modify the program to go off scope. It's purely for the intention of aligning every "point" along a direction.

 

It's possible, but I opt that out since it can lag quite a lot when working with drawings containing many objects of high density. Originally it's not possible, but with Lee Mac's help, it's doable. I'll implement the distance restriction feature, and then setting a distance of 0 should work similar to snapping.

Hi Jonathan, is there an update with the distance of 0 snapping etc?

Link to comment
Share on other sites

On 5/3/2023 at 1:28 PM, AeJay said:

Hi Jonathan, is there an update with the distance of 0 snapping etc?

Just give me a moment, I'm still  working on the calculations to make it as user-friendly as possible.

  • Thanks 1
Link to comment
Share on other sites

Try this has the 4 directions set at 200 offset from closest point. Could do a enter offset etc. Pick points in sequence then enter.

 

(defun c:dr200 ( / pt1 pt2 lst lst2 x j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (car pt1) 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 c:dl200 ( / pt1 pt2 x lst lst2 j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (car pt1) 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 c:dt200 ( / pt1 pt2 lst lst2 y j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (cadr pt1) 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 c:db200 ( / pt1 pt2  lst lst2 y x j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (cadr pt1) 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)
)

 

image.png.8eca991b8b17f7497e2efb17c0d1ebad.png

Edited by BIGAL
  • Thanks 1
Link to comment
Share on other sites

2 hours ago, BIGAL said:

Try this has the 4 directions set at 200 offset from closest point. Could do a enter offset etc. Pick points in sequence then enter.

 

(defun c:dr200 ( / pt1 pt2 lst lst2 x j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (car pt1) 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 c:dl200 ( / pt1 pt2 x lst lst2 j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (car pt1) 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 c:dt200 ( / pt1 pt2 lst lst2 y j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (cadr pt1) 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 c:db200 ( / pt1 pt2  lst lst2 y x j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (cadr pt1) 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)
)

 

image.png.8eca991b8b17f7497e2efb17c0d1ebad.png


This works great, but I don't know why there is an extra "0" tho.

 

image.pngsample.dwg

 

 

 

EDIT:

I am also trying to make it dynamic by combining it into one d200 function, the code below allows me to pick points and all but doesn't accept DB, DT, etc. and always says invalid keyword.
 

(defun c:d200 (/ offset pt1 lst lst2 x j direction)

(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())


	(while (setq pt1 (getpoint "\nPick dim point in sequence. Press Enter to stop. "))
		(setq lst (cons pt1 lst))
		(setq lst2 (cons (car pt1) lst2))
	)
	
	(setq x (length lst))
	(setq j 0)
	(setq direction (getkword "\nEnter offset direction [DR/DB/DL/DT]: "))
	
	(cond
	
	((= direction "DR")
	(setq offset 200.)
	(setq pt3 (list (+ (car (vl-sort lst2 '>)) offset) (cadr (car lst)))))
	
	((= direction "DB")
	(setq offset 200.)
	(setq pt3 (list (car (car lst)) (- (car (vl-sort lst2 '<)) offset))))
	
	((= direction "DL")
	(setq offset -200.)
	(setq pt3 (list (- (car (vl-sort lst2 '<)) offset) (cadr (car lst)))))
	
	((= direction "DT")
	(setq offset -200.)
	(setq pt3 (list (car (car lst)) (+ (cadr (car (vl-sort lst2 '>))) offset))))
	
	(T (princ "\nInvalid direction. Please try again.") (setq offset nil))
	)

	(if offset
		(progn
			(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)
)


 

 

 

 

Edited by AeJay
Link to comment
Share on other sites

On 5/3/2023 at 1:28 PM, AeJay said:

Hi Jonathan, is there an update with the distance of 0 snapping etc?

This program has now been updated as version 1.3 that allows for distance prompting.

  • Thanks 1
Link to comment
Share on other sites

Thinking about pick points work out a average angle between points so auto L R U D. Just need time. eg right is 225-315 degrees from Y axis.

 

  • Thanks 1
Link to comment
Share on other sites

2 hours ago, BIGAL said:

Thinking about pick points work out a average angle between points so auto L R U D. Just need time. eg right is 225-315 degrees from Y axis.

 

Great idea! Sure, will wait for this :)

Edited by AeJay
Link to comment
Share on other sites

On 5/5/2023 at 8:54 AM, BIGAL said:

Try this has the 4 directions set at 200 offset from closest point. Could do a enter offset etc. Pick points in sequence then enter.

 

(defun c:dr200 ( / pt1 pt2 lst lst2 x j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (car pt1) 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 c:dl200 ( / pt1 pt2 x lst lst2 j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (car pt1) 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 c:dt200 ( / pt1 pt2 lst lst2 y j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (cadr pt1) 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 c:db200 ( / pt1 pt2  lst lst2 y x j)
(setq oldsnap (getvar 'osmode))
(setq lst '() lst2 '())
(while (setq pt1 (getpoint "\nPick dim point in sequence Enter to stop "))
(setq lst (cons pt1 lst))
(setq lst2 (cons (cadr pt1) 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)
)

 

image.png.8eca991b8b17f7497e2efb17c0d1ebad.png

Is there an update with the adjusted one for this? 😇

Link to comment
Share on other sites

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

 

  • Like 1
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...