Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Check if ename or object
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Check if ename or object (Read 1145 times)
0 Members and 1 Guest are viewing this topic.
mailmaverick
Bull Frog
Posts: 493
Check if ename or object
«
on:
December 29, 2016, 03:22:31 AM »
Is it possible to check if a variable is an entity-name or object ?
Logged
kdub_nz
Mesozoic keyThumper
SuperMod
Water Moccasin
Posts: 2139
class keyThumper<T>:ILazy<T>
Re: Check if ename or object
«
Reply #1 on:
December 29, 2016, 03:48:16 AM »
Yes
Logged
Called Kerry in my other life
Retired; but they dragged me back in !
I live at UTC + 13.00
---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.
kdub_nz
Mesozoic keyThumper
SuperMod
Water Moccasin
Posts: 2139
class keyThumper<T>:ILazy<T>
Re: Check if ename or object
«
Reply #2 on:
December 29, 2016, 04:01:15 AM »
Have a play ...
Code - Auto/Visual Lisp:
[Select]
(
setq
acadObj
(
vlax-get-acad-object
)
)
;;-> #<VLA-OBJECT IAcadApplication 00007ff7bf137538>
(
type
acadObj
)
;;-> VLA-OBJECT
(
=
(
type
acadObj
)
'
VLA-OBJECT
)
(
setq
ename
(
cdar
(
entget
(
entlast
)
)
)
)
;;-><Entity name: 158e8ba9460>
(
type
ename
)
;;-> ENAME
(
=
(
type
ename
)
'ENAME
)
Logged
Called Kerry in my other life
Retired; but they dragged me back in !
I live at UTC + 13.00
---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.
kdub_nz
Mesozoic keyThumper
SuperMod
Water Moccasin
Posts: 2139
class keyThumper<T>:ILazy<T>
Re: Check if ename or object
«
Reply #3 on:
December 29, 2016, 04:11:55 AM »
Realised I had these in my Library
May help you ..
Code - Auto/Visual Lisp:
[Select]
;; (KDUB:emptystring-p "1") ->nil
;; (KDUB:emptystring-p "") ->T
;; (KDUB:emptystring-p " ") ->T
;;
;; (KDUB:notemptystring-p "x") -> T
;; (KDUB:notemptystring-p "") -> nil
;; (KDUB:notemptystring-p " ") -> nil
;;
;; (KDUB:validstring-p "x") -> T
;; (KDUB:validstring-p "") -> nil
;; (KDUB:validstring-p " ") -> T
(
defun
kdub:string
-
p
(
arg
)
(
=
(
type
arg
)
'str
)
)
(
defun
kdub:validstring
-
p
(
arg
)
(
and
(
=
(
type
arg
)
'str
)
(
/=
0
(
strlen
arg
)
)
)
)
(
defun
kdub:emptystring
-
p
(
arg
)
(
and
(
=
(
type
arg
)
'str
)
(
=
0
(
strlen
(
vl-string-trim
" "
arg
)
)
)
)
)
(
defun
kdub:notEmptystring
-
p
(
arg
)
(
and
(
=
(
type
arg
)
'str
)
(
/=
0
(
strlen
(
vl-string-trim
" "
arg
)
)
)
)
)
(
defun
kdub:real
-
p
(
arg
)
(
equal
(
type
arg
)
'real
)
)
(
defun
kdub:integer
-
p
(
arg
)
(
equal
(
type
arg
)
'int
)
)
(
defun
kdub:vlaobject
-
p
(
arg
)
(
equal
(
type
arg
)
'
vla-object
)
)
(
defun
kdub:ename
-
p
(
arg
)
(
equal
(
type
arg
)
'ename
)
)
(
defun
kdub:variant
-
p
(
arg
)
(
equal
(
type
arg
)
'
variant
)
)
Logged
Called Kerry in my other life
Retired; but they dragged me back in !
I live at UTC + 13.00
---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.
Grrr1337
Swamp Rat
Posts: 812
WWW
Re: Check if ename or object
«
Reply #4 on:
December 29, 2016, 06:18:52 AM »
Or if you have the handle, then you could simply convert it to an ename or vla-object:
Code - Auto/Visual Lisp:
[Select]
_$
(
setq
handle
(
cdr
(
assoc
5
(
entget
(
car
(
entsel
)
)
)
)
)
)
"24B"
_$
(
handent
handle
)
<
Entity name: 7ff662504cb0
>
_$
(
vla-HandleToObject
(
vla-get-ActiveDocument
(
vlax-get-acad-object
)
)
handle
)
#
<
VLA-OBJECT
IAcadLWPolyline 000000623f71d378
>
_$
Logged
(apply ''((a b c)(a b c))
'(
(( f L ) (apply 'strcat (f L)))
(( L ) (if L (cons (chr (car L)) (f (cdr L)))))
(72 101 108 108 111 32 87 111 114 108 100)
)
)
vevo.bg
mailmaverick
Bull Frog
Posts: 493
Re: Check if ename or object
«
Reply #5 on:
December 29, 2016, 11:36:06 PM »
Thanks to all.
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Check if ename or object