BudPerry 发表于 2022-7-6 07:41:56

insert block at distance & ang

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

MSasu 发表于 2022-7-6 08:08:51

Please pay attention that the POLAR function require the angle to be in radians, not in degrees:

(setq nextpoint (polar p1 ang1 48))

MSasu 发表于 2022-7-6 08:22:10

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 /No?")) ))(setvar "CMDECHO" oldCmdEcho)(princ))

BudPerry 发表于 2022-7-6 08:50:26

That was the main problem (face palm!)
 
Thanks!
页: [1]
查看完整版本: insert block at distance & ang