Guest lesliematt Posted July 8, 2010 Posted July 8, 2010 I am working on a lisp will start a polyline at coordinates that i choose. then it will automatically go in the direction of 90 degrees, input a distance, it automatically goes to 0 degrees, and again enter a distance, and then it will automatically finish the box. so pretty much i want a program that will make a polyline box starting at a user specified location, and all i will have to input is a length and a width and it will make it. i need it to be a polyline and not a rectangle because i need to specify a global width. if there is an easier way, please help. lol (defun C:plx() (command "layer" "s" "Plate" "") (command "pline" pause " (princ)) M Quote
Guest lesliematt Posted July 8, 2010 Posted July 8, 2010 actually i realized i could make it with a rectangle and then us pedit to change it to a polyline. Quote
Guest lesliematt Posted July 8, 2010 Posted July 8, 2010 I need to figure out how to make a poly line that will force angles, and all the user needs to do is put in lengths to make an object like this ^ Quote
Tharwat Posted July 8, 2010 Posted July 8, 2010 You can use F8 to do that easily ...... Regards Quote
Tharwat Posted July 8, 2010 Posted July 8, 2010 Its not that hard to make , you need to know the varies lengths of your pose and with " polar " function you can create it easily. Regards Tharwat Quote
Lee Mac Posted July 8, 2010 Posted July 8, 2010 Some fun (defun c:rect ( / p1 p2 ) ;; © Lee Mac 2010 (if (and (setq p1 (getpoint "\nSpecify Pick Corner: ")) (setq p2 (getcorner "\nSpecift Opposite Corner: " p1))) (LM:Rectangle p1 p2 (trans '(0. 0. 1.) 1 0 t)) ) (princ) ) (defun LM:Rectangle ( ll ur norm ) ;; © Lee Mac 2010 (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 4) (cons 70 1) (cons 38 (caddr ll)) (cons 210 norm) ) (mapcar '(lambda ( p ) (cons 10 p)) ( (lambda ( data ) (mapcar '(lambda ( funcs ) (mapcar '(lambda ( func ) ((eval func) data) ) funcs ) ) '((caar cadar) (caadr cadar) (caadr cadadr) (caar cadadr)) ) ) (mapcar '(lambda ( p ) (trans p 1 norm)) (list ll ur) ) ) ) ) ) ) Quote
alanjt Posted July 8, 2010 Posted July 8, 2010 Straight out of my toolbox... (defun c:SQ (/ foo p1 pt w h p2 ent) ;; Draw square polygon at specified height and width (with option to rotate) ;; Alan J. Thompson (defun foo (p) (list 10 (car p) (cadr p))) (if (and (setq p1 (getpoint "\nSpecify NorthWest corner of rectangle: ")) (setq w (getdist "\nSpecify width: ")) (setq h (cond ((getdist (strcat "\nSpecify height <" (rtos w) ">: "))) (w) ) ) ) (progn (setq p2 (polar (setq pt (trans p1 1 0)) 0. w)) (if (setq ent (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) ) (mapcar 'foo (list pt p2 (polar p2 (* 1.5 pi) h) (polar pt (* 1.5 pi) h)) ) ) ) ) (command "_.rotate" ent "" "_non" p1 "_r" "_non" p1 "_non" (trans p2 0 1)) ) ) ) (princ) ) Quote
alanjt Posted July 8, 2010 Posted July 8, 2010 Oops, I didn't notice you posted something Lee. BTW, is there any difference in yours and the command Rectangle (other than it won't match the current UCS angle and always be parallel to view)? Quote
Lee Mac Posted July 8, 2010 Posted July 8, 2010 Oops, I didn't notice you posted something Lee. BTW, is there any difference in yours and the command Rectangle (other than it won't match the current UCS angle and always be parallel to view)? No difference - just experimenting. That's the problem with getcorner... Quote
alanjt Posted July 8, 2010 Posted July 8, 2010 No difference - just experimenting. That's the problem with getcorner... Right on. I figured you were just playing. I know, it's sooooo aggravating. Quote
Lee Mac Posted July 8, 2010 Posted July 8, 2010 I know, it's sooooo aggravating. Yeah, and any imitation would lack OSnap rendering it useless.. Quote
alanjt Posted July 8, 2010 Posted July 8, 2010 Yeah, and any imitation would lack OSnap rendering it useless.. I know. I wish ADesk would be nice to the world and release an update of VLisp or something. I know I need to learn C, but you just can't fight the speed of LISP programming. That's why I use/write so many subs. I'll write quick stuff in the office to perform a very specific task for the day and I'll use 20 subs. Quote
Lee Mac Posted July 8, 2010 Posted July 8, 2010 I know. I wish ADesk would be nice to the world and release an update of VLisp or something. I know I need to learn C, but you just can't fight the speed of LISP programming. That's why I use/write so many subs. I'll write quick stuff in the office to perform a very specific task for the day and I'll use 20 subs. Exactly - that's why I'm struggling so hard to learn C++ or anything more advanced... its just too easy to slip back into the (relatively) easy world of LISP... I hope that Swamp thread regarding VL being improved does materialise eventually - it would be fantastic for VL to be enhanced. PS> Ooo.. Quantum Mechanic Quote
alanjt Posted July 8, 2010 Posted July 8, 2010 Exactly - that's why I'm struggling so hard to learn C++ or anything more advanced... its just too easy to slip back into the (relatively) easy world of LISP... I hope that Swamp thread regarding VL being improved does materialise eventually - it would be fantastic for VL to be enhanced. PS> Ooo.. Quantum Mechanic Yeah, I'm with you on learning a more powerful language. My issue is that I have a job/wife/kid where you have additional time to learn the language. I'll pick up a book soon, but I'll never be able to leave LISP behind for the amount of time a 5 min. routine can save. Quote
Lee Mac Posted July 8, 2010 Posted July 8, 2010 My issue is that I have a job/wife/kid where you have additional time to learn the language. Well - perhaps for this week, but I start my summer job in the next couple of weeks so I won't have the time either... Quote
alanjt Posted July 8, 2010 Posted July 8, 2010 Well - perhaps for this week, but I start my summer job in the next couple of weeks so I won't have the time either... HaHa, have a kid and see how little free time you have. :wink: What're you doing for the summer? Quote
Lee Mac Posted July 8, 2010 Posted July 8, 2010 What're you doing for the summer? Hopefully some CAD work if all goes to plan Quote
alanjt Posted July 8, 2010 Posted July 8, 2010 Hopefully some CAD work if all goes to plan Come to Florida, you can work with me. Quote
Guest lesliematt Posted July 9, 2010 Posted July 9, 2010 Straight out of my toolbox... (defun c:SQ (/ foo p1 pt w h p2 ent) ;; Draw square polygon at specified height and width (with option to rotate) ;; Alan J. Thompson (defun foo (p) (list 10 (car p) (cadr p))) (if (and (setq p1 (getpoint "\nSpecify NorthWest corner of rectangle: ")) (setq w (getdist "\nSpecify width: ")) (setq h (cond ((getdist (strcat "\nSpecify height <" (rtos w) ">: "))) (w) ) ) ) (progn (setq p2 (polar (setq pt (trans p1 1 0)) 0. w)) (if (setq ent (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) ) (mapcar 'foo (list pt p2 (polar p2 (* 1.5 pi) h) (polar pt (* 1.5 pi) h)) ) ) ) ) (command "_.rotate" ent "" "_non" p1 "_r" "_non" p1 "_non" (trans p2 0 1)) ) ) ) (princ) ) This works well. I am fairly new to using lisp tho. i will see how far i can get making the object i previously posted. 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.