Caracolalbino Posted April 3, 2023 Posted April 3, 2023 Hello everyone, I have one issue with dimension properties where I want to know if something can be done. We work with meters as units, and we make a lot of details so we've found a format that suits our needs but it means a lot of manual overrides. Basically, the dimensions are to be displayed with meters as the units, and we have the two first decimals for the cm as is, but we write the next or next two decimals for the mm range as superscript, stacking the last two digits. Is there any way to have the precision set to .0000 and stack the last two digits as default as opossite to manually override each dimension? Thanks in advance! 1 Quote
BIGAL Posted April 4, 2023 Posted April 4, 2023 You can override a dim value <> is default distance. So if we look at this I typed the text twice to see the change. "\\A1;123.4567 123.45{\\H0.7x;\\S67^;}" so this is mtext you would need to get the dimension value at 4 decimals then build a new string, and put the new string into the dim. (setq ent (entget (entlast))) (entmod (subst (cons 1 "123.45{\\H0.7x;\\S67^;}") (assoc 1 ent) ent)) It is best to post a sample dwg with your dim style to use,. The string will need to be made up of 3 parts 123.45 \\H0.7x;\\S 67. Probably need to use Vla-get-measurement as a entget shows the dim value as "" 1 Quote
Caracolalbino Posted April 5, 2023 Author Posted April 5, 2023 Hi, thanks a lot, BIGAL! So if I understand correctly, the first part is the default integer string, the second is an override for the height of the text string(?) and the last is the text to be in superscript. But I'm still kinda clueless with that last part with the entget and the vla-get-measurement... Also, I'm working on an LT version, I don't know if that makes the issue any harder. I'm attaching the standard linear dimension we use with the manual override for reference, thanks a lot for the feedback! new block.dwg Quote
BIGAL Posted April 6, 2023 Posted April 6, 2023 Ok with LT all manual no automation ! Don't know about wether diesel can be used. Using a lisp can pull apart the dim text value based on 4 decimal places and superscript last 2 decimal places. LT 2024 now supports lisp. So does Bricscad, Intellicad, Zwcad, Gstar, Drafsight to mention a few. 1 Quote
Caracolalbino Posted April 19, 2023 Author Posted April 19, 2023 Wow, you're right, I've just installed LT2024 and indeed I can use LISP without any issues so far. And this worked like a charm to replace the text within the dimension with the integer string 1234567 in the format I was looking for. So now I need to pull the string from the dimension to apply the format and replace the text with the override, am I correct? On 4/4/2023 at 3:23 AM, BIGAL said: (setq ent (entget (entlast))) (entmod (subst (cons 1 "123.45{\\H0.7x;\\S67^;}") (assoc 1 ent) ent)) Quote
BIGAL Posted April 20, 2023 Posted April 20, 2023 (edited) This will force 4 decimals so will get like 10.0000 could look for exact fraction is zero, so do say 10.00. would be Version 2. (defun c:wow ( / txtent dtxt len newstr) (setvar 'dimrnd 0.0001) (setvar 'dimzin 0) (setq txtent (entget (car (nentsel "\nSelect the dim text ")))) (setq dtxt (cdr (assoc 1 txtent))) (setq len (strlen dtxt)) (setq newstr (strcat (substr dtxt 1 (- len 2)) "{\\H0.7x;\\S" (substr dtxt (- len 1) 2) "^;}")) (entmod (subst (cons 1 newstr) (assoc 1 txtent) txtent)) (command "regen") (princ) ) (c:wow) If want to work with 4 decimals for dims, check your dim style that dimrnd and dimzin are set correct. The remove from code. Edited April 20, 2023 by BIGAL Quote
Caracolalbino Posted April 26, 2023 Author Posted April 26, 2023 I finally got some time to fiddle around a little with this Lisp but i'm still in diapers as far as lisp code goes. I got this far: Quote (defun c:SDO( / txtent odmprc dimprc dtxt slen len newstr) (setq odmprc (getvar 'dimdec)) (setq dimprc (getint "\nEnter the dimension precision value: ")) (setq slen (getint "\nEnter the length of the string to stack: ")) (setvar 'dimdec dimprc) (setvar 'dimzin 0) (setq txtent (entget (car (nentsel "\nSelect the dim text ")))) (setq dtxt (cdr (assoc 1 txtent))) (setq len (strlen dtxt)) (setq newstr (strcat (substr dtxt 1 (- len slen)) "{\\H0.7x;\\S" (substr dtxt (- len 1) slen) "^;}")) (entmod (subst (cons 1 newstr) (assoc 1 txtent) txtent)) (command "regen") (setvar 'dimdec odmprc) (princ) ) (c:SDO) Where I intended to allow the user to set the precision of the dimension and the length of the stacked part... So far I succeded with the last part but the first part is beyond me. I also tried and failed to set 3 as a default precision and 1 as a default stack length. Also I wonder if you could retrieve the text string from the dimension by selecting any part of the dimension, and if it is possible to select more dimensions to apply the lisp in one fell swoop to a selection. Sorry if my addition is messy, I'm still getting a grasp on lisp Quote
BIGAL Posted April 27, 2023 Posted April 27, 2023 Found the problem trying to work it out if you set precison the dim text made reflects it using VL- PrimaryUnitsPrecision resets the display of the dim value, ok now tricky bit a dim uses the real value of the dim say 20.0 long can display as 20.0000 but its stored as 20.0. When I did the code it was based on the dim being made correct and not variable dec places. Trying to find the way around it. May need a pad zeros as simplest way just read measurement and adjust to suit as a string with correct decimals then superscript. A random dim will show a measurement like, Measurement (RO) = 33.3541601603158 so easy to have 4 decimals using a chop method or round last place. So having a think to get around it. 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.