Author Topic: retrieving attribute values  (Read 5728 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: retrieving attribute values
« Reply #15 on: December 01, 2005, 10:49:43 AM »
Please note I am not picking on you personally.
There are certain logic rules to follow when writing computer programs, you've just missed a few here.

Kerry, comment like your's give me nitro to improve my programs...thanks.  :roll:

also, from your comment I have modified the routine, could you comment this one ?
just to be sure...?

Code: [Select]
(defun c:getbat (/ edata attdata eb1 eb2)
(setq bname (getstring "Enter your block name : "))
  (if (ssget "X" (list (cons 0 "INSERT") (cons 2 bname))) (getdata)
    (alert (strcat "No block named " bname " was detected on this drawing."))
  );;if
)
(defun getdata () 
(setq edata (entget (ssname (ssget "X" (list (cons 0 "INSERT") (cons 2 bname))) 0)))
 (setq attdata (entget (entnext (dxf -1 edata))))
 (if (= (cdr (assoc 0 attdata)) "ATTRIB")
  (progn
    (setq x T)
    (setq edata (entget (entnext (dxf -1 edata))))
  (while x
(setq eb1 (dxf 1 edata));; = Attribute Value
        (setq eb2 (dxf 2 edata));; = Attribute TAG
        (alert (strcat "Tag = " eb2 "\nValue = " eb1))
        (setq edata (entget (entnext (dxf -1 edata))))
        (if (eq (dxf 0 edata) "SEQEND") (setq x nil))
    );;while
   );;progn
(alert "This block is present but miss attribute.")
  );;if
(setq bname nil)
  (princ)
)
(defun dxf (code elist)
(cdr (assoc code elist))
);defun

Keep smile...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: retrieving attribute values
« Reply #16 on: December 01, 2005, 11:01:42 AM »
sure, one item at a time ..

Do you know what the DXF 66 does ?
(setq ss (ssget "_X" '((0 . "INSERT") (66 . 1) (cons (2  blockNameToFind)))))

Think about passing the getdata function the  blockNameToFind

Think about returning the required info to the calling routine ;
ie : (setq val (getdata blockNameToFind) )

Think about localising your variables.

Think about testing the length of the selectionSet and advising the user that there is more than ONE block in the drawing.
 


kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: retrieving attribute values
« Reply #17 on: December 01, 2005, 12:20:37 PM »
sure, one item at a time ..

Do you know what the DXF 66 does ?
(setq ss (ssget "_X" '((0 . "INSERT") (66 . 1) (cons (2  blockNameToFind)))))

Think about passing the getdata function the  blockNameToFind

Think about returning the required info to the calling routine ;
ie : (setq val (getdata blockNameToFind) )

Think about localising your variables.

Think about testing the length of the selectionSet and advising the user that there is more than ONE block in the drawing.
 

Thanks Kerry..
I'll think a little bit more..  :lmao:
Keep smile...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: retrieving attribute values
« Reply #18 on: December 02, 2005, 05:22:42 PM »
How did you go ? ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.