PDA

View Full Version : Extracting Attribute Information


stephen.coff
2006-11-19, 06:12 AM
I would be most greatful if anyone could assist.

I am trying to get some attribute information to use in a lisp routine to create a transmittal.
I have beenable to open the application and the .xls file. I can place the information in the cell required though having trouble getting the attribute information.

I just want to get specific tags information from a block, though the block contains multiple tags. I am not sure how to get the itemised tags info.
eg:
Block Name - Sheet Details-DSA

Tags in oredr as displayed when opened in block editor.

DRAWING_TITLE_LINE_1
DRAWING_TITLE_LINE_2
DRAWING_TITLE_LINE_3
DRAFTSMANS_NAME
WHO_CHECKED_THE_DRAWING
WHO_QA_CHECKED_THE_DRAWING
WHAT_IS_THE_SCALE_OF_THE_DRAWING
NUMBER_OF_DRAWINGS_IN_SET
DATE_THE_DRAWING_WAS_CREATED
WHAT_IS_THE_PROJECT_NUMBER
WHAT_IS_THE_CURRENT_ISSUE
WHAT_IS_THE_DRWING_NUMBER

I want to get the value (attribute information) for "WHAT_IS_THE_CURRENT_ISSUE".
I have done a search and found a few threads though haven't been successful as yet. I have also looked for the samples mentioned in a few threads though not installed.
If anyone could assist with an example, it would be much appreciated.

Regards

Stephen

kennet.sjoberg
2006-11-19, 10:50 AM
(defun GetAtt ( MyBlock AttTag / SelSet #Block AttName Result )
(setq AttTag (strcase AttTag nil ) )
(if (setq SelSet (ssget "X" (list (cons 0 "INSERT") (cons 2 MyBlock )))) (setq #Block (sslength SelSet ) ) (setq #Block 0 ) )
(cond
((= 0 #Block ) (princ "No matching block in drawing" ) )
((< 1 #Block ) (alert "More than one matching block in drawing" ) )
(t
(setq AttName (ssname SelSet 0 ) ) ; Main ent
(while AttName
(setq AttName (entnext AttName ) ) ; Sub ent
(cond
((equal (assoc 0 (entget AttName )) '(0 . "SEQEND")) (setq AttName nil ) )
((equal (assoc 2 (entget AttName )) (cons 2 AttTag )) (setq Result (cdr (assoc 1 (entget AttName )))) )
(t (princ "No matching attribute in block" ))
)
)
)
)
(if Result Result (princ) )
)

Usage :
Command: (GetAtt "MyBlock" "MyTag" )
and for you:
Command: (GetAtt "Sheet Details-DSA" "WHAT_IS_THE_CURRENT_ISSUE" )

: ) Happy Computing !

kennet

stephen.coff
2006-11-19, 10:07 PM
Thank you Kennet, greatly appreciated.

Regards

Stephen