bruce13557 Posted January 26, 2022 Posted January 26, 2022 During shut downs we get requests for many wear plates very quickly. These are generally a rectangle with 2 to 4 holes. What I am hoping for is a way to do something like the following just by entering the x and y coordinates: rec (manual select point) -X,Y rec @X1,-Y1 X2,-Y2, circle on 4 corners of the last rectangle, delete the last rectangle, then repeat. I don't know if all of this can be done but as much as possible would be great. SAMPLE WEAR PLATE DRAWING.dwg Quote
Dadgad Posted January 26, 2022 Posted January 26, 2022 Sounds like this might be a good function to incorporate into a Dynamic Block, although I am not very good at creating them personally. That or a pretty rudimentary lisp would seem to be another easy way to go. I am sure someone will chime in with suggestions, once a few more forum members see your post. Come to think of it an Action Recorder Macro could do it also. Quote
BIGAL Posted January 26, 2022 Posted January 26, 2022 (edited) Here is a close start for you. You may want to set a dimension style eg (command "-dimstyle" "R" "standard") tested on your dwg needed dimscale to be reset. ; simple draw a box and dimension it ; By Alan H March 2019 ' info@alanh.com.au (defun ah:box ( / pt1 pt2 pt3 ahl ahh ahoff ) (setq oldsnap (getvar 'osmode)) (setq oldang (getvar 'angdir)) (setq pt1 (getpoint "\nPick lower left")) (setvar 'osmode 0) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "Simple rectang" "Enter length" 8 7 "1" "Enter height " 8 7 "2"))) (setq ahL (atof (nth 0 ans))) (setq ahH (atof (nth 1 ans))) (setq pt2 (polar pt1 0.0 ahl)) (setq pt3 (polar pt2 (/ pi 2.0) ahH)) (command "rectang" pt1 pt3) (setq ahoff (* 2.0 (* (getvar 'dimasz)(getvar 'dimscale)))) ; change offset as required (setq pt4 (polar pt2 (* pi 1.5) ahoff)) (command "dim" "hor" pt1 pt2 pt4 "" "exit") (setq pt4 (polar pt3 0.0 ahoff)) (command "dim" "Ver" pt2 pt3 pt4 "" "exit") (setvar 'osmode oldsnap) ) (ah:box) You can see how the box is made so using polar can work out inside box. The multi getvals.lsp needs to be loaded 1st or put in a support path location. Hint for your version. (setq ans (AH:getvalsm (list "Enter Values" "X" 5 4 "100" "X2" 5 4 "50" "X3" 5 4 "50" "Y " 5 4 "100" "Y1 " 5 4 "50" "Y2 " 5 4 "50" "Rad" 5 4 "10" ))) I have added multi toggles for the circles say 1 2 3 4 tick on for position. yes could hard code a single dcl. Multi toggles.lsp Is the inner rectang required or is that just to show the hole positions ? Multi GETVALS.lsp Edited January 27, 2022 by BIGAL 1 Quote
bruce13557 Posted January 26, 2022 Author Posted January 26, 2022 The inner rectangle is just to locate the holes I have loaded the lisp but I can't get it to open, what is the command? Quote
BIGAL Posted January 26, 2022 Posted January 26, 2022 Ok redid it all your task is to finish off the dimensions, the points pt1-pt8 can be used save the 2 multi files.lsp in a search path or change the path in the code to auto load them, save this code as say drawplate.lsp and load. For me would be in a menu. ; simple draw a box and dimension it ; By Alan H March 2019, updated more options Jan 2022 ; info@alanh.com.au (defun c:ahbox ( / pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8 olsnap oldang ahoff z) (setq oldsnap (getvar 'osmode)) (setq oldang (getvar 'angdir)) (setq pt1 (getpoint "\nPick lower left")) (setvar 'osmode 0) (if (not AH:getvalsm)(load "Multi Getvals.lsp")) (setq ans (AH:getvalsm (list "Enter Values" "X" 5 4 "100" "X1" 5 4 "50" "X2" 5 4 "50" "Y " 5 4 "100" "Y1 " 5 4 "50" "Y2 " 5 4 "50" "Rad" 5 4 "10" ))) (setq X (atof (nth 0 ans))) (setq X1 (atof (nth 1 ans))) (setq X2 (atof (nth 2 ans))) (setq Y (atof (nth 3 ans))) (setq Y1 (atof (nth 4 ans))) (setq Y2 (atof (nth 5 ans))) (setq rad (atof (nth 6 ans))) (setq pt2 (polar pt1 0.0 x)) (setq pt3 (polar pt2 (/ pi 2.0) y)) (setq pt4 (polar pt3 (* pi 1.5) x)) (command "rectang" pt1 pt3) (setq pt5 (polar (polar pt1 0.0 x1) (/ pi 2.0) (- y (+ y1 y2)))) (setq pt6 (polar pt5 0.0 x2)) (setq pt7 (polar pt6 (/ pi 2.0) y2)) (setq pt8 (polar pt5 (/ pi 2.0) y2)) ;(command "rectang" pt5 pt7) (if (not AH:Toggs)(load "Multi toggles.lsp")) (setq ans (reverse (ah:toggs '("Choose corners" "1" "2" "3" "4" )))) (setq z 5) (foreach val ans (if (= val "1") (command "CIRCLE" (eval (read (strcat "pt" (rtos z 2 0)))) rad) (princ "\nno circle") ) (setq z (1+ z)) ) (setq ahoff (* 2.0 (* (getvar 'dimasz)(getvar 'dimscale)))) ; change offset as required (setq pt4 (polar pt2 (* pi 1.5) ahoff)) (command "dim" "hor" pt1 pt2 pt4 "" "exit") (setq pt4 (polar pt3 0.0 ahoff)) (command "dim" "Ver" pt2 pt3 pt4 "" "exit") (setvar 'osmode oldsnap) ) (c:ahbox) Quote
bruce13557 Posted January 26, 2022 Author Posted January 26, 2022 Should there have been a Multi Getvals.lsp file? Quote
SLW210 Posted January 26, 2022 Posted January 26, 2022 I moved your thread to the AutoLISP, Visual LISP & DCL Forum. Quote
BIGAL Posted January 27, 2022 Posted January 27, 2022 Sorry about that, Yes all the Multi files can be downloaded from the Download section here Quote
bruce13557 Posted January 27, 2022 Author Posted January 27, 2022 BigAl Thank you That works brilliantly. I had to remove the dimensioning command otherwise I would have had to delete the dimension for the CNC plasma. Where can I change the default dimensions in the Multi Getvals box? I do want to learn to write this type of thing, there are many times I could use it. Do you have any suggestions as to where I can start learning? Quote
bruce13557 Posted January 27, 2022 Author Posted January 27, 2022 I found where to change the default dimensions Thanks again Quote
BIGAL Posted January 27, 2022 Posted January 27, 2022 (edited) You can change some values as default you can also do keep a value for next use in same session. I wont go into that now but its easy. Change to suit colored values, the 5 4 is 5 digits max so if need more say 8 7 instead for text may need like 21 20. Each can be a different size. (setq ans (AH:getvalsm (list "Enter Values" "X" 5 4 "100" "X1" 5 4 "50" "X2" 5 4 "50" "Y " 5 4 "100" "Y1 " 5 4 "50" "Y2 " 5 4 "50" "Rad" 5 4 "10" ))) The ans returned is a list of strings so use Atof or Atoi for numbers. I matched your way of doing x x1 x2 etc Re learning no quick way other than keep looking at tasks like this. Start simple learn about stuff like polar for working out pts, I often draw on a piece of paper the point numbers as I code so dont lose track. A beginner big hint work angles in radians, aunits 3, 90 = (/ pi 2.0) and the nasty Autocad is counter clockwise for angles, but you get used to it. Just post another request then people here will help you to learn. I would look at a custom menu next adding what you download or write much easier than using appload. Edited January 27, 2022 by BIGAL 1 Quote
bruce13557 Posted January 27, 2022 Author Posted January 27, 2022 I'm in Bunbury, Western Australia Quote
Tharwat Posted January 27, 2022 Posted January 27, 2022 Here you go ... (defun c:Test (/ xb4 yb4 pt p1 p2 p3 in 1p 2p 3p) ;; Tharwat Al Choufi - 27.Jan.2.22 ;; (or *Plate:len* (setq *Plate:len* 300.0)) (or *Plate:hgt* (setq *Plate:hgt* 200.0)) (if (and (setq *Plate:len* (cond ((getdist (strcat "\nSpecify X length " (rtos *Plate:len* 2 2) " > : " ) ) ) (*Plate:len*) ) ) (setq *Plate:hgt* (cond ((getdist (strcat "\nSpecify Y length " (rtos *Plate:hgt* 2 2) " > : " ) ) ) (*Plate:hgt*) ) ) (setq xb4 (/ *Plate:len* 4.0) yb4 (/ *Plate:hgt* 4.0) ) ) (while (setq pt (getpoint "\nSpecify base point : ")) (setq p1 (polar pt pi *Plate:len*) p2 (polar p1 (* pi 0.5) *Plate:hgt*) p3 (polar p2 0.0 *Plate:len*) in (polar (polar pt pi xb4) (* pi 0.5) yb4) 1p (polar in pi (* xb4 2.0)) 2p (polar 1p (* pi 0.5) (* yb4 2.0)) 3p (polar 2p 0.0 (* xb4 2.0)) ) (LWPoly pt p1 p2 p3) (LWPoly in 1p 2p 3p) (foreach q (list in 1p 2p 3p) (entmake (list '(0 . "CIRCLE") (cons 10 q) '(40 . 9.0))) ) ) ) (princ) ) ;; ;; (defun LWPoly (1pt 2pt 3pt 4pt) (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) (cons 10 1pt) (cons 10 2pt) (cons 10 3pt) (cons 10 4pt) ) ) ) 1 Quote
Recommended Posts
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.