Author Topic: How to compare entity name?  (Read 1939 times)

0 Members and 1 Guest are viewing this topic.

A_LOTA_NOTA

  • Bull Frog
  • Posts: 202
How to compare entity name?
« on: July 16, 2007, 08:47:27 PM »
How could I compare entity names to make sure they are not equal? If I wanted to test to see if the were equal I could use (eq Ent1 Ent2) & get "T" but (/= Ent1 Ent2) I also get "T"!

Adesu

  • Guest
Re: How to compare entity name?
« Reply #1 on: July 16, 2007, 09:01:34 PM »
Hi A_LOTA_NOTA ,
I think you want like this.
Code: [Select]
(defun c:test (/ ss1 ss2)
  (setq ss1 (car (entsel "\nSelect an object first")))
  (setq ss2 (car (entsel "\nSelect an object second")))
  (if
    (eq ss1 ss2)
    (alert "\nThis object is same entity")
    )  ; if
  (if
    (not (eq ss1 ss2))
    (alert "\nThis object is not same entity")
    )  ; if
  (princ)
  )

How could I compare entity names to make sure they are not equal? If I wanted to test to see if the were equal I could use (eq Ent1 Ent2) & get "T" but (/= Ent1 Ent2) I also get "T"!

gile

  • Water Moccasin
  • Posts: 2406
  • Marseille, France
Re: How to compare entity name?
« Reply #2 on: July 17, 2007, 02:45:51 AM »
Hi,

You have to use eq or equal function, = and /= only work with numbers or strings.
Speaking English as a French Frog

ronjonp

  • Needs a day job
  • Posts: 7462
Re: How to compare entity name?
« Reply #3 on: July 17, 2007, 10:45:15 AM »
This should do it:

Code: [Select]
(if (eq (car (entsel)) (car (entsel)))
  (alert "same")
  (alert "not same")
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC