bohoon Posted February 5, 2014 Posted February 5, 2014 This is my first post so first of all I would like to welcome everyone. I hope that I could learn a lot from you guys. I would like to write a simple (I hope so ) lisp which will help me a lot during my work at the office. Drawings that we receive are in 2d but are created from a 3d model made on bentley software. Because of that all the dimensions are overriden even if they are not changed. We are asked to overline every single dimension which was shortened. What I would like to achive is to - by single command - select all the dimension in the drawing, check if they are matching with actual measurement (this is the place where I get really confused) and if not than overline them (put %%o before the overriden text). Later on I would like to develop it a little, maybe by adding option to select all or only chosen dimensions, but it is not a "must have" My lisp level is really basic. By far I rather do more of a script than lisp, but I would like to learn much more, that is why I appreciate all the help with this and as many comments as possible to help me understand how it all works. Thank You for all responses Quote
Bill Tillman Posted February 5, 2014 Posted February 5, 2014 First off, welcome to the forum. You will find many answers and ideas in here. But your post is a little confusing...and if you would do something on future posts that would help you and us to help you a lot more. Don't write "What I'd like to do......" and then take 40 more words to get to the part of what you'd like to do. Just a suggestion. Anyway, if I understand what you're asking is that you want to select all the dimensions in a drawing and by "check to see which ones have been shortened..." do you mean narrow the selection down to the ones which have a text override in them? If so, we probably can direct you to some LISP code which does exactly that. I know I have seen posts from CAD instructors who routinely do this to check that their students are not taking short cuts in drawing to scale by using text overrides in their work. Quote
Jef! Posted February 6, 2014 Posted February 6, 2014 Welcome to cadtutor! If I understand well: -every single dim is overwritten with a value -you want to check if overwritten value correspond to the "real" dimension -if not underline the changed value overwritten dims. It could be achieved, but there are few things that are required to be known. -Are overwritten values made by hand or generated automatically? (Are they ALWAYS on the same format?) -What is the formatting used for the overwritten dimensions? -What is the format of the dimensions not overwritten? -Are the dimensions overwrite contain any non numerical chars? While it is easy to get real values and overwritten values of all dimensions within a drawing, it can be quite another story to make a lisp to compare a dimension value which is a real number to a hand written string override. ie.: comparing 12.128 with "1 0-1/8""... or "12.125".. or "12-1/8"" Another thing to be kept in mind, the real value of a dimension can be, like above, 12.128. If the style of the override is architectural, the compared value could be "12-1/8""... meaning that if the precision is of 1/16", a checkup has to be made so if the value from the override differ from less than the precision of the drawing, it has to be evaluated as equivalent. I made a lisp, and I'm up to the point where I have to compare overwritten value with real value, and cannot process further without having a sample. Can you provide requested information and a sample drawing? Quote
bohoon Posted February 6, 2014 Author Posted February 6, 2014 Thanks for both responses Bill, I understand what You mean and I will try to avoid that amount of text. I have seen these lisps You mentioned and tried to convert them to my needs but unfortunentally I am not good enough yet to do this by myself. In my case all dimensions are overriden but the problem is to ad prefix "%%o" only in those which overriden value doesn't match with actual measurement. Jef! I will try to answer your questions: -1 - They are generated automatically, not sure about the format though because the style could be changed before the 2d drawings are created -2 and 3 - What exactly do You mean by format? Imperial or metric? If so than for both we are using always metric dimensions with decimal places (ex. 12.125), so situations which you described with "12-1/8"" and evaluation of equivalents should never happen -4 - No, they are always just numbers These type of drawings are typical workshop drawings and no architectural dimensions will ever be used. If I didn't explain something you asked or I misunderstood your doubts please ask me again. Thank you again for your help. Quote
Jef! Posted February 6, 2014 Posted February 6, 2014 but the problem is to ad prefix "%%o" only in those which overriden value doesn't match with actual measurement.The challenge is to compare a string with a real number... but knowing that they are automatically generated and decimal, imo this remove many worst-case-scenarios. -2 and 3 - What exactly do You mean by format? Imperial or metric? If so than for both we are using always metric dimensions with decimal placesWell, knowing that dimensions are metric with decimal places is a beginning. By format, I meant all the stuff that figure in the "primary units" tab on the dimstyle manager (modify button) . (don't bother giving me the values of your AutoCAD though since dimensions are not made by autocad). For information, these would be -unit format (Architectural, decimal, engineering, fractional, scientific,..) -precision of units (value to witch dimensions are rounded..) This can apply to any unit format (common architectural basic imperial dimensioning have a precision of 1/16", common imperial decimal dimensioning have a precision of 0.000/0.0000. I didn't work much with metric, but I'd guess that a precision 0.0 could be used. I would still make sure that the difference between real values and overwritten values is more then the precision before tagging them as overrides as it is possible that while modeling someone mistyped 1.32 instead of 1.3) -decimal separator (It could be possible that while a dimension real value is 1.25mm the overwritten value could be 1,25mm. That would depend on the software putting overrides vs cad settings.) -fraction format (not applicable in your situation, but with architectural formatting 1/2" and ½" are 2 different things) I would still need a sample drawing containing both dimensions (some with an override with the actual value, and some with an override with a modified value.) That will answer all questions I have and might have, save lots of typing, back and forward, and give me something to test with. Quote
bohoon Posted February 6, 2014 Author Posted February 6, 2014 Hi I created a sample of typical beam drawing. I hope you won't have a problem with opening - it is in fact a 3d drawing. I can flatten it if necessary. What you will propably notice is that dimensions that were not shortened are not overwritten with numbers but only with sign. I am not really sure when it has changed but currnet version of bentley does it like that (or maybe this is case of internal settings). I am sorry for the confusion since I misled you. I should have checked it before posting :/ Does it mean that now it will be more or less complicated? Drawing1.dwg Quote
Jef! Posted February 6, 2014 Posted February 6, 2014 I created a sample of typical beam drawing. I hope you won't have a problem with opening - it is in fact a 3d drawing. I can flatten it if necessaryNo, not necessary.. I'd even say that it is best if the lisp makes the job directly on automatically generated files. If there is no man made manipulation before, the input is constant... ...not overwritten with numbers but only with sign...Does it mean that now it will be more or less complicated?Au contraire! It is easier to discard any overrides that contain "" than trying to manipulate the string to compare it to a real number. Ok, here it is. At the beginning, there is the variable exclusionlist. I made the lisp to disregard any item in it, so for now it wont modify any dimensions with no overrides ("") and wont modify "" overrides. Any other dimension will get overlined. Since the dimensions that have same override as original value have I didn't bother comparing overwrittenvalue and realvalue. No need to do so. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;LSP routine made by Jef! ;;2014-02-06 ;;with no expressed written or applied warranty ;;;;;;;;;;;;;; (defun c:OverrideFinder ( / working_list counter entity entityslist overwrittenvalue realvalue exclusionlist) (command "undo" "be") (setq exclusionlist (list "<>" ""));add more if required (if (setq working_list (ssget "_X" '((0 . "*DIMENSION")) )) (progn (princ "Dimensions detected") (setq counter 0) (while (< counter (sslength working_list)) (setq entity (ssname working_list counter)) (setq entityslist (entget entity)) (if (not (member (setq overwrittenvalue (cdr (assoc 1 entityslist))) exclusionlist)) (progn (princ "\nDimension processed!") (setq realvalue (cdr (assoc 42 entityslist))) (entmod (subst (cons 1 (strcat "%%o" overwrittenvalue)) (assoc 1 entityslist) entityslist)) );progn (princ "\nDimension with no overwride skipped") );if (setq counter (+ 1 counter)) );while );progn (alert "No dimensions found.. Ungroup first!") ) (princ "Processing finished") (command "undo" "end") ) Pretty nifty, huh? If you want to learn LISP, analyze everything expression by expression.. With dedication it is possible to achieve many things. I never took any class and my post-its made 3 or 4 months ago look like "structure of the if function", "setq doesn't need quotation marks, setvar does".. and look at what I just made. Actually, I self impressed myself! don't hesitate to Google any function to fully understand it. Take many written notes, it helps assimilate knowledge.. And every time you review your notes you can see the progress you made. For instance: "Hey, last month I needed my notes to make a cond statement". Don't hesitate to ask if further explanations are required. (you should) Happy coding, Cheers Jef! 1 Quote
bohoon Posted February 7, 2014 Author Posted February 7, 2014 I just tried it and it works perfect for me. Thank you again for your time and help. I don't know much lisp but I am impressed as well I will take your advise and analyze it line by line. I have many ideas for simple rutines which could make my life easier and that is why I am sure that time spend on learning lisp won't be wasted. Quote
bohoon Posted March 17, 2014 Author Posted March 17, 2014 Jef! ... or someone else willing to help:) Lisp works great, but unfortunentally situation with all dimensions being overriden even when dimension isn't shortened does appear (It happens when program creates 2d drawings of single elements like plates, steel profiles...) I was trying by myself change your code but with no success. I suppose what I need to do is to add a "if" function that will compare real dimension value with the one overriden. The overrdien value has to be first converted from text to numbers. I wanted to set tolerance to 1 mm (1 drawing unit) - so for example if real value is bigger/smaller less than 1 unit from overriden value --> dimension goes to exclusion list which You used in your code. I hope you know what I mean. Could You please help me again with this one? Quote
marko_ribar Posted March 18, 2014 Posted March 18, 2014 Replace this line : (entmod (subst (cons 1 (strcat "%%o" overwrittenvalue)) (assoc 1 entityslist) entityslist)) With this line : (if (not (equal realvalue (atof overwrittenvalue) 1.0)) (entmod (subst (cons 1 (strcat "%%o" overwrittenvalue)) (assoc 1 entityslist) entityslist)) ) Of course this means that these values are compareable (your statement that all dimensions are metric and represented with numbers with decimal structure) Quote
bohoon Posted March 18, 2014 Author Posted March 18, 2014 You guys are awesome:D I tried it and by now it works just as it should. We never use imperial system so no further complications are expected;) Thank you for quick and helpful response. Quote
Aftab Younas Posted July 3 Posted July 3 hi all thanks for the wonderful lisp. It works perfectly but is there any possibility to add color to the highlighted dimension. because i have like 5000 dimensions which is a little hard to find. Quote
X11start Posted July 8 Posted July 8 (edited) Lisp to verify forced dimensions. VERIFQTA.LSP Edited July 8 by X11start Quote
BIGAL Posted July 8 Posted July 8 Did you google "color dimensions autocad lisp" 1st entry is from here in Cadtutor. 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.