Auto Room Dimensions

Auto Room Dimensions

zaid.k3112
Contributor Contributor
10,319 Views
39 Replies
Message 1 of 40

Auto Room Dimensions

zaid.k3112
Contributor
Contributor

Hello, I would like a small lisp in which when I select 2 corners of the room, itll place a text in middle with the room name & room dimensions with the current layer and text style. Itll go like this 

Line 1: Bedroom

Line 2: 3.05 x 3.30 M

Line 3: 10' x 10'9"

It should be length x breadth always.  All as middle center justification. I have found a few lisp but it just has feet inches and not both dimensions. Itll save a lot of my time if someone could do it. Thanks & Regards

Capture.JPG

0 Likes
Accepted solutions (1)
10,320 Views
39 Replies
  • Lisp
Replies (39)
Message 2 of 40

pbejse
Mentor
Mentor

@zaid.k3112 wrote:

Hello, I would like a small lisp in which when I select 2 corners of the room, itll place a text in middle with the room name ...

 


What is the source of the Room name?  User prompt?

Are you wanting 3 separate TEXT entity or 1 MTEXT?

 


@zaid.k3112 wrote:

I have found a few lisp but it just has feet inches and not both dimensions. 


Where is this lisp then?

 


@zaid.k3112 wrote:

Itll save a lot of my time if someone could do it. Thanks & Regards


It would save us  a lot of time  if you be more concise 

0 Likes
Message 3 of 40

zaid.k3112
Contributor
Contributor

I want 1 single Mtext. 1 text with 3 lines. I have attached the lisp below. it shows only in meters. I need both meters and feet inches 

0 Likes
Message 4 of 40

zaid.k3112
Contributor
Contributor

The source could be pre listed as in the attached lisp in previous reply. Or I could manually type when I enter the lisp command. As the texts are almost always the same typical as living kitchen bedroom toilet etc.. the first option would be better instead of typing everytime.

0 Likes
Message 5 of 40

pbejse
Mentor
Mentor

@zaid.k3112 wrote:

The source could be pre listed as in the attached lisp in previous reply. Or I could manually type when I enter the lisp command. As the texts are almost always the same typical as living kitchen bedroom toilet etc.. the first option would be better instead of typing everytime.


Attached is the modifed lisp to include the third line

Here are the additional snippets

.....
  (setq	pt (polar p1 (angle p1 p2) (/ (distance p1 p2) 2)) ; mid point
	pt (polar pt (/ pi 2.0) (* h 1.5))
	pm (polar pt (* pi 1.5) (* h 1.5))
	pf (polar pm (* pi 1.5) (* h 1.50))
  )
  (MakeText pm pm txlay "rs" ht1 mt)
  (MakeText pf pf txlay "rs" ht1 ft)

IT should be 3 lines now, third line as imperial

 

HTH

 

0 Likes
Message 6 of 40

zaid.k3112
Contributor
Contributor

Hello, this is just perfect. But the text does not gets placed in the middle of the room. Do you know how to fix that? I have attached a screenshot below to show. Another thing would be great if the first line be Bold. i.e. the 'Toilet' should be in bold font.

 
 
 

 

0 Likes
Message 7 of 40

pbejse
Mentor
Mentor

@zaid.k3112 wrote:

Hello, this is just perfect. But the text does not gets placed in the middle of the room. Do you know how to fix that? I have attached a screenshot below to show. Another thing would be great if the first line be Bold. i.e. the 'Toilet' should be in bold font.


Where is the screenshot?

 

Not sure why it behaves that way, ok here on my end.

Here's a short code that creates three lines of text , the height is will refer to TEXTSIZE variable, it iwll be on the current layer.

 

