PDA

View Full Version : Matching Block Attributes


Stephen.Walz
2006-11-16, 04:34 PM
Does anyone have some routine that allows you to match properties of attributes within a group of blocks...

I'm trying to revise a bunch of P&ID's. The moron who originally created these drawings defined the blocks so that the annotation whithin the symbols are at color 70!!!

Any help would be much appreciated.

Thanks

Steve

kennet.sjoberg
2006-11-16, 06:46 PM
hmmm, I think here is two different tasks.

The first task is to change the blockdefinition table,
in this example I change (62 . 70) to (62 . 1) equal to red. . .

(defun c:BlockDefAttRed ( / BlName EntName EntDxf ) ;; Change blockdefinition
(setq BlName (tblobjname "BLOCK" "MyBlock" ) )
(setq EntName BlName )
(while EntName
(setq EntDxf (entget Entname ) )
(if (and (equal (assoc 0 EntDxf ) '(0 . "ATTDEF") ) (equal (assoc 62 EntDxf ) '(62 . 70) ) )
(progn
(setq EntDxf (subst '(62 . 1) '(62 . 70) EntDxf ) )
(entmod EntDxf )
(entupd BlName )
)
( )
)
(setq EntName (entnext EntName ) )
)
(princ)
)

. . .and probably next inserted "MyBlock" will turn in to red attributed text now.

Next task is to change all previous inserted "MyBlock" . . .

(defun c:BlockAttRed ( / SelSet EntName Counter EntDxf ) ;; Change All "MyBlock"
(setq SelSet (ssget "_X" '((0 . "INSERT")(2 . "MyBlock"))) )
(setq Counter 0 )
(repeat (sslength SelSet )
(setq EntName (ssname SelSet Counter )) ;; MainObject
(setq EntDxf (entget Entname ) )
(while EntName ;; Iterate trough all "ATTRIB"s ( includng main ent "INSERT" and "SEQEND" )
(setq EntDxf (entget Entname ) )
(if (and (equal (assoc 0 EntDxf ) '(0 . "ATTRIB") ) (equal (assoc 62 EntDxf ) '(62 . 70) ) )
(progn
(setq EntDxf (subst '(62 . 1) '(62 . 70) EntDxf ) )
(entmod EntDxf )
(entupd EntName )
)
( )
)
(setq EntName (entnext EntName ) ) ;; SubObject
)
(setq Counter (1+ Counter ) )
)
(princ)
)

. . .and probably will all "Myblock" now turn in to red attributed text.
but first you must change Myblock and 1 to your values.

: ) Happy Computing !

kennet