traumathecat Posted July 27, 2010 Posted July 27, 2010 Hi all. I am searching for a command or lisp routine that will allow me to fit a square between two points. The points are on diagonal corners of the square and the rotations vary so I have not been able to use the RECTANGLE or POLYGON commands. Does anyone know of a command or lisp routine that would be able determine the rotation and size of the square and draw it between the two diagonal points? Thanks for your help. Quote
rkmcswain Posted July 27, 2010 Posted July 27, 2010 If you use the ._Rectang command along with the _Dimension and _Rotation options, won't this work? Quote
traumathecat Posted July 27, 2010 Author Posted July 27, 2010 If you use the ._Rectang command along with the _Dimension and _Rotation options, won't this work? I should mention that I have several hundred sets of points to be made into squares each of which is not necessarily the same size or on the same rotation. I don't think these commands will work unless I first go through and calculate the size and rotation for each square, right? Quote
traumathecat Posted July 27, 2010 Author Posted July 27, 2010 I suspect what I am going to need is a LISP routine that will find the distance and angle between the two points, then calculate the rotation and dimensions from that information, and draw the square. Unfortunately, I know nothing about writing LISP routines. Maybe this is a good time for me to learn! Quote
CALCAD Posted July 28, 2010 Posted July 28, 2010 traumathecat, Yes, if you want to learn to write Autolisp, this problem would be good practice. There are several possible ways to solve the problem with lisp. I would first try simply automating the procedure outlined by rkmcswain, since you seem to understand the requirements. Go for it! Plenty of help is available by asking in the appropriate forum. Quote
rkmcswain Posted July 28, 2010 Posted July 28, 2010 I should mention that I have several hundred sets of points to be made into squares each of which is not necessarily the same size or on the same rotation. I don't think these commands will work unless I first go through and calculate the size and rotation for each square, right? Ok. I had guessed that since this was posted in the regular AutoCAD forum, a built in command might have worked for you... You might try starting some lisp code and posting for help in the autolisp forum, as CALCAD suggested. Try to at least write some pseudo code, and I'm sure you will find some help there. On the other hand, requests that just say "I need someone to write me a routine to do x...." are met with less enthusiasm. EDIT: I see you have already been there. In that case, best of luck... Quote
BIGAL Posted July 29, 2010 Posted July 29, 2010 Start with (setq pt1 (getpoint "\nPick point ")) (setq x1 (car pt1)) this is x value of point (setq y1 (cadr pt1)) this is y value of point now draw box using "polar" command to calculate new points or even just do a line command my choice polar as it is good to learn for other routines (setq Pt3 (polar pt1 horang X)) (setq pt4 (polar pt3 verang y)) (command "line" pt1 pt3 pt4 pt5 pt1 "'") left a couple of things out for you to learn "distance" y1 y2 horang = 0.0 verang = 1.5707 check your radians for angles ! Quote
rkmcswain Posted July 29, 2010 Posted July 29, 2010 Start with...There is a thread in the customization forum on this topic.http://www.cadtutor.net/forum/showthread.php?50880-LISP-routine-format-and-commands Quote
traumathecat Posted August 14, 2010 Author Posted August 14, 2010 traumathecat,Yes, if you want to learn to write Autolisp, this problem would be good practice. There are several possible ways to solve the problem with lisp. I would first try simply automating the procedure outlined by rkmcswain, since you seem to understand the requirements. Go for it! Plenty of help is available by asking in the appropriate forum. Thank you for the advice/encouragement. Autolisp was definitely the way to go. It's new territory for me, but I am learning... with a lot of help! Quote
traumathecat Posted August 14, 2010 Author Posted August 14, 2010 Ok. I had guessed that since this was posted in the regular AutoCAD forum, a built in command might have worked for you...You might try starting some lisp code and posting for help in the autolisp forum, as CALCAD suggested. Try to at least write some pseudo code, and I'm sure you will find some help there. On the other hand, requests that just say "I need someone to write me a routine to do x...." are met with less enthusiasm. EDIT: I see you have already been there. In that case, best of luck... Thank you. I initially posted here as I was not sure if there was a built-in feature that could accomplish what I was trying to do. It seems there is not. The Customization Forum worked out well for me. I was able to get some great help. My attempt to write the code on my own got me on the right track, but I definitely needed help to complete it. I am so grateful for all the helpful people here. Quote
traumathecat Posted August 14, 2010 Author Posted August 14, 2010 Start with (setq pt1 (getpoint "\nPick point ")) (setq x1 (car pt1)) this is x value of point (setq y1 (cadr pt1)) this is y value of point now draw box using "polar" command to calculate new points or even just do a line command my choice polar as it is good to learn for other routines (setq Pt3 (polar pt1 horang X)) (setq pt4 (polar pt3 verang y)) (command "line" pt1 pt3 pt4 pt5 pt1 "'") left a couple of things out for you to learn "distance" y1 y2 horang = 0.0 verang = 1.5707 check your radians for angles ! Thank you. I did not see your post until after I posted in the Customization Forum. My approach ended up being a little different... getting the two points... calculating the angle between them... then invoking the rectangle command to draw a rectangle with that rotation between the two points. You can follow the progression into a working LISP here http://www.cadtutor.net/forum/showthread.php?50880-LISP-routine-format-and-commands 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.