Refer to my other post's thread dated7/21/04 for what led up to this and what I am trying to do. Below is what I have been able to come up with, yet I am still having problems. I do not know in lisp how to tell it I want it to move this far, on this side of wall or column. ????? Thanks again, Rob (defun c:mr (/ OLD_OS RTU_BLK PT-1 PT-2) (setq OLD_OS (getvar "osmode")) (setvar "osmode" 675) (setq PT-1 (getpoint "\nSelect Column or Wall: ")) (setq PT-2 (getpoint "\nPick Side of Column for RTU: ")) (setvar "osmode" 64) (setq PT-3 (getpoint "\nSelect RTU Insertion Point: ")) (setq PT-4 (getdist "\n<Offset Distance>: ")) (setvar "osmode" 0) (prompt "\nSelect RTU") (setq RTU_BLK (ssget)) (if RTU_BLK (command "move" RTU_BLK "" pt-3 pt-1) ) ;if (command "move" RTU_BLK "" pt-2 pt-4) (setvar "osmode" OLD_OS) (princ) )
Try this modification: (defun c:mr (/ OLD_OS RTU_BLK PT-1 PT-3 PX dir di) (setq OLD_OS (getvar "osmode")) (setvar "osmode" 675) (setq PT-1 (getpoint "\nSelect Column or Wall: ")) (setvar "osmode" 64) (setq PT-3 (getpoint "\nSelect RTU Insertion Point: ")) (setq DI (getdist "\n<Offset Distance>: ")) (setvar "osmode" 0) (prompt "\nSelect RTU") (setq RTU_BLK (ssget)) (if RTU_BLK (progn (setq p1x (car PT-1) p1y (cadr PT-1)) (setq p3x (car PT-3) p3y (cadr PT-3)) (setq dir (strcase (getstring "\nDirection: p, [D]own, [L]eft, or [R]ight ?:"))) (if (= dir "U") (setq PX (list (+ p1x 0.0)(+ p1y di))) );if (if (= dir "D") (setq PX (list (+ p1x 0.0)(- p1y di))) );if (if (= dir "L") (setq PX (list (- p1x di)(+ p1y 0.0))) );if (if (= dir "R") (setq PX (list (+ p1x di)(+ p1y 0.0))) );if (command "move" RTU_BLK "" pt-3 pt-1) (command "move" RTU_BLK "" pt-1 px) ); progn ); if (setvar "osmode" OLD_OS) (princ) Bob
Thanks Bob, that's exactly what I was trying to do. I must say though you lost me in the program. I have no idea what you did really. ;-) Perhaps you could explain it to me in a right brain interface so that I can understand. ;-) -Rob D.
Rob, The Web side is not in sync with the Outlook Express side. So, here is the explanation.. ;; With Comments.. (defun c:mr (/ OLD_OS RTU_BLK PT-1 PT-3 PX dir di) (setq OLD_OS (getvar "osmode")) (setvar "osmode" 675) (setq PT-1 (getpoint "\nSelect Column or Wall: ")) (setvar "osmode" 64) (setq PT-3 (getpoint "\nSelect RTU Insertion Point: ")) (setq DI (getdist "\n<Offset Distance>: ")); Get offset distance e.g. 1.5' (setvar "osmode" 0) (prompt "\nSelect RTU") (setq RTU_BLK (ssget)) (if RTU_BLK; if something selected, proceed (progn (setq p1x (car PT-1) p1y (cadr PT-1)); Get X and Y value of PT-1 (setq p3x (car PT-3) p3y (cadr PT-3)); Get X and Y value of PT-3 ;; Which direction does operator want to move the RTU_BLK from the Wall ? (setq dir (strcase (getstring "\nDirection: {U}p, {D}own, {L}eft, or {R}ight ?:"))) (if (= dir "U"); Up, Calculate point, PT-1 (Y + distance), X as is (setq PX (list (+ p1x 0.0)(+ p1y di))) );if (if (= dir "D"); Down, Calculate point, PT-1 (Y - distance), X as is (setq PX (list (+ p1x 0.0)(- p1y di))) );if (if (= dir "L"); Left, Calculate point, PT-1 (X - distance), Y as is (setq PX (list (- p1x di)(+ p1y 0.0))) );if (if (= dir "R"); Right, Calculate point, PT-1 (X + distance), Y as is (setq PX (list (+ p1x di)(+ p1y 0.0))) );if (command "move" RTU_BLK "" pt-3 pt-1); First, move selected to PT-1 (command "move" RTU_BLK "" pt-1 px); Next, move selected to Calculated Point PX ); progn ); if (setvar "osmode" OLD_OS) (princ) ) Bob
Bob, nother question. How do you know what you are getting with the cadr and car? On association lists how do you know how to extract the info you are looking for? I am familiar with the dxf codes, but, I also have problems with understanding extracting the info from the list I want to use, along with understanding how to make the loops, if statements, and things like that work. Thanks once again, Rob
Rob, (short answer to your questions..) <<"Bob, nother question. How do you know what you are getting with the cadr and car? On association lists how do you know how to extract the info you are looking for? I am familiar with the dxf codes, but, I also have problems with understanding extracting the info from the list I want to use, along with understanding how to make the loops, if statements, and things like that work.>>" Examples: ;; ;; Local DXF Function (defun dxf (code elist) (cdr (assoc code elist)) ); end function dxf ** Select object (ssget).. Command: (setq ss (ssget)) Select objects: 1 found Select objects: <Selection set: 2> ** Get the entity definition of the 1st item in ss.. Command: (setq ent (entget (ssname ss 0))) ((-1 . <Entity name: 4008f5c0>) (0 . "INSERT") (330 . <Entity name: 40091480>) (5 . "570") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbBlockReference") (66 . 1) (2 . "DEVID") (10 6.0 7.3438 0.0) (41 . 1.0) (42 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0)) ** Notice it was a block insert.. get the Attribute (assoc 66 = 1), has attributes.. Command: (setq atr (entget (entnext (dxf -1 ent)))) ((-1 . <Entity name: 4008f5c8>) (0 . "ATTRIB") (330 . <Entity name: 4008f5c0>) (5 . "571") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (6 . "Continuous") (100 . "AcDbText") (10 5.60417 7.3438 0.0) (40 . 0.125) (1 . "132A PB") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "STANDARD") (71 . 0) (72 . 1) (11 6.0 7.3438 0.0) (210 0.0 0.0 1.0) (100 . "AcDbAttribute") (2 . "DEV_ID") (70 . 0) (73 . 0) (74 . 0)) ** Get the Attribute 'value' - as a string.. Command: (setq atrval (cdr (assoc 1 atr))) "132A PB" ** The above sample selected (1) block and retreived the attribute value. ** Checking Points.. Command: point Current point modes: PDMODE=0 PDSIZE=0.0000 Specify a point: Command: list Select objects: 1 found Select objects: POINT Layer: "0" Space: Model space Color: BYLAYER Linetype: "CONTINUOUS" Handle = 1AA5 at point, X= 7.0000 Y= 3.5625 Z= 0.0000 Command: (setq pt (getvar "lastpoint")) (7.0 3.5625 0.0) Command: (setq X (car pt)) 7.0 Command: (setq Y (cadr pt)) 3.5625 Command: (setq Z (caddr pt)) 0.0 ** Understanding 'lists ** Make a list to examine.. Command: (setq lst (list "A" "B" "C")) ("A" "B" "C") ** Get the 1st value (leftmost) Command: (setq 1st (car lst)) "A" ** Get the 2nd value (middle) Command: (setq 2nd (cadr lst)) "B" ** Get the 3rd value (far right) Command: (setq 3rd (caddr lst)) "C" ** Alternate getting List elements, using nth.. Command: (setq n 0); 1st element is 0, 2nd is 1, etc. 0 Command: (setq 1st (nth n lst)) "A" Command: (setq n (+ n 1)) 1 Command: (setq 2nd (nth n lst)) "B" Command: (setq n (+ n 1)) 2 Command: (setq 3rd (nth n lst)) "C"
Double checked. There are nine messages total on both sides of the discussion group server. If you see any other problem, please send a report to feedback. That would be appreciated. Feedback on the Discussion Groups can be made at http://www.autodesk.com/discussion-feedback
Bob, I'll probably bend your ear some other time if you don't mind. I don't want to wear out my welcome. ;-) Could I email you direct some time after you've had some time to recupe? Thanks again, Rob