structo Posted November 30, 2016 Share Posted November 30, 2016 (edited) Hi friends, i have dimension text as 59" and so on. i want to convert as 4'-11"rule is above 18" dimension text should be convert as feet. any possibilities by quick lisp? Rule is: find text with inches(") symbol text and divided by "12". then replace with "Feet-Inch" text. like a 4'-11" instead of 59".( if more than 18" text value) Thank you. inches to feets.dwg Edited November 30, 2016 by structo Quote Link to comment Share on other sites More sharing options...
Dadgad Posted November 30, 2016 Share Posted November 30, 2016 You could certainly do it with an ALTERNATE Dimension style, or by creating a brand new Dimension style. Quote Link to comment Share on other sites More sharing options...
structo Posted November 30, 2016 Author Share Posted November 30, 2016 Hi friend, thank you for responding. yes i tried your idea already. but not success full. please observe sample drawing. there is one dimension style. in this style contains different text was included. please have a look. in this dimension style not a original dimension. there is edited text. so difficult to change each text. Thank you. Quote Link to comment Share on other sites More sharing options...
Dadgad Posted November 30, 2016 Share Posted November 30, 2016 (edited) You just need to set up the dimstyle to do what you want it to do. I have created a new dimstyle which I based upon the existing Dimsyle 1, and I adjusted the dimscale linear in the dimstyle definition, so that you would not need to OVERRIDE all your dimensions. I removed all of the OVERRIDES in the linework on the right, and selected all of the dimensions and changed their dimstyle in the QUICK PROPERTIES to Dimstyle 1 Fixed. I am not sure why you didn't draw this at 1:1 in Modelspace, as is the accepted industry norm. Typically working with Autocad one draws anything and everything, in Modelspace, at life size (1:1), unlike conventional drafting on a sheet of paper, where that very quickly becomes out of the question. If you SCALED this drawing by a factor of .02, everything would be the right size, in which case you would then be able to remove the .02 scale factor which I applied to the dimstyle as highlighted in yellow on the screenshot of the Quick Properties Tab. I just scaled the object in your drawing by a factor of .02, and adjusted the dimension style to reflect that change, as highlighted in yellow, the dim scale linear is no longer 0.02, but is now 1, as shown in the last screenshot. I hope this helps you. inches to feet.dwg Edited November 30, 2016 by Dadgad Quote Link to comment Share on other sites More sharing options...
structo Posted November 30, 2016 Author Share Posted November 30, 2016 hi, thank you for reply. those drawing was developed by one program. that's why i want to change by automate procedure for lot of drawings. thank you. Quote Link to comment Share on other sites More sharing options...
Dadgad Posted November 30, 2016 Share Posted November 30, 2016 Because the Dimension Text has been OVERRIDDEN, that could be quite difficult, not to mention the fact that the scales are not as would be expected. I am pretty good with Dimensions, but know nothing about lisp, good luck with finding an automated way to sort them out. Would all of the drawings be scaled like this one was, at fifty times larger than lifesize (50:1)? The answer to that, could be an important one. Quote Link to comment Share on other sites More sharing options...
structo Posted November 30, 2016 Author Share Posted November 30, 2016 Yes friend, i need to find text with inches(") symbol text and divided by "12". then replace with "Feet-Inch" text. like a 4'-11" instead of 59".( if more than 18" text value) Thank you. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted November 30, 2016 Share Posted November 30, 2016 I agree with Dadgad's comments. But, having said that, this should work: (defun c:Test ( / doc ovr ss) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (if (setq ss (ssget "_X" '((0 . "DIMENSION") (-4 . "<NOT") (1 . "") (-4 . "NOT>")))) (vlax-for obj (setq ss (vla-get-activeselectionset doc)) (setq ovr (vla-get-textoverride obj)) (if (and (wcmatch ovr "*\"") (not (wcmatch ovr "*[~\"0-9]*,*\"*?")) (< 18 (atoi ovr)) ) (vla-put-textoverride obj (strcat (itoa (/ (atoi ovr) 12)) "'-" (itoa (rem (atoi ovr) 12)) "\"" ) ) ) ) (vla-delete ss) ) (vla-endundomark doc) (princ) ) Quote Link to comment Share on other sites More sharing options...
structo Posted November 30, 2016 Author Share Posted November 30, 2016 Wow Roy, its Amazing. thank you for your great contribution. Quote Link to comment Share on other sites More sharing options...
Dadgad Posted December 1, 2016 Share Posted December 1, 2016 Nicely done Roy! Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 1, 2016 Share Posted December 1, 2016 Thanks. Here is a slightly modified version. Same functionality but wcmatch is used only once. (defun c:Test ( / doc ovr ss) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (if (setq ss (ssget "_X" '((0 . "DIMENSION") (-4 . "<NOT") (1 . "") (-4 . "NOT>")))) (vlax-for obj (setq ss (vla-get-activeselectionset doc)) (setq ovr (vla-get-textoverride obj)) (if (and (not (wcmatch ovr "*[~\"0-9]*,*[~\"],*\"*?")) (< 18 (atoi ovr)) ) (vla-put-textoverride obj (strcat (itoa (/ (atoi ovr) 12)) "'-" (itoa (rem (atoi ovr) 12)) "\"" ) ) ) ) (vla-delete ss) ) (vla-endundomark doc) (princ) ) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 1, 2016 Share Posted December 1, 2016 The following is untested, but perhaps offers an alternative: (defun c:test ( / g i s v x ) (if (setq s (ssget "_X" '((0 . "DIMENSION") (1 . "*#\"") (1 . "~*\"*?") (1 . "~*[~\"0-9]*")))) (repeat (setq i (sslength s)) (if (< 18 (setq x (entget (ssname s (setq i (1- i)))) g (assoc 1 x) v (atoi (cdr g)) ) ) (entmod (subst (cons 1 (strcat (itoa (/ v 12)) "'-" (itoa (rem v 12)) "\"")) g x)) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
structo Posted December 2, 2016 Author Share Posted December 2, 2016 Hi thank you Royal Roy, please test with following file. some dimension text was not changed. please have a look. inches to feets.dwg Quote Link to comment Share on other sites More sharing options...
structo Posted December 2, 2016 Author Share Posted December 2, 2016 The following is untested, but perhaps offers an alternative: Hi super Macc, thank you friend. some text was not changed. please test with attached file. thank you. inches to feets.dwg Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 2, 2016 Share Posted December 2, 2016 @structo: I am pleased to see that my code functions exactly as intended: 1. As per your request it only changes dimension texts. Normal text entities are not affected. 2. Only dimension texts that consist of one or more digits and end in a double quote are changed. So in your drawing dimensions with these overrides are not changed: "33-2B-A8 \\X~@ 7\" A/C" "74\"\\X = =" Also this normal text is not changed: "66\" both sides" I hope you understand the logic here. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 2, 2016 Share Posted December 2, 2016 @structo: For your new drawing this should work: (defun ConvStr (str i / j num sub) (if (setq i (vl-string-position 34 str i)) (progn (setq j i) (while (and (/= j 0) (wcmatch (substr str j 1) "#")) (setq j (1- j)) ) (if (< 18 (setq num (atoi (substr str (1+ j) (- i j))))) (ConvStr (strcat (setq sub (strcat (substr str 1 j) (itoa (/ num 12)) "'-" (itoa (rem num 12)))) (substr str (1+ i)) ) (1+ (strlen sub)) ) (ConvStr str (1+ i)) ) ) str ) ) (defun c:ConvAll ( / doc ss) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (if (setq ss (ssget "_X" '((0 . "DIMENSION,*TEXT") (1 . "*#*\"*")))) (progn (vlax-for obj (setq ss (vla-get-activeselectionset doc)) (if (vl-position (vla-get-objectname obj) '("AcDbText" "AcDbMText")) (vla-put-textstring obj (ConvStr (vla-get-textstring obj) 0)) (vla-put-textoverride obj (ConvStr (vla-get-textoverride obj) 0)) ) ) (vla-delete ss) ) ) (vla-endundomark doc) (princ) ) Quote Link to comment Share on other sites More sharing options...
structo Posted December 3, 2016 Author Share Posted December 3, 2016 @structo:For your new drawing this should work: Thank you Roy. its working. Quote Link to comment Share on other sites More sharing options...
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.