TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Jomzkie2 on May 01, 2021, 12:05:35 PM

Title: macro code or lisp to change specific text height to desired text height
Post by: Jomzkie2 on May 01, 2021, 12:05:35 PM
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.
Title: Re: macro code or lisp to change specific text height to desired text height
Post by: Lee Mac on May 01, 2021, 05:18:49 PM
To offer an existing solution, you can use this (https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-of-line-and-pline-vertices/m-p/4396563#M314796), 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"))))
Title: Re: macro code or lisp to change specific text height to desired text height
Post by: Jomzkie2 on May 02, 2021, 08:30:04 AM
To offer an existing solution, you can use this (https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rounding-of-line-and-pline-vertices/m-p/4396563#M314796), 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?
Title: Re: macro code or lisp to change specific text height to desired text height
Post by: Lee Mac on May 03, 2021, 06:37:09 PM
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.
Title: Re: macro code or lisp to change specific text height to desired text height
Post by: Jomzkie2 on May 03, 2021, 09:34:29 PM
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.