Jump to content

Compare 2 objects


DuanJinHui

Recommended Posts

Since every object has a unique handle property, strictly speaking, identical objects do no exist...

 

  1. First compare the objectname property of the two objects. If they have the same object name:
  2. Use the atoms-family function to get a list of all functions. Filter for "vla-get-*" functions and compile a list of all properties (skip the handle property).
  3. Check which properties are available (vlax-property-available-p) for the objects and compare values. Perhaps use vl-every to do so efficiently.

Link to comment
Share on other sites

Like Roy_043 some of the obvious line,arc,circle,pline layer, length,area you need to provide more information about what you are comparing, solids are different again.

Link to comment
Share on other sites

In its simplest, most primitive, form the function could look like this:

; (CompareEntities_P (car (entsel)) (car (entsel)))
(defun CompareEntities_P (enm1 enm2 / elst1 elst2)
 (setq elst1 (entget enm1))
 (setq elst2 (entget enm2))
 (and
   (= (length elst1) (length elst2))
   (vl-every
     '(lambda (sub1 sub2)
       (cond
         ((/= (car sub1) (car sub2))
           nil
         )
         ((vl-position (car sub1) '(-1 5)) ; Skip ename and handle.
           T
         )
         (T
           (equal sub1 sub2 1e-
         )
       )
     )
     elst1
     elst2
   )
 )
)

Link to comment
Share on other sites

@Lee:

Interesting solution, but with a chance of false positives.

 

Thanks Roy, though a stricter comparison may miss valid results - this form of function is notoriously ambiguous.

Link to comment
Share on other sites

In its simplest, most primitive, form the function could look like this:

; (CompareEntities_P (car (entsel)) (car (entsel)))
(defun CompareEntities_P (enm1 enm2 / elst1 elst2)
 (setq elst1 (entget enm1))
 (setq elst2 (entget enm2))
 (and
   (= (length elst1) (length elst2))
   (vl-every
     '(lambda (sub1 sub2)
       (cond
         ((/= (car sub1) (car sub2))
           nil
         )
         ((vl-position (car sub1) '(-1 5)) ; Skip ename and handle.
           T
         )
         (T
           (equal sub1 sub2 1e-
         )
       )
     )
     elst1
     elst2
   )
 )
)

 

Thank you Roy, 8)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...