getpropertyvalue

getpropertyvalue

etilley327KA
Advocate Advocate
2,202 Views
24 Replies
Message 1 of 25

getpropertyvalue

etilley327KA
Advocate
Advocate

When I entsel the block I get the DESC2 value, but when it runs with the ssget, the dump shows it missing. What am I doing wrong?

(defun c:test (/ pointdata ddl i e pointxy)
  (setq pointdata (ssget "_X" '((0 . "INSERT")(8 . "DFORMSHOTS"))))
  (PRINC POINTDATA)
  (repeat (setq ii (sslength pointdata))
  (setq e (ssname pointdata (setq i (1- i))))
  (PRINC e)
  (PRINC (dumpallproperties e))
  (setq ddl (cons (getpropertyvalue e "DESC2") ddl))
  (setq pointxy (cons (list (getpropertyvalue e "Position/X")
                            (getpropertyvalue e "Position/Y")) pointxy))
    (cond
      ((= (strcase ddl) "28") (command "_insert" "r" pointxy "28" "" "" ""))
    ))
)
0 Likes
Accepted solutions (1)
2,203 Views
24 Replies
Replies (24)
Message 21 of 25

etilley327KA
Advocate
Advocate

I believe I was mistaken I dont think the problem lies in the property value of "DESC2". I think it is when the value isnt in the blklst. I still get ADS request error :error#0 on (setq a (getpropertyvalue h "DESC2")), but I think its somewhere else. I tried this, but im still getting an error.

(defun c:test (/ blklst s g h a blkname)
  (setq blklst '(("28" "28" 1) ("34" "34" 1) ("27" "27" 1)))
  (setq s (ssget "_A" '((0 . "INSERT")(8 . "DFORMSHOTS"))))
  (repeat (setq g (sslength s))
    (setq h (ssname s (setq g (1- g))))
    (setq a (getpropertyvalue h "DESC2"))
    (setq blkname (assoc a blklst))
    (if blkname
      (if (tblsearch "block" (cadr blkname))
        (command "_.insert" (cadr blkname) "_non" (getpropertyvalue h "Position") (caddr blkname) "" 0)
        (princ (strcat "\nBlock " a " not found in drawing.")))
      (princ (strcat "\nBlock " a " not found in block list.")))
  )
)

S=Selection set: 1c54
H=Entity name: 200570f3960
A=41
BLKNAME=nil
ADS request error :error#0

0 Likes
Message 22 of 25

Kent1Cooper
Consultant
Consultant

@etilley327KA wrote:

....

    (setq a (getpropertyvalue h "DESC2"))
    (setq blkname (assoc a blklst))
.....

Could it be a case issue?  If the value in the DESC2 Attribute is "test", but the 'blklst' variable list has a sub-list in it that's ("TEST" "whatever"), the (assoc) function won't find it.  It that's the problem, make sure the 'blklst' sub-lists all start with all-upper-case content, and do:

    (setq blkname (assoc (strcase a) blklst))

Kent Cooper, AIA
Message 23 of 25

etilley327KA
Advocate
Advocate
Thats a good idea, Ive added the strcase. However, right now I only have numbers in the list.
0 Likes
Message 24 of 25

Kent1Cooper
Consultant
Consultant

@etilley327KA wrote:

..... I still get ADS request error :error#0 on (setq a (getpropertyvalue h "DESC2")), ....


I get an "ADS request error" from (getpropertyvalue) if either the entity doesn't exist or it doesn't have the property listed.  It looks like you must have a Block by that point, so I have to ask, is "DESC2" the precise spelling of the Attribute tag?  I also notice that your summary includes A=41, but you don't have a sublist in 'blklst' for that value.  But I expect that should not be an issue until after the error mentioned -- that must be left over from some other code operation [maybe the same code, but before variables were localized?].

Kent Cooper, AIA
0 Likes
Message 25 of 25

etilley327KA
Advocate
Advocate

Yes the attribute is DESC2, and I was trying to get it to exclude values not in the blklist or in the dwg. Did I write it wrong, to skip those values?

0 Likes