BudPerry Posted July 26, 2012 Posted July 26, 2012 In this portion of a continuing program I'm putting together, a 4' block is inserted at a user point at a defined angle, then it is again inserted but this time 4' away at the same angle so that the two blocks form an 8' line. This is continued until the user stops the program. However, when the second block is inserted, it is rotated correctly but inserted somewhere north of where it is supposed to be. Obviously my polar calc or something is off: (defun c:blockinsert () ; ; ; ;part 5 of overall program ; ; (setq p1 (getpoint "\nSELECT POINT: "));user inputs first point (setq p2 (getpoint "\nSELECT NEXT POINT: "));user inputs second point - for use in part 6 of program ; (setq ang1 (angle p1 p2));get angle from user points (setq angreal (* 180.0 (/ ang1 pi)));convert from radians to degrees ; (setq blockpt "@48<");create a string that puts the next block at 48 inches away at same angle - from first point ; (command "_insert" "I:/documents/pog-panel-4" P1 "1" "1" angreal "1" "category text" "lf");first insertion at first point with two attributes filled ; (setq nextpoint (polar p1 angreal 48));add 4' from p1 at same angle (setq nextp (strcat blockpt angreal));this line is wrong, but I can't figure out how to get the info into the command line... ; (command "_insert" "I:/documents/pog-panel-4" nextp "1" "1" angreal "1" "category text" texttwo) ;insert 4' from last one ; ; ;now I need to add a line that will increase the amount from 4' to 8', ;then to 12', and so on in multiples of 4' - the block is 4' long ;until the user hits escape to stop the block insertions ;maybe use the repeat function? ; );end defun Any ideas on how to correct the insertion and how to create the repeat function and user break? Quote
MSasu Posted July 26, 2012 Posted July 26, 2012 Please pay attention that the POLAR function require the angle to be in radians, not in degrees: (setq nextpoint (polar p1 [color=red]ang1[/color] 48)) Quote
MSasu Posted July 26, 2012 Posted July 26, 2012 I attempted some changes to your code, even though I don’t understand what you intend to do with the third attribute: (defun c:blockinsert( / oldCmdEcho point1st angleInsert nextItem ) (setq oldCmdEcho (getvar "CMDECHO")) (setvar "CMDECHO" 0) (setq nextItem "Yes") (if (and (setq point1st (getpoint "\nIndicate start point: ")) (setq angleInsert (getorient point1st "\nIndicate direction: "))) (while (not (or (initget "Yes No") (= nextItem "No"))) (command "_INSERT" "p4" point1st 1.0 1.0 (* (/ angleInsert pi) 180.0) "1" "category text" "??") (setq point1st (polar point1st angleInsert 48)) (setq nextItem (getkword "Insert another one <Yes>/No?")) ) ) (setvar "CMDECHO" oldCmdEcho) (princ) ) Quote
BudPerry Posted July 26, 2012 Author Posted July 26, 2012 That was the main problem (face palm!) Thanks! 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.