How to get rid of "ADS request error"?

How to get rid of "ADS request error"?

Anonymous
Not applicable
4,320 Views
7 Replies
Message 1 of 8

How to get rid of "ADS request error"?

Anonymous
Not applicable

Hello Community,
surfing I come across one very useful function "getpropertyvalue" it works fine until it get property name & property value of entity. But problem starts when this function has failed to get property name or property value of any property name. "It gives ADS request error"
Is there any way to check "Property Name" & "Property Available" before getting ADS request error?

0 Likes
Accepted solutions (1)
4,321 Views
7 Replies
Replies (7)
Message 2 of 8

Ranjit_Singh
Advisor
Advisor
Accepted solution

You could use vlax-property-available-p. However, that needs a vlaobject, whereas getpropertyvalue needs an ename as its first argument. So you could do this for instance

(if (vlax-property-available-p (vlax-ename->vla-object ename1) "Length")
 (getpropertyvalue ename1 "Length")
 (princ "\nProperty not available"))

or other option

(if (vl-catch-all-error-p (vl-catch-all-apply 'getpropertyvalue (list ename1 "Length")))
 (princ "\nProperty not available")
 (getpropertyvalue ename1 "Length"))

Change ename1 to your variable name containing the ename of the entity. Since you are only reading the property, above is sufficient.

Edit: Read post 8 here which has a link in there. That link has more information on the function.

 

Message 3 of 8

Anonymous
Not applicable
Thank You Ranjit Sir,
I will try this.
Can I get back to you if I have any question regarding this?
0 Likes
Message 4 of 8

Ranjit_Singh
Advisor
Advisor

Sure. There are quite a few helpful active members here. So you will get an answer.

Message 5 of 8

Anonymous
Not applicable
Thank you Ranjit Sir,
Property values are getting without ADS request error by using both the codes.
0 Likes
Message 6 of 8

Anonymous
Not applicable

Is it possible to add more than one property to check in list & get values by getpropertyvalue

(if (vl-catch-all-error-p (vl-catch-all-apply 'getpropertyvalue (list ename1 "Length" "Width" "Layer ")))
 (princ "\nProperty not available")
(progn
 (getpropertyvalue ename1 "Length")
(getpropertyvalue ename1 "Width")
(getpropertyvalue ename1 "Layer")
)
)
0 Likes
Message 7 of 8

Ranjit_Singh
Advisor
Advisor

It pretty much depends on what you are trying to do. You can test them all separately or combine in one statement. This is just one example using line entity

(mapcar '(lambda (x) (cons x (vl-catch-all-apply 'getpropertyvalue (list ename1 x)))) '("Length" "Angle" "MissingProperty"))
(("Length" . 2000.0) ("Angle" . 5.16545) ("MissingProperty" . #<%catch-all-apply-error%>))

"MisingProperty" throws an error. You can now use the result to check which property failed.

 

0 Likes
Message 8 of 8

Anonymous
Not applicable
Thank You Ranjit Sir.
0 Likes