Author Topic: Best way to compare 2 drawings  (Read 4779 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Best way to compare 2 drawings
« Reply #15 on: April 03, 2015, 01:43:51 PM »
And you could go the code route to compare the layers :)
Code - Auto/Visual Lisp: [Select]
  1. (defun c:comparelayers (/ a adoc b doc dwg l lay lprops ll ll2 name odbx out props props2 v x)
  2.   (setq lprops '("Color" "Freeze" "LayerOn" "Linetype" "Lineweight" "Lock"
  3.                  ;; "PlotStyleName"
  4.                  "Plottable")
  5.   )
  6.     (if (not (wcmatch (vla-get-name x) "*|*"))
  7.       (setq ll
  8.              (cons
  9.                (list (strcase (vla-get-name x)) (mapcar '(lambda (l) (cons l (vlax-get x l))) lprops))
  10.                ll
  11.              )
  12.       )
  13.     )
  14.   )
  15.   (cond
  16.     ((or
  17.        (null (setq dwg (getfiled "Select a drawing to compare layers:" (getvar 'dwgprefix) "dwg" 16))
  18.        )
  19.        (= dwg "")
  20.      )
  21.      (print "Bye..")
  22.     )
  23.     ((null (setq odbx (cond ((< (setq v (substr (getvar 'acadver) 1 2)) "16")
  24.                              (vla-getinterfaceobject doc "ObjectDBX.AxDbDocument")
  25.                             )
  26.                             ((vla-getinterfaceobject doc (strcat "ObjectDBX.AxDbDocument." v)))
  27.                       )
  28.            )
  29.      )
  30.      (print "ObjectDBX.AxDbDocument could NOT be created!")
  31.     )
  32.     ((vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list odbx dwg)))
  33.      (print (strcase (strcat "*Error opening*: " dwg)))
  34.     )
  35.     ((vlax-for lay (vla-get-layers odbx)
  36.        (setq name (strcase (vla-get-name lay)))
  37.        (cond ((null (setq props (cadr (assoc name ll))))
  38.               (print (strcat name " not in current drawing..."))
  39.              )
  40.              ((equal (setq props2 (mapcar '(lambda (x) (cons x (vlax-get lay x))) lprops)) props)
  41.               (setq ll (vl-remove (list name props) ll))
  42.               (print (strcat name " matches..."))
  43.              )
  44.              ((print (strcat name " different..."))
  45.               (setq ll (vl-remove (list name props) ll))
  46.               (mapcar '(lambda (a b)
  47.                          (if (not (equal a b))
  48.                            (print (strcat (vl-princ-to-string (car a))
  49.                                           ": "
  50.                                           (vl-princ-to-string (cdr a))
  51.                                           " -> "
  52.                                           (vl-princ-to-string (cdr b))
  53.                                   )
  54.                            )
  55.                          )
  56.                        )
  57.                       props2
  58.                       props
  59.               )
  60.              )
  61.        )
  62.      )
  63.      (mapcar '(lambda (x) (print (strcat (car x) " not in other drawing..."))) ll)
  64.      (vlax-release-object odbx)
  65.     )
  66.   )
  67.   (princ)
  68. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Best way to compare 2 drawings
« Reply #16 on: April 03, 2015, 06:15:56 PM »
I did not know you can export the layer state into excel. The two drawings have the same Named Layers but the colors - on - off are different.

Import Data...from TXT

the formatting is messy but it will import.


Upon thinking about it the Cad Standards checker is probably the better option
as it would allow comparing a >>> b

and b >>>>a

just to catch difference (changes) in either direction

Just go to layer palette and
Ctrl+A(select all)
Ctrl+C(copy)

Then open excel
Ctrl+V(paste)


Then delete all rows except name and whatever else you want.
Select all and format as table and then you filtering added easy and you can make two tables align by value to compare