Jump to content

Automatic room dimensions


Zaidkhot

Recommended Posts

Hello, I just need a small lisp script in which I can automatically name the selected room dimensions in meters and feet. The assumed steps are written below.

 

1. Select one corner of room

2. Select second corner of room

3. In this step the text will automatically be placed at center of room with the same font and size I have selected by default. 

 

The order of things shall be as follows in 3 lines. 

LIVING ROOM

3.05 X 3.30 M

10' x 10'9"

 

Link to comment
Share on other sites

  • 4 weeks later...

Hello I did the routine but the autocad has an error when using FIX to remove the decimal part of the number.
Drawing a 3.0480 x 3.0480 rectangle the same routine returns different values. Even if you use 3.05 when converting meters to feet and drawing a 3.050 x 3.050 rectangle, we have an error in the FIX.
I found differences 2.7e-12 between the same numbers.
Sometimes (fix 10.0) = 10 and (fix 10.0) = 9. I don't know why.

Invert the sequence of the points.
Bottom left to top right.
Bottom right to bottom left.
I gave up.
I do not speak English.
Sorry my english from google translator.

 

Original in Portuguese.

Olá eu fiz a rotina mas o autocad tem erro quando usa o FIX para retirar a parte decimal do número.
Desenhando um retangulo 3.0480 x 3.0480 a mesma rotina retorna valores diferentes. Mesmo que use 3.05 na converção de metros para pes e desenhando um retangulo de 3.050 x 3.050 temos erro no FIX.
Localizei diferenças 2.7e-12 entre mesmos numberes.
As vezes (fix 10.0) = 10 e (fix 10.0) = 9. Não sei porque.

Inverta a sequencia dos pontos. 
Inferior esquerdo para o superior direito.
Inferior direito para o inferior esquerdo. 
Desisti. 
Eu não falo ingles.
Desculpe o meu ingles do google tradutor. 

room size.LSP

  • Like 1
Link to comment
Share on other sites

i noticed the LSP is designed to insert the size in meters but then convert meters to feet, correct?

My gut tells me this is the cause of the anomaly.

 

It looks like the correct conversion factor would be:

 

1 meter = 3.28083989501312 foot

 

So your meter to feet number in "precision" in your LSP shows .32808333 but it looks like this should be .328083989501312

 

Other than this,

 

It is possible to have an error factor in Autocad depending on what drawing units you are using in your DWG.  But I'm sure there are others more versed in this than I that can explain it better.  I am not an expert as I've used imperial for the last 17 years lol.


SO if you are using imperial inches UNITS in your dwg file, the LISP will add the dimension in meters - right away that number will be wrong. 

Then that number gets reconverted back to feet by the LSP but that original metric multiplier would still be incorrect (in this example, at least).

 

So the feet text would also be slightly off in theory.

 

Maybe there is an error with inches in a metric DWG but from what I recall the error is more associated with metric objects in an Imperial DWG because of how autocad does the conversion.

Edited by ammobake
  • Thanks 1
Link to comment
Share on other sites

I don't work in feet god bless metric makes life so much easier. Anyway my take on metres to feet. Tried to get distof to work.

 

; tol 1/16"
(setq a 3.25 str "")
(setq ar (/ a 0.3048))
(setq ai (fix (/ a 0.3048)))
(setq  b   (- ar ai))
(setq str (strcat (rtos ai 2 0) "'"))
(IF (>  b (/ 0.0625 12.0))
(progn
(setq c  (* 12.0 b))
(setq inch (fix c))
(setq str  (strcat str (rtos inch 2 0) "\""))
(setq frac  (* (- c inch) 16.0))
(if (/= (fix frac) 0.0)
(setq str  (strcat str (rtos frac 2 0) "/16" ))
)
)
)
(princ str)

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thank you so much ammobake for the explanation. Really numbers such pi (3.1415) "e" (2.7182818) end inch feet have many decimal places can generate errors in the conversion.

 

 

Link to comment
Share on other sites

Thank you very much Bigal for the explanation. I had forgotten about / 16 "
And I found it strange that the autocad had given these small errors and now they didn't happen anymore. I did rectangle, polygon and line offset with 3.05. I copied and rotated 90º, but the numbers change with the same routine!
What happened?
I am sending the dwg file to the conference because something is wrong. it is clear that the number 3.04 is wrong for conversion feet x meters but the mathematical operation is the same. It gives different results only by rotating the drawing. I'll use the routine you did.
Thank you very much Bigal.
Did I say something wrong, don't take it into account.

test.dwg

Link to comment
Share on other sites

Lee Mac has a number of very useful Area related lisps available on his site.

I have never needed them, but they are highly configurable, and as with

all of Lee's lisps, brilliant.   :)

 

Lee very generously makes these freely available to the global cad community as share-ware,

with a Donation option, always a good idea, for such productive tools!   Thanks Lee!     :beer:

  • Thanks 1
Link to comment
Share on other sites

Hi Dadgad, thanks for the comments. I know Lee Mac's work and I especially like fractals that are very beautiful and complex but with compact routines. I also like the field finder in the "filds obects" routine that I used to do material resistance exercises at the university of civil engineering. I went back to college with 49 years old. Thanks Lee Mac for the routines and thanks Dadgad for the comments.

  • Like 1
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...