(defun c:RoomLabel ( /  _Imperial Roomname fc nc h v str p)
(defun _Imperial (v)
  (rtos (cvunit v "meter" "inch") 4 0))
	(while
	 (and
	   (setq Roomname (getstring t "\nEnter room name: "))
	   (setq fc (getpoint "\nPick first corner"))
	   (null (initget 32))
	   (setq nc (getcorner fc "\nPick Next corner"))
	   )
	(setq h (abs (- (car fc)(car nc)))
	      v (abs (- (cadr fc)(cadr nc))))
	(setq str (strcat  (strcase Roomname) "\\P"
			   (rtos h 2 2) " x " (rtos v 2 2) "\\P"
			   (_Imperial h) " x " (_Imperial v)))
	(setq p (mapcar (function (lambda (a b) (/ (+ a b) 2.))) fc nc))
	(entmakex (list (cons 0 "MTEXT")
			  (cons 100 "AcDbEntity")
			  (cons 100 "AcDbMText")
			  (cons 10 (trans p 1 0))
			  (cons 1 str)
			  (cons 41 (- (car p)(car p)))	
			  (cons 71 5)
			  (cons 72 5)
			  (cons 73 1)
			  (cons 7 (getvar 'TextStyle))
				    )
			  )
	    )
  (princ)
  )

 

If you are savvy enough in lisp, you can add the options for Room names. and also add the "BOLD" thingy. That  requires retrieving the current text style's font and some additional formatting. 

 

HTH

 

Message 8 of 40

zaid.k3112
Contributor
Contributor

Ok I created a new lisp command as per your new script. I am not well versed with all this. I dont know how to make it bold and room names. I will try to integrate both the lisps and try it. Rest all is just perfect. 

0 Likes
Message 9 of 40

pbejse
Mentor
Mentor

@zaid.k3112 wrote:

Ok I created a new lisp command as per your new script. I am not well versed with all this. I dont know how to make it bold and room names. I will try to integrate both the lisps and try it. Rest all is just perfect. 


 

Formating Mtext is a bit complicated., we can add the boldness easy if you are using a rgular font type. Can you post a drawng sample of the label you are using. Do that, and we might even add the room names on the code.

 

0 Likes
Message 10 of 40

zaid.k3112
Contributor
Contributor

1. I am not using regular font type. The font I am using is Bahnscrift (I have attached the font below)

2. I have attached the drawing with all the text types/room names I need for the same. I'll write the same here for the short form it needs when using the lisp command. 

L=Living Room, K=Kitchen, D=Dining, B=Bedroom, MB=Master Bed., WC=W.C., B=Bath, T1=Toilet 1, T2, Toilet 2, LL=Lobby, P=Passage, Li=Lift, S=Shop, Ba=Balcony, Te=Terrace, DB=Dry Balc., T=Type the text by myself. 

0 Likes
Message 11 of 40

Kent1Cooper
Consultant
Consultant

@zaid.k3112 wrote:

... B=Bedroom, ... B=Bath .... 


Two rooms with the same abbreviation

Kent Cooper, AIA
0 Likes
Message 12 of 40

zaid.k3112
Contributor
Contributor

oh sorry. Bt=Bath, B=Bedroom

0 Likes
Message 13 of 40

pbejse
Mentor
Mentor
Accepted solution

@zaid.k3112 wrote:

1. I am not using regular font type. The font I am using is Bahnscrift (I have attached the font below)

2. I have attached the drawing with all the text types/room names I need for the same. I'll write the same here for the short form it needs when using the lisp command. 


Try this, I used numbers instead of keywords, that way you can add as many as you need in the future and not worry about the keyword

 

(defun c:RoomLabel ( /  _Imperial _StrcatW lst Roomname
		    			txFont fc opt nc h v str p)
;;		pBe Jan 2021		;;;
(defun _Imperial (v) (rtos (cvunit v "meter" "inch") 4 0))
(defun _StrcatW	(l f)
  (substr
    (apply 'strcat (mapcar '(lambda (s) (strcat f s)) l)) 2
  )
)
(setvar 'dynmode 3)  
(setq lst '(("1" " Living Room")("2" " Kitchen")("3" " Dining")("4" " Bedroom")
	    ("5" " Master Bed")("6" " W.C.")("7" " Bath")("8" " Toilet 01")
	    ("9" " Toilet 02")("10" " Lobby")("11" " Passage")("12" " Lift")
	    ("13"  " Shop")("T" " Type")))

;; if Bahnschrift in not the current textstyle or does not exist on the drawing	;;
;; the default textstyle would be standard, text height = current TEXTSIZE	;;
  
(setq txFont      
	  (if (member (Cdr (assoc 2 (tbLsearch "style" (getvar 'textstyle))))
		      '("BH-Light" "BH-Medium")) 
	    	(list "{\\fBahnschrift|b1|i0|c0|p34;"
		      "\\P\\fBahnschrift Light Condensed|b0|i0|c0|p34;" "}")
		(list "{\\fArial|b1|i0|c0|p34;" "}\\P" ""))
       )

(initget 1 (_strcatw (mapcar 'car lst) " "))
(setq opt (getkword (strcat  "\nChoose Room name ["
			     (_strcatw (mapcar 'strcat (mapcar 'car lst)
					       (mapcar 'cadr lst)) "/" ) "]: ")))
 
(setq Roomname
       (cond
	 ((= opt "T")(getstring t "\nTYPE ROOM NAME: "))
	 ((substr (cadr (assoc opt lst)) 2))
	 ;; more options here in the future ;;;
	 )
      )
  
(if
	(and
	   (setq fc (getpoint "\nPick first corner"))
	   (null (initget 32))
	   (setq nc (getcorner fc "\nPick Next corner"))
	   )
  (progn
	(setq h (abs (- (car fc)(car nc)))
	      v (abs (- (cadr fc)(cadr nc))))
	      
	(setq str (strcat (car txFont) Roomname (cadr txFont)
			   (rtos h 2 2) " x " (rtos v 2 2) "\\P"
			   (_Imperial h) " x " (_Imperial v) (caddr txFont)))
    
	(setq p (mapcar (function (lambda (a b) (/ (+ a b) 2.))) fc nc))
	(entmakex (list (cons 0 "MTEXT")
			  (cons 100 "AcDbEntity")
			  (cons 100 "AcDbMText")
			  (cons 10 (trans p 1 0))
			  (cons 1 str)
			  (cons 41 (- (car p)(car p)))	
			  (cons 71 5)
			  (cons 72 5)
			  (cons 73 1)))
	    )
  	)
  (princ)
  )
Command:ROOMLABEL
Choose Room name [1 Living Room/2 Kitchen/3 Dining/4 Bedroom/5 Master Bed/6 W.C./7 Bath/8 Toilet 01/9 Toilet 02/10 LObby/11 Passage/12 Lift/13 Shop/T Type]: 2
Pick first corner
Pick Next corner

 

Dynamic input:

 rooms.png

HTH

Message 14 of 40

zaid.k3112
Contributor
Contributor

This is exactly what I wanted. Thanks a lot brother. You solved a major problem and much of manual work for me. Thanks a lot. I hope you succeed in life. Wish you all the very best. Kudos to you. Thanks & Regards. 

0 Likes
Message 15 of 40

pbejse
Mentor
Mentor

@zaid.k3112 wrote:

This is exactly what I wanted. Thanks a lot brother. You solved a major problem and much of manual work for me. Thanks a lot. I hope you succeed in life. Wish you all the very best. Kudos to you. Thanks & Regards. 


Good for you, glad i could help.

 

You are welcome.

 

Message 16 of 40

Sea-Haven
Mentor
Mentor

A alternative to dynmode had some issues if forget to turn back off.

 

 

 

(setq lst '("Please choose " " Living Room" " Kitchen" " Dining" " Bedroom"
	    " Master Bed" "W.C." " Bath" " Toilet 01"
	    " Toilet 02" " Lobby" " Passage"  " Lift"
	    " Shop"  " Type"))
(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (not but)(setq but 1))
(setq ans (ah:butts but "v"  lst)) ; ans holds the button picked value

 

 

 Multi radio buttons.lsp can be used in any code.

 

screenshot324.png

 

Almost forgot can set default button to repeat last button picked so just click OK.

Message 17 of 40

zaid.k3112
Contributor
Contributor

What am i supposed to do with this code? I am not familiar with lisp

0 Likes
Message 18 of 40

Sea-Haven
Mentor
Mentor

Its an alternative to using dynmode method of selecting an option, very similar in that you have  a list of options. 

 

Use what has been provided when you get a bit more experience come back happy to answer any questions, as its a library routine for any code.

Multi radio.jpg

0 Likes
Message 19 of 40

maratovich
Advisor
Advisor

Use this: RoomDim 

 

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 20 of 40

Anonymous
Not applicable

Can you please update lisp for 10' to 10'-0"

Thanks in advance

0 Likes