Entity Data Comparison

Entity Data Comparison

kpennell
Collaborator Collaborator
1,176 Views
5 Replies
Message 1 of 6

Entity Data Comparison

kpennell
Collaborator
Collaborator

When I compare the data of the same entity, and do a comparison, I always get a 'nil' returned.

 

(setq before (entget (car (entsel)))); I pick an entity

(setq after (entget (car (entsel)))); I pick the exact same, unmodified entity

(= before after); this always returns 'nil'.

 

I'm studying the 'entget' data, and all the strings and numbers are identical.  Should it return to me as 'T'?

 

Weird.  Thanks.

0 Likes
Accepted solutions (1)
1,177 Views
5 Replies
Replies (5)
Message 2 of 6

kpennell
Collaborator
Collaborator

So I'm guessing, it has something to do with the name of the selection set, which gets recorded in the data, but not presented?

0 Likes
Message 3 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

The (=) function takes number or string arguments only [read about it in Help].  Use (equal) or (eq) instead.

Kent Cooper, AIA
0 Likes
Message 4 of 6

rkmcswain
Mentor
Mentor

Since these functions can be hard to find in help these days, here are a couple of links.

 

= | equal

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 5 of 6

kpennell
Collaborator
Collaborator

I did as you suggested. I'm taking it, that 'equal' is true and forgiving than '=' or 'eq'.

 

Thanks for this.

0 Likes
Message 6 of 6

devitg
Advisor
Advisor

I use to check same enty , the 5 code , it is the handle, handle is one and unique for each enty , or the OBJECTID .

 

(SETQ ENT-A (CAR(ENTSEL "/N PICK YOU ENTY")))

(SETQ ENT-B (THE-SAME-NOT ENT-A))


(DEFUN THE-SAME-NOT  (ENT-A
                      /
                      
                      HANDLE-A
                      HANDLE-B
                      )

  (SETQ HANDLE-A (CDR (ASSOC 5 (ENTGET ENT-A))))
  (SETQ ENT-B (CAR (ENTSEL "/N PICK THE OTHER")))
  (SETQ HANDLE-B (CDR (ASSOC 5 (ENTGET ENT-B))))
  (IF (= HANDLE-B HANDLE-A)
    (PROGN
      (ALERT
        (STRCAT "\nYou did not understood what I ask for , try it again!")
        )
      (THE-SAME-NOT ENT-A) ; RECURSIVE
      )
    )
  ENT-B
  )



 

(SETQ ENT-A (CAR(ENTSEL "/N PICK YOU ENTY")))

(SETQ ENT-B (NOT-THE-SAME ENT-A))


(DEFUN NOT-THE-SAME  (OBJ-A /
                      OBJ-A-ID OBJ-B OBJ-B-ID
                                                     
;;;                     
                                 )
(VL-LOAD-COM)
  (IF (= (TYPE OBJ-A) 'ENAME)
    (SETQ OBJ-A (VLAX-ENAME->VLA-OBJECT OBJ-A))
    )

  (SETQ OBJ-A-ID (VLA-GET-OBJECTID OBJ-A))

  (SETQ ENT-B (CAR(ENTSEL "/N PICK THE OTHER")))
  (SETQ OBJ-B (VLAX-ENAME->VLA-OBJECT ENT-B))
  (SETQ OBJ-B-ID (VLA-GET-OBJECTID OBJ-B))


  (IF (= OBJ-A-ID OBJ-B-ID)
    (PROGN
      (ALERT
       (strcat "\nYou did not understood what I ask for , try it again!"  )
        )
      (NOT-THE-SAME OBJ-A ); RECURSIVE
      ); PROGN
    )

  ENT-B
        )


 

 

 

 

 

 

 

0 Likes