Saturday, April 14, 2012

Process and Instrumentation Diagrams (PIDs)...but wait ...there's more!

Hmfff.....looks like I was wrong thinking 1.5mm high text was a good idea.

It so happened that one of our electrical engineers has just had an eye operation and was having an awful time trying to read my drawings.

I realised they would have to be changed to 2mm high, which a huge nuisance as I have done quite a few drawings.

Just to add to the fun, it appears that the requirement is for each sheet to show mainly just one item, so a drawing might only have one tank, with it's associated piping and pumps. So the emphasis is still on systems, just at a finer level.

The drawings I had done were not wasted, as they became the detailed PROCESS FLOW DIAGRAMS. Some upside to this as I have a bad habit of trying to squeeze too much onto one drawing usually.

I have started on a lisp routine to deal to errant drawings: it is called FIX.lsp. When it is up and running I will post it.

In the meantime, in a rush of enthusiasm that has just evaporated, I have just gotten the skeleton of a routine together that should make PID drudgery a little easier.

The idea of the routine, called ADTAGS.lsp, is that you have done all the graphical elements of your drawing, that is you have drawn all the valves and pipelines in, and you now wish to add tags to all the items in the drawing. For instance you may have 3 manual valves, and you want to label them with tags, HV001,HV002 and HV003, as per the picture above.

Here is the routine, which is obviously far from finished:

;Program written by Bill Le Couteur
;Auckland NZ
;Rev 0 date 14-4-12
;This program adds tag numbers to a bunch of blocks
;only works for blocks named "VALVE MANUAL" at the moment

(defun c:ADTAGS()
(setq count 0)
(setvar "attdia" 0); turns off the dialog box you get when issuing ate commmand

(setq ss1 (ssget "X" '(( 0 . "INSERT")( 2 . "VALVE-MANUAL")) ))
;gets a selection set of the whole drawing, filtering for the block we want

(setq the_no_of_members(sslength ss1))
;how many members in the selection set?

;;;;;SET THE INSERTION POINTS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(while (< count the_no_of_members)
(setq en (ssname ss1 count))
(setq edata (entget en))
(setq theposn(cdr(assoc 10 edata)))
(setq the_x (car theposn))
(setq the_x ( - the_x 5))
(setq the_y (cadr theposn))
(setq rot (cdr (assoc 50 edata)))
(if (eq rot 0)(setq the_tagy (+ the_y 4)))
(if (/= rot 0)(setq the_tagy (- the_y 1.5)))
(if (/= rot 0)(setq the_x ( + the_x 9)))
(setq counts (itoa count))
(if (eq rot 0)(setq the_tag (strcat "HV00" counts)))
(if (/= rot 0)(setq the_tag (strcat "HV00" counts)))
(command "-insert" "tag" (list the_x the_tagy) "1" "1" "0" the_tag)

(setq count ( + count 1));add one to the counter to keep the loop going

);end while progn
);end while

(setvar "attdia" 1);turns on the dialog box you get when issuing ate commmand