Hi Everyone, I hope I can discribe this well enough... sometimes someone dimensions a floor plan and starts one direction and then "goes back " the other way over the top of the dimension they just placed, which causes the dimension lines to overlap, which in turn shows incorrect distances when viewing on paper. Does anyone know of a lisp routine that can alert you to the fact that there are overlapping dimension lines (not the extension lines) in a drawing by changing them to color White or something? I have pasted a routine that we use which changes all dimenions with "modified text" to color white. That way I can see if someone just typed in the dimension distance they wanted instead of what was actually there. I don't know if this routine can be modified in anyway to acheive the results I'm asking for.
Any help would surely be appreciated.
(defun c:dc (/ dim_length)
(setq ssmod (ssget "X" (list (cons 0 "Dimension")(cons 1 "~"))))
(if ssmod
(progn
(setq dim_length (sslength ssmod))
(command "Change" ssmod "" "P" "C" "w" "")
(strcat "Found a total of ""< " (rtos dim_length 2 0) " >"" modified dimension(s), please verify. Use the DCB command to change the color back to BYLAYER")
);progn
(progn
(prompt "\nThere were no modified dimensions found...") (princ)
);end second program
); if
);end function
Thanks,
John W.
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
Hi John,
Are you able to upload a sample drawing containing an example of such an overlapping dimension?
Hi Lee, I've attached a primative sample of what problems can occur with the dim continue command IF someone isn't paying attention to what they're doing. I simply ran the right 1'-8" dimension from left to right and then hit dim cont and went the other direction to the left side of the opening and finished on the left. The 10'-0" dimension is actually going from the right side of the example to the left 1'-8" dimension. I labled all on the cad file as well.
Thanks,
John
I also have the same concern when I find an overlapping dimension.
Once I find one, I need to click on every single dimension to confirm there are no more overlapping dimensions.
I find this to be a very hard error to discover. Usually by chance or after construction has started.
Thanks John -
The following is only a quick draft (and may be slow!), but should hopefully perform as required:
;; Dimension Overlap - Lee Mac ;; Detects overlapping linear dimensions and moves the dimension to a separate layer (defun c:dimoverlap ( / dm1 dm2 enx g10 g13 g14 idx int lst sel tmp vec ) (if (setq sel (ssget "_X" (list '(0 . "DIMENSION") '(-4 . "<OR") '(70 . 000) '(70 . 032) '(70 . 064) '(70 . 096) '(70 . 128) '(70 . 160) '(70 . 192) '(70 . 224) '(-4 . "OR>") (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model") ) ) ) ) (progn (repeat (setq idx (sslength sel)) (setq enx (entget (ssname sel (setq idx (1- idx)))) g10 (cdr (assoc 10 enx)) g13 (cdr (assoc 13 enx)) g14 (cdr (assoc 14 enx)) vec (mapcar '- g10 g14) int (inters g10 (mapcar '+ g10 (list (- (cadr vec)) (car vec) 0.0)) g13 (mapcar '+ g13 vec) nil ) lst (cons (list g10 int enx) lst) ) ) (while (setq dm1 (car lst)) (setq lst (cdr lst) tmp lst ) (while (not (or (null (setq dm2 (car tmp))) ( (lambda ( / x y ) (if (vl-some (function (lambda ( a b c d / e f ) (if (setq f (equal a c 1e-3)) (progn (setq e (distance b d)) (or (setq x (< e (distance a b))) (setq y (< e (distance c d))) ) ) ) f ) ) (list (car dm1) (car dm1) (cadr dm1) (cadr dm1)) (list (cadr dm1) (cadr dm1) (car dm1) (car dm1)) (list (car dm2) (cadr dm2) (car dm2) (cadr dm2)) (list (cadr dm2) (car dm2) (cadr dm2) (car dm2)) ) (if (or x y) ( (lambda ( e ) (entmod (subst '(8 . "DIMOVERLAP") (assoc 8 (caddr e)) (caddr e) ) ) t ) (if x dm1 dm2) ) ) ) ) ) ) ) (setq tmp (cdr tmp)) ) ) ) ) (princ) )
The above processes only Linear Dimensions and assumes all dimensions reside in the WCS X-Y plane
- that's all I have time for I'm afraid.
Give it a try and let me know how you get on
@Johnw wrote:
I tried to attach a .dwg file and it wouldn't let me so I had to zip it.
This is a known issue and a fix will be rolled out soon. Zipping and attaching is the solution for now.
Thanks
Discussion_Admin
You're very welcome John, it was an interesting program to write
I'm unaware of any formal training available online or elsewhere (perhaps you might need to contact your local Autodesk representative?), but I would personally recommend learning the very basics of AutoLISP (such as the syntax and basic functions) from free online tutorials, and then progress with your learning through many hours of practice and through feedback and information received from the forums.
As a side-note, be sure to mark my post as the solution (if you are satisfied) so that the thread is marked as resolved.
Hi Lee, if you have a moment could you add the following to already great routine:
1. If there are overlapping dimensions can the command alert you to say "There were X overlapping dimensions found in the drawing.
2. If there are no overlapping dimensions can the routine state the following (I tried to add in myself but couldn't find the proper "IF" statement to add it to):
(progn
(prompt "\nThere were no overlapping dimensions found...") (princ)
)
3. If it's not too timeconsuming - can you have the command look inside blocks with dimensions and turn those dims white as well? Yes, I know this one is asking a lot. 🙂
Thanks again Lee. Have a great afternoon!
I haven't had much time to look back over this, but try the following code:
;; Dimension Overlap - Lee Mac ;; Detects overlapping linear dimensions and moves the dimension to a separate layer (defun c:dimoverlap ( / *error* cn1 cn2 ) (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (setq cn1 0 cn2 0 ) (LM:startundo (LM:acdoc)) (vlax-for blk (vla-get-blocks (LM:acdoc)) (if (= :vlax-false (vla-get-isxref blk)) (if (= :vlax-true (vla-get-islayout blk)) (setq cn1 (+ cn1 (processblock blk))) (setq cn2 (+ cn2 (processblock blk))) ) ) ) (if (< 0 cn2) (vla-regen (LM:acdoc) acallviewports) ) (if (< 0 (+ cn1 cn2)) (princ (strcat "\n" (itoa (+ cn1 cn2)) " overlapping dimension" (if (= 1 cnt) "" "s") " found." (if (< 0 cn2) (strcat "\n" (itoa cn2) (if (= 1 cn2) " was in a block." " were in blocks.") ) "" ) ) ) (princ "\nNo overlapping dimensions were found.") ) (LM:endundo (LM:acdoc)) (princ) ) (defun processblock ( blk / cnt dm1 dm2 enx g10 g13 g14 int lst tmp vec ) (vlax-for obj blk (if (= "AcDbRotatedDimension" (vla-get-objectname obj)) (setq enx (entget (vlax-vla-object->ename obj)) g10 (cdr (assoc 10 enx)) g13 (cdr (assoc 13 enx)) g14 (cdr (assoc 14 enx)) vec (mapcar '- g10 g14) int (inters g10 (mapcar '+ g10 (list (- (cadr vec)) (car vec) 0.0)) g13 (mapcar '+ g13 vec) nil ) lst (cons (list g10 int enx) lst) ) ) ) (setq cnt 0) (while (setq dm1 (car lst)) (setq lst (cdr lst) tmp lst ) (while (not (or (null (setq dm2 (car tmp))) ( (lambda ( / x y ) (if (vl-some (function (lambda ( a b c d / e f ) (if (setq f (equal a c 1e-3)) (progn (setq e (distance b d)) (or (setq x (< e (distance a b))) (setq y (< e (distance c d))) ) ) ) f ) ) (list (car dm1) (car dm1) (cadr dm1) (cadr dm1)) (list (cadr dm1) (cadr dm1) (car dm1) (car dm1)) (list (car dm2) (cadr dm2) (car dm2) (cadr dm2)) (list (cadr dm2) (car dm2) (cadr dm2) (car dm2)) ) (if (or x y) ( (lambda ( e ) (entmod (subst '(8 . "DIMOVERLAP") (assoc 8 (caddr e)) (caddr e) ) ) (setq cnt (1+ cnt)) ) (if x dm1 dm2) ) ) ) ) ) ) ) (setq tmp (cdr tmp)) ) ) cnt ) ;; Start Undo - Lee Mac ;; Opens an Undo Group. (defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc) ) ;; End Undo - Lee Mac ;; Closes an Undo Group. (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc) ) (vl-load-com) (princ)
Thanks Lee! This is fantastic... FYI I sent you a private message regarding some programming inquires. Please take a look. If you cannot find that message, please reply to this one and I'll resend.
Thank you very much,
John
Thanks John
My apologies, I had received your earlier message, but hadn't had a chance to respond
Good morning Lee, I left you my email address in the private message I sent you. When you have a moment can you look the message and email me your response to the questions I put forth? Thanks, John
@Johnw wrote:Good morning Lee, I left you my email address in the private message I sent you. When you have a moment can you look the message and email me your response to the questions I put forth? Thanks, John
Hi John,
I thought I replied to your message yesterday, but perhaps the message didn't reach you - no problem though, I shall forward my response to the email address you provided.
Cheers,
Lee
overlaped dims are very serious problem so i wrote my own tool FOD.
includes of course some Lee sub routine
kruuger
Has anything new become of this issue?
Does the green text at the top of the code need to be copy/pasted?
The issue is the same as what started this thread - even johnw's .dwg attachment displays exactly what the problem is.
Just one question - what needs to change in the code to turn the layer a different color than white?