Is it possible to add this effect to an arbitrary rectangle

Is it possible to add this effect to an arbitrary rectangle

a22663564
Contributor Contributor
1,712 Views
11 Replies
Message 1 of 12

Is it possible to add this effect to an arbitrary rectangle

a22663564
Contributor
Contributor


Like the file
I want to add 5MM line segments in the middle of the horizontal and vertical of any rectangle
Rectangle 8MM inward and add the circle of the following size

Is this feasible?

0 Likes
Accepted solutions (1)
1,713 Views
11 Replies
Replies (11)
Message 2 of 12

Sea-Haven
Mentor
Mentor
Accepted solution

It borders on a custom project ie pay for it, its 3 routines, Mid lines, circles and dims. Its a real good task to have a go at. Its just made up of a lot of polar commands working out the points.

 

Here is a front end to get you started.

 

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values" "Centre length" 5 4 "5" "Circle ver offset " 5 4 "8" "Circle hor offset " 5 4 "8" "Outer Rad " 5 4 "3.6" "Inner Rad " 5 4 "3.1")))
; Ans holds a list of strings

 

 

screenshot167.pngscreenshot167.png

 

0 Likes
Message 3 of 12

Sea-Haven
Mentor
Mentor

This will return the co-ordinates of the 4 corners.

 

(setq plent (entsel "\nPick rectang"))
(if plent (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))

 

0 Likes
Message 4 of 12

Kent1Cooper
Consultant
Consultant

For the midpoint Lines, you can use MarkMidPoints.lsp with its MMP command, available >here<.  It has an option for Polylines to mark either the overall midpoint or the midpoint of each segment.  In the mark-with-Lines option, they will be centered  on the path object, but if you make a Block of a 5-unit-long line, with its insertion base point at an end, you can use that -- experiment with which end is used for the insertion point, which direction it faces in base orientation, and how you specify the rotation in the command.

Kent Cooper, AIA
0 Likes
Message 5 of 12

Sea-Haven
Mentor
Mentor

Kent just an idea "if you make a Block" make a dynamic/constrained block change L & W, rad1 rad2, offV & offH all done.

 

For a2266 3564 via lisp add the L&W to what I previously posted.

0 Likes
Message 6 of 12

a22663564
Contributor
Contributor

Thank you all for your help

Give me a lot of opinions

0 Likes
Message 7 of 12

a22663564
Contributor
Contributor

I tried to write two codes myself

It is a point-to-point trigger code that can be selected on any rectangle

Can it be modified to select a rectangular trigger code?

---------------------------------------------------------------------------------------

(defun C:ff ()

(setvar "osnapcoord" 1)

(setq PT1 (getpoint "\n Choose the first point:"))
(setq PT3 (getcorner pt1 "\n Diagonal point:"))
(setq x1 (car pt1))
(setq y1 (cadr pt1))
(setq x3 (car pt3))
(setq y3 (cadr pt3))
(setq PT2 (list x3 y1))
(setq PT4 (list x1 y3))
(setq pn1 (polar PT1(angle PT1 PT2) (/ (distance PT1 PT2) 2)))
(setq pn2 (polar PT2(angle PT2 PT3) (/ (distance PT2 PT3) 2)))
(setq pn3 (polar PT3(angle PT3 PT4) (/ (distance PT3 PT4) 2)))
(setq pn4 (polar PT4(angle PT4 PT1) (/ (distance PT4 PT1) 2)))

(setq P11(car PT1))
(setq P12(cadr PT1))
(setq P00 (list(+ P11 8)(+ P12 -8)))
(command "circle" P00 "d" "3.6")
(command "circle" P00 "d" "3.1")

(setq P13(car PT2))
(setq P14(cadr PT2))
(setq P01 (list(+ P13 -8)(+ P14 -8)))
(command "circle" P01 "d" "3")

(setq P15(car PT3))
(setq P16(cadr PT3))
(setq P02 (list(+ P15 -8)(+ P16 8)))
(command "circle" P02 "d" "3.6")
(command "circle" P02 "d" "3.1")

(setq P17(car PT4))
(setq P18(cadr PT4))
(setq P03 (list(+ P17 8)(+ P18 8)))
(command "circle" P03 "d" "3")

(princ)
)

 

