Author Topic: macro code or lisp to change specific text height to desired text height  (Read 336 times)

0 Members and 1 Guest are viewing this topic.

Jomzkie2

  • Mosquito
  • Posts: 3
Hi. We have a DWG drawings came or exported from a different software. The issue of these files (all dwg or cad file) is that text heights are not an exact number. Sample text heights are 2.8633 and 4.846. We want these to round to exact 3 and 5 respectively and we have bunch of drawings for this case. So if anyone having idea for a LISP and or a macro, pls share. Thank you keep safe and god bless.

Lee Mac

  • Seagull
  • Posts: 12488
  • London, England
To offer an existing solution, you can use this, and change the list to:
Code - Auto/Visual Lisp: [Select]
  1. (setq l
  2.    '(
  3.         ("TEXT"  40)
  4.         ("MTEXT" 40)
  5.     )
  6. )

And ssget expression to:
Code - Auto/Visual Lisp: [Select]
  1. (if (setq s (ssget "_:L" '((0 . "TEXT,MTEXT"))))

Jomzkie2

  • Mosquito
  • Posts: 3
To offer an existing solution, you can use this, and change the list to:
Code - Auto/Visual Lisp: [Select]
  1. (setq l
  2.    '(
  3.         ("TEXT"  40)
  4.         ("MTEXT" 40)
  5.     )
  6. )

And ssget expression to:
Code - Auto/Visual Lisp: [Select]
  1. (if (setq s (ssget "_:L" '((0 . "TEXT,MTEXT"))))

Hi Mr Lee, thanks for the CODE above. But it seems it needs user to choose only one value for the entire drawing. Is there any way to change code whereby the user will select all (contol+all) then the LISP will choose say text with height of 2.863 and 4.863 then it will round off to 3 and 5 respectively?
« Last Edit: May 02, 2021, 09:27:25 AM by Jomzkie2 »

Lee Mac

  • Seagull
  • Posts: 12488
  • London, England
Hi Mr Lee, thanks for the CODE above. But it seems it needs user to choose only one value for the entire drawing. Is there any way to change code whereby the user will select all (contol+all) then the LISP will choose say text with height of 2.863 and 4.863 then it will round off to 3 and 5 respectively?

I think you may have misunderstood the code: the rounding tolerance is the multiple to which the numerical values should be rounded - in your case, to round to the nearest integer, you would specify a rounding tolerance of 1.

Jomzkie2

  • Mosquito
  • Posts: 3
I think you may have misunderstood the code: the rounding tolerance is the multiple to which the numerical values should be rounded - in your case, to round to the nearest integer, you would specify a rounding tolerance of 1.
[/quote]

Hi Mr Lee, your guess is right. I define a value 5 at first instead of .5 during testing. But yeah setting 1 to round off to nearest integer is working fine too. Thanks for your help and bright code.