| Author |
Message |
z26y25
Guest
|
Posted:
Sat Apr 02, 2005 1:39 am Post subject:
Testing for entity existence |
|
|
I have a list of entities that I want to go through one by one and test for the existence of that entity. The idea is that I am saving a tab name and a viewport entity name in a list. When I retrieve the entity name I would like to be able to test for it's existence before manipulating it, this way I could test to see if it had been erased.
I've tried several versions of:
(ssget "x" (list '(-1 . entity)))
and
(ssget "x" (list (cons -1 entity)))
Where entity is the entity name.
Does anyone have any suggestions on how to perform this test?
|
|
| Back to top |
|
 |
Jason Piercey
Guest
|
Posted:
Sat Apr 02, 2005 1:58 am Post subject:
Re: Testing for entity existence |
|
|
Not sure I completely understand what you are
trying to do exactly, but can't you just use (entget)?
Command: (setq ename (car (entsel)))
Select object: <Entity name: 79d727a0>
Command: (entdel ename)
<Entity name: 79d727a0>
Command: (entget ename)
nil
--
Autodesk Discussion Group Facilitator
"z26y25" <nospam@address.withheld> wrote in message
news:31912872.1112387978442.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | I have a list of entities that I want to go through one by one and test
for the existence of that entity. The idea is that I am saving a tab name |
and a viewport entity name in a list. When I retrieve the entity name I
would like to be able to test for it's existence before manipulating it,
this way I could test to see if it had been erased.
| Quote: |
I've tried several versions of:
(ssget "x" (list '(-1 . entity)))
and
(ssget "x" (list (cons -1 entity)))
Where entity is the entity name.
Does anyone have any suggestions on how to perform this test? |
|
|
| Back to top |
|
 |
Don Ireland
Guest
|
Posted:
Sat Apr 02, 2005 2:43 am Post subject:
Re: Testing for entity existence |
|
|
There is only one item in the list so "nth 0" works in THIS case. Develop
as needed.
(setq testList(list "LINE"))
(ssget "x" (list(cons 0 (nth 0 testList))))
"z26y25" <nospam@address.withheld> wrote in message
news:31912872.1112387978442.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | I have a list of entities that I want to go through one by one and test for
the existence of that entity. The idea is that I am saving a tab name and
a viewport entity name in a list. When I retrieve the entity name I would
like to be able to test for it's existence before manipulating it, this way
I could test to see if it had been erased.
I've tried several versions of:
(ssget "x" (list '(-1 . entity)))
and
(ssget "x" (list (cons -1 entity)))
Where entity is the entity name.
Does anyone have any suggestions on how to perform this test? |
|
|
| Back to top |
|
 |
Tom Smith
Guest
|
Posted:
Sat Apr 02, 2005 2:43 am Post subject:
Re: Testing for entity existence |
|
|
| Interesting -- according to help, ssget will ignore enames, handles, and xdata codes in filter lists, so you'll have to take another approach. Sorry I don't have a suggestion. |
|
| Back to top |
|
 |
Don Ireland
Guest
|
Posted:
Sat Apr 02, 2005 2:47 am Post subject:
Re: Testing for entity existence |
|
|
You CAN use variables in the filter lists--just not using the abbreviated
list notation. By "abbreviated list notation, I mean using the apostrophe
instead of typing out list.
i.e.
;the following WILL work--I just did it (using Acad2k5)
(ssget "x" (list(cons 0 (nth 0 testList))))
;the following will NOT work
(ssget "x" '(cons 0 (nth 0 testList)))
"Tom Smith" <nospam@address.withheld> wrote in message
news:25836699.1112391849587.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | Interesting -- according to help, ssget will ignore enames, handles, and
xdata codes in filter lists, so you'll have to take another approach.
Sorry I don't have a suggestion. |
|
|
| Back to top |
|
 |
Don Ireland
Guest
|
Posted:
Sat Apr 02, 2005 2:56 am Post subject:
Re: Testing for entity existence |
|
|
Misunderstood what OP was looking for. But I DO have a solution for him.
"Don Ireland" <don@n0spam.donireland.com> wrote in message
news:424dc18b$1_3@newsprd01...
| Quote: | You CAN use variables in the filter lists--just not using the abbreviated
list notation. By "abbreviated list notation, I mean using the apostrophe
instead of typing out list.
i.e.
;the following WILL work--I just did it (using Acad2k5)
(ssget "x" (list(cons 0 (nth 0 testList))))
;the following will NOT work
(ssget "x" '(cons 0 (nth 0 testList)))
"Tom Smith" <nospam@address.withheld> wrote in message
news:25836699.1112391849587.JavaMail.jive@jiveforum2.autodesk.com...
Interesting -- according to help, ssget will ignore enames, handles, and
xdata codes in filter lists, so you'll have to take another approach.
Sorry I don't have a suggestion.
|
|
|
| Back to top |
|
 |
Don Ireland
Guest
|
Posted:
Sat Apr 02, 2005 2:58 am Post subject:
Re: Testing for entity existence |
|
|
SORRY misunderstood what you were asking for.
;retrieve EVERY element in the file
(setq entlist(ssget "x"))
;if entity is in entlist then returns the ename
;otherwise returns nil
(ssmemb entity entlist)
"Don Ireland" <don@n0spam.donireland.com> wrote in message
news:424dc06b$1_3@newsprd01...
| Quote: | There is only one item in the list so "nth 0" works in THIS case. Develop
as needed.
(setq testList(list "LINE"))
(ssget "x" (list(cons 0 (nth 0 testList))))
"z26y25" <nospam@address.withheld> wrote in message
news:31912872.1112387978442.JavaMail.jive@jiveforum2.autodesk.com...
I have a list of entities that I want to go through one by one and test
for the existence of that entity. The idea is that I am saving a tab name
and a viewport entity name in a list. When I retrieve the entity name I
would like to be able to test for it's existence before manipulating it,
this way I could test to see if it had been erased.
I've tried several versions of:
(ssget "x" (list '(-1 . entity)))
and
(ssget "x" (list (cons -1 entity)))
Where entity is the entity name.
Does anyone have any suggestions on how to perform this test?
|
|
|
| Back to top |
|
 |
Don Ireland
Guest
|
Posted:
Sat Apr 02, 2005 3:09 am Post subject:
Re: Testing for entity existence |
|
|
And remember the ename will change every time you reopen the file.
"Don Ireland" <don@n0spam.donireland.com> wrote in message
news:424dc41e$1_3@newsprd01...
| Quote: | SORRY misunderstood what you were asking for.
;retrieve EVERY element in the file
(setq entlist(ssget "x"))
;if entity is in entlist then returns the ename
;otherwise returns nil
(ssmemb entity entlist)
"Don Ireland" <don@n0spam.donireland.com> wrote in message
news:424dc06b$1_3@newsprd01...
There is only one item in the list so "nth 0" works in THIS case.
Develop as needed.
(setq testList(list "LINE"))
(ssget "x" (list(cons 0 (nth 0 testList))))
"z26y25" <nospam@address.withheld> wrote in message
news:31912872.1112387978442.JavaMail.jive@jiveforum2.autodesk.com...
I have a list of entities that I want to go through one by one and test
for the existence of that entity. The idea is that I am saving a tab
name and a viewport entity name in a list. When I retrieve the entity
name I would like to be able to test for it's existence before
manipulating it, this way I could test to see if it had been erased.
I've tried several versions of:
(ssget "x" (list '(-1 . entity)))
and
(ssget "x" (list (cons -1 entity)))
Where entity is the entity name.
Does anyone have any suggestions on how to perform this test?
|
|
|
| Back to top |
|
 |
Tom Smith
Guest
|
Posted:
Sat Apr 02, 2005 8:27 am Post subject:
Re: Testing for entity existence |
|
|
I understand the differences in filter list syntax. The single-apostrophe is not just an abbreviated format. The apostrophe is shorthand for the lisp "quote" function, which has the purpose of suppressing evaluation of an atom or list.
'(1 2 3) is identical to (quote (1 2 3)) -- they both return the unevaluated list (1 2 3). You can't quote (supress evaluation of) any list which contains a variable that needs to be evaluated. If you (setq var 1), then '(var 2 3) will return (VAR 2 3) whereas (list var 2 3) will return (1 2 3).
I was simply repeating what the A2K4 help docs state -- that entity names and handles are not allowed, and are ignored, in ssget filter lists. It's not a matter of notation, it's a matter of what criteria you can filter upon. The OP had a syntax error, yes. But that wasn't the basic problem. In A2K4, at least, you can't filter on entity names, period.
Your solution of tesing the members of the ename list against the whole drawing sset looks like a clever way to work around this cruel fact, though it might be punishingly slow in a large file. Maybe it will work out for the OP. |
|
| Back to top |
|
 |
|
|
|
|