(defun c:dd ()
(setvar "osnapcoord" 1)
(setq PT1 (getpoint "\n Choose the first point:"))
(setq PT3 (getcorner pt1 "\n Diagonal point:"))
(setq x1 (car pt1))
(setq y1 (cadr pt1))
(setq x3 (car pt3))
(setq y3 (cadr pt3))
(setq PT2 (list x3 y1))
(setq PT4 (list x1 y3))
(setq pn1 (polar PT1(angle PT1 PT2) (/ (distance PT1 PT2) 2)))
(setq pn2 (polar PT2(angle PT2 PT3) (/ (distance PT2 PT3) 2)))
(setq pn3 (polar PT3(angle PT3 PT4) (/ (distance PT3 PT4) 2)))
(setq pn4 (polar PT4(angle PT4 PT1) (/ (distance PT4 PT1) 2)))

(setq pn1x(car pn1))
(setq pn1y(cadr pn1))
(setq pn11 (list(+ pn1x 0)(+ pn1y -5)))
(command "line" pn1 pn11 "")

(setq pn2x(car pn2))
(setq pn2y(cadr pn2))
(setq pn21 (list(+ pn2x -5)(+ pn2y 0)))
(command "line" pn2 pn21 "")

(setq pn3x(car pn3))
(setq pn3y(cadr pn3))
(setq pn31 (list(+ pn3x 0)(+ pn3y 5)))
(command "line" pn3 pn31 "")

(setq pn4x(car pn4))
(setq pn4y(cadr pn4))
(setq pn41 (list(+ pn4x 5)(+ pn4y 0)))
(command "line" pn4 pn41 "")

(princ)
)

 

0 Likes
Message 8 of 12

Sea-Haven
Mentor
Mentor

Good to see you have something close, I would approach it like this.

use Rectang enter L & W

get the rectang co-ords this is 4 points add to this the 1st again, the reason for this is below

use repeat 4 ie 4 points

using rectang points can work out mid pt1 pt2 then draw mid line, 

Can work out the offset 8mm hor and ver for each cnr, 5th co-ord is used as a dummy for the 4th point

draw circles.

end repeat

 

after getting that to work add in the dim and leader functions

 

You may want to use Lee-mac check pline is clockwise else everything may go outside.

 

Using polar and line angles will mean even if you rotate the rectang it will still work.

 

 

 

 

 

 

0 Likes
Message 9 of 12

a22663564
Contributor
Contributor

Give me great ideas thanks

0 Likes
Message 10 of 12

Sea-Haven
Mentor
Mentor

Using multi getvals.lsp try this.

 

(setq a0 0.0 a90 (/ pi 2.0) a180 pi a270 (* 1.5 pi))

(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values" "Length" 5 4 "100" "Height" 5 4 "80" "Centre length" 5 4 "5" "Circle ver offset " 5 4 "8" "Circle hor offset " 5 4 "8" "Outer Rad " 5 4 "3.6" "Inner Rad " 5 4 "3.1")))
(setq 
len (atof (nth 0 ans))
ht (atof (nth 1 ans))
len2 (atof (nth 2 ans))
voff (atof (nth 3 ans))
hoff (atof (nth 4 ans))
rad1 (atof (nth 5 ans))
rad2 (atof (nth 6 ans))
)

 

0 Likes
Message 11 of 12

Sea-Haven
Mentor
Mentor

I thought would have a go at this and see how code could be shortened, so far draws rectang and the 5mm lines at 1/2 point. Next is add circles. 

(setq a90 (/ pi 2.0) a180 pi a270 (* 1.5 pi))
(setq oldsnap (getvar 'osmode))
(defun p1 ()(eval (read (strcat "pt" (rtos x 2 0)))))
(defun p2 ()(eval (read (strcat "pt" (rtos (+ x 1) 2 0)))))
(defun angx ()(eval (read (strcat "ang" (rtos x 2 0)))))


(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values" "Length" 5 4 "100" "Height" 5 4 "80" "Centre length" 5 4 "5" "Circle ver offset " 5 4 "8" "Circle hor offset " 5 4 "8" "Outer Rad " 5 4 "3.6" "Inner Rad " 5 4 "3.1")))

(setq 
len (atof (nth 0 ans))
ht (atof (nth 1 ans))
len2 (atof (nth 2 ans))
voff (atof (nth 3 ans))
hoff (atof (nth 4 ans))
rad1 (atof (nth 5 ans))
rad2 (atof (nth 6 ans))
)

(setq pt1 (getpoint "\pick a point lower left"))
(setq pt2  (polar pt1 (* pi 0.25) 10))
(setvar 'osmode 0)
(command "rectang" "D" len ht pt1 pt2)
(setq co-ord (reverse (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast))))))
(setq co-ord (cons (nth 3 co-ord) co-ord))
; make ptx's
(setq x 0)
(foreach co co-ord
(set (read (strcat "pt" (rtos (setq x (+ x 1)) 2 0))) co)
)

; make angx's
(setq x 1)
(repeat 4
(set (read (strcat "ang" (rtos x 2 0))) (angle (eval (read (strcat "pt" (rtos x 2 0))))(eval (read (strcat "pt" (rtos (+ x 1) 2 0))))))
(setq x (+ x 1))
)

(setq x 1)
(repeat 4
(setq pt6 (mapcar '(lambda (x) (/ x 2.0)) (mapcar '+ (p1) (p2))))
(setq pt7 (polar pt6 (- (angX) a90) len2))
(command "line" pt6 pt7 "")
(setq x (+ x 1))
)

 

 

0 Likes
Message 12 of 12

Sea-Haven
Mentor
Mentor

Why can you not edit your code Autodesk ? This matches the dwg without dims. 

; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/is-it-possible-to-add-this-effect-to-an-arbitrary-rectangle/td-p/9371113
; By Alanh Consulting [email protected]
; March 2020
(defun c:rec33 ( /  x a90 a180 a270 p1 p2 angx ans len ht len2 voff hoff rad1 rad2 rad3 pt1 pt2 pt3 pt4 pt5 ang1 ang2 ang3 ang4 co-ord)
(setq a90 (/ pi 2.0) a180 pi a270 (* 1.5 pi))
(setq oldsnap (getvar 'osmode))
(defun p1 ()(eval (read (strcat "pt" (rtos x 2 0)))))
(defun p2 ()(eval (read (strcat "pt" (rtos (+ x 1) 2 0)))))
(defun angx ()(eval (read (strcat "ang" (rtos x 2 0)))))


(if (not AH:getvalsm)(load "Multi Getvals.lsp"))
(setq ans (AH:getvalsm (list "Enter values" "Length" 5 4 "100" "Height" 5 4 "80" "Centre length" 5 4 "5" "Circle ver offset " 5 4 "8" "Circle hor offset " 5 4 "8" "Outer Rad " 5 4 "3.6" "Inner Rad " 5 4 "3.1" "Other Rad " 5 4 "3.0")))

(setq 
len (atof (nth 0 ans))
ht (atof (nth 1 ans))
len2 (atof (nth 2 ans))
voff (atof (nth 3 ans))
hoff (atof (nth 4 ans))
rad1 (atof (nth 5 ans))
rad2 (atof (nth 6 ans))
rad3 (atof (nth 7 ans))
)

(setq pt1 (getpoint "\pick a point lower left"))
(setq pt2  (polar pt1 (* pi 0.25) 10))
(setvar 'osmode 0)
(command "rectang" pt1 "D" len ht pt2)
(setq co-ord (reverse (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast))))))
(setq co-ord (cons (nth 3 co-ord) co-ord))
; make ptx's
(setq x 0)
(foreach co co-ord
(set (read (strcat "pt" (rtos (setq x (+ x 1)) 2 0))) co)
)

; make angx's
(setq x 1)
(repeat 4
(set (read (strcat "ang" (rtos x 2 0))) (angle (eval (read (strcat "pt" (rtos x 2 0))))(eval (read (strcat "pt" (rtos (+ x 1) 2 0))))))
(setq x (+ x 1))
)

(setq x 1)
(repeat 4
(setq pt6 (mapcar '(lambda (x) (/ x 2.0)) (mapcar '+ (p1) (p2))))
(setq pt7 (polar pt6 (- (angX) a90) len2))
(command "line" pt6 pt7 "")
(setq x (+ x 1))
)

(setq x 1)
(repeat 2
(setq pt7 (polar (p1) (angX) hoff))
(setq pt7 (polar pt7 (- (angx) a90) voff))
(command "circle" pt7 rad3)
(setq x (+ x 1))
(setq pt7 (polar (p1) (angX) voff))
(setq pt7 (polar pt7 (- (angx) a90) hoff))
(command "circle" pt7 rad1)
(command "circle" pt7 rad2)
(setq x (+ x 1))
)
 ; now dims
(princ)
)

 

 

0 Likes