rose sr Posted May 20, 2022 Posted May 20, 2022 hello everyone , hope u all doing so great ... i am new to this cad tutor ,tried searching lisp what i wanted but could not found. so please can any one help me with lisp of room dimension. following step i need from it. 1.selection diagonal points of the rectangular room. 2 .asking for room name to type 3.placing M-TEXT in side room, final outcome is LIVING ROOM 3000X5000 hope somebody could help me in this ... thanks in advance Quote
Steven P Posted May 20, 2022 Posted May 20, 2022 How is your LISP programming? Would I be telling you what you know if I wrote this all out fully or would it all be new to you? I'll meet you half way and give you the basics of what I think you'll need - mostly because the other night I posted what is below (plus a few other bits) just deleted what you don't want so try this (from try this: (defun c:testthis ( / a b c d scpt1 mywidth myheight) (setq spt1 (getpoint "\nPick the first point") spt3 (getcorner "\Pick the next corner" spt1) a (if (< (car spt1)(car spt3))(car spt1)(car spt3)) ;;Lower Left X coord b (if (> (car spt1)(car spt3))(car spt1)(car spt3)) ;;Upper Right X coord c (if (< (cadr spt1)(cadr spt3))(cadr spt1)(cadr spt3)) ;;Lower Left y Coord d (if (> (cadr spt1)(cadr spt3))(cadr spt1)(cadr spt3)) ;;Upper Right Y Coord ) (setq mywidth (abs (- a b))) (setq myheight (abs (- c d))) ;;center points (setq scpt1 (list (/ (+ a b) 2) (/ (+ c d) 2)) ) (command "text" scpt1 2.5 0 "Text Here" "") ) You'll need to work out the text input yourself and the final text but this will give you the basics - if you struggle with the other parts just shout and we can fill in the rest of the details 1 Quote
rose sr Posted May 20, 2022 Author Posted May 20, 2022 Thanks for the reply Stevan P. not able to get the rest of it. tried. please help Quote
Tharwat Posted May 20, 2022 Posted May 20, 2022 Create your Mtext with contents with respect to alignments Middle Center if required then move it via specifying the two points diagonally. Quote
Steven P Posted May 20, 2022 Posted May 20, 2022 OK So it you might have made something like this if you got it to work: (defun c:testthis ( / spt1 spt2 roomname a b c d scpt1 mywidth myheight) ;; after the '/' are local variable names (setq ;;setq: Tells LISP you are setting a variable spt1 (getpoint "\nPick the first point") ;;should be obvious what this does spt3 (getcorner "\nPick the next corner" spt1) ;;should be obvious what this does roomname (getstring "\nEnter Room Name: " T) ;;T allows spaces, else space acts as a return a (if (< (car spt1)(car spt3))(car spt1)(car spt3)) ;;Lower Left X coord car gives first item in a list, here x coord b (if (> (car spt1)(car spt3))(car spt1)(car spt3)) ;;Upper Right X coord c (if (< (cadr spt1)(cadr spt3))(cadr spt1)(cadr spt3)) ;;Lower Left y Coord cadr gives second item in a list, here y coord d (if (> (cadr spt1)(cadr spt3))(cadr spt1)(cadr spt3)) ;;Upper Right Y Coord ) (setq mywidth (abs (- a b))) ;;abs for absolute value (witohut = or -), (- is subtract (setq myheight (abs (- c d))) ;;center points (setq scpt1 (list (/ (+ a b) 2) (/ (+ c d) 2)) ) ;;create a coordinate which is a list (/ for divide (+ for add (command "mtext" scpt1 "J" "MC" scpt1 (strcat roomname "\n" (rtos mywidth 2 2) " x " (rtos myheight 2 2 )) "") ;;Command echos what you'd type in command line, anything in "" is a fixed value in else it is calculated ) Put a few notes in if you want to learn how it does what it does 4 Quote
rose sr Posted May 20, 2022 Author Posted May 20, 2022 Wow this works. thank u very much. saves lot of time. 1 Quote
ronjonp Posted May 20, 2022 Posted May 20, 2022 @Steven P You can also subtract the X's and the Y's to get W and H. (and (setq p1 (getpoint)) (setq p2 (getcorner p1)) (setq r (mapcar 'abs (mapcar '- p1 p2))) (mapcar 'print r) ) 1 Quote
mhupp Posted May 20, 2022 Posted May 20, 2022 And easy midpoint of two points add them up and divide x y and z by 2 (setq mpt (mapcar '/ (mapcar '+ pt1 pt2) '(2 2 2))) 2 Quote
BIGAL Posted May 23, 2022 Posted May 23, 2022 And easy midpoint of two points add them up and divide x y and z by 2 inverse answer (setq mpt (mapcar '* (mapcar '+ pt1 pt2) '(0.5 0.5 0.5))) 2 Quote
ronjonp Posted May 23, 2022 Posted May 23, 2022 @BIGAL Look at @mhupp post directly above yours. 1 Quote
faizur Posted August 8, 2023 Posted August 8, 2023 On 5/20/2022 at 6:48 PM, Steven P said: OK So it you might have made something like this if you got it to work: (defun c:testthis ( / spt1 spt2 roomname a b c d scpt1 mywidth myheight) ;; after the '/' are local variable names (setq ;;setq: Tells LISP you are setting a variable spt1 (getpoint "\nPick the first point") ;;should be obvious what this does spt3 (getcorner "\nPick the next corner" spt1) ;;should be obvious what this does roomname (getstring "\nEnter Room Name: " T) ;;T allows spaces, else space acts as a return a (if (< (car spt1)(car spt3))(car spt1)(car spt3)) ;;Lower Left X coord car gives first item in a list, here x coord b (if (> (car spt1)(car spt3))(car spt1)(car spt3)) ;;Upper Right X coord c (if (< (cadr spt1)(cadr spt3))(cadr spt1)(cadr spt3)) ;;Lower Left y Coord cadr gives second item in a list, here y coord d (if (> (cadr spt1)(cadr spt3))(cadr spt1)(cadr spt3)) ;;Upper Right Y Coord ) (setq mywidth (abs (- a b))) ;;abs for absolute value (witohut = or -), (- is subtract (setq myheight (abs (- c d))) ;;center points (setq scpt1 (list (/ (+ a b) 2) (/ (+ c d) 2)) ) ;;create a coordinate which is a list (/ for divide (+ for add (command "mtext" scpt1 "J" "MC" scpt1 (strcat roomname "\n" (rtos mywidth 2 2) " x " (rtos myheight 2 2 )) "") ;;Command echos what you'd type in command line, anything in "" is a fixed value in else it is calculated ) Put a few notes in if you want to learn how it does what it does THIS WORKS PERFECTLY IN METRIC DRAWING, HOW CAN I USE THE IN IMPERIAL DRAWING? LIKE - BEDROOM 12'-0"x14'-0" Quote
Steven P Posted August 8, 2023 Posted August 8, 2023 4 hours ago, faizur said: THIS WORKS PERFECTLY IN METRIC DRAWING, HOW CAN I USE THE IN IMPERIAL DRAWING? LIKE - BEDROOM 12'-0"x14'-0" Barely an inconvenience..... if you look through the code near the end you should find a line or 2 to create some mtext (command "mtext"...... change (command "mtext" scpt1 "J" "MC" scpt1 (strcat roomname "\n" (rtos mywidth 2 2) " x " (rtos myheight 2 2 )) "") to (command "mtext" scpt1 "J" "MC" scpt1 (strcat roomname "\n" (rtos mywidth 3 2) " x " (rtos myheight 3 2 )) "") the difference is the RTOS mode for mywidth and myheight. That should do it. 1 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.