PDA

View Full Version : SQL statement - Specialty Items



dave
03-07-2006, 09:06 AM
Apparently in ver. 8.6 SP2 of the Autoplant P&ID software, there is a bug when you try and use the "attach specialty item or tie point command" (NewSPtieinconnection) The bug is that the specialty item or tie point will attach itself to the PIPE RUN PROCESS and not the PIPE RUN itself. I notified bentley and they have logged it. In the meantime, you have to run this lisp routine.

(defun c:RelinkSpecItmToPipeRun (/ en SelEnt keydata Tagtype conen ConnectEnt Condata LnkFld LnkRun keyVal RunVal)

(if (not MenuEnt)
(setq en (entsel (at_msg "\nSelect Specialty Item or Tie-in:" "PID_1484" 1 )))
(setq en (list MenuEnt ()))
)

(if (and
en
(setq SelEnt (get_link (car en)))
(setq keydata (at_asi_get_data SelEnt))
(setq Tagtype (cadr (assoc "^TAG_TYPE" keydata)))
(wcmatch Tagtype "AT_SPEC_ITEM*,AT_TIEIN*")
)
(progn
(if (and
(setq conen (entsel (at_msg "\nSelect component to connect to:" "PID_1485" 1 )))
(setq ConnectEnt (get_link (car conen)))
(setq Condata (at_asi_get_data ConnectEnt))
)
(progn
(if (= tagtype "AT_SPEC_ITEM")
(setq LnkFld "ASSOC_KEY" LnkRun "")
(setq LnkFld "LINE_ID" LnkRun "RUN_ID")
)

(if (wcmatch (cadr (assoc "^TAG_TYPE" Condata)) "AT_PROCESS,AT_PIPERUN")
(setq keyVal (cadr (assoc "KEYTAG" Condata))
RunVal (cadr (assoc "KEYTAG" Condata))
)
(setq keyVal (cadr (assoc "KEYTAG" Condata)))
)

(if (not keyVal) (setq keyVal ""))
(if (not RunVal) (setq RunVal ""))
(if (and (= tagtype "AT_TIEIN") (= RunVal ""))
(abort (at_msg "\nInvalid Selection, selection must be a Process line." "PID_1486" 1))
)

(at_asi_update_data SelEnt (list (list LnkFld keyVal)))
(if (/= RunVal "")
(at_asi_update_data SelEnt (list (list LnkRun RunVal)))
)
(prompt (at_msg "\nConnection Made." "PID_1487" 1))
)
(prompt (at_msg "\nInvalid Selection" "PID_1488" 1))
)
)
(prompt (at_msg "\nInvalid Selection, selecion must be a Specialty Item or Tie-in" "PID_1489" 1))
)
(ResetRightClickMenuVars)
(princ)
)

Copy that into a txt document and save it as "RelinkSpecItmToPipeRun.lsp"

then drag that file into your drawings, type "RelinkSpecItmToPipeRun", and re-attach your specialty items/ tie points to thier respective lines. FUN!

dave
03-20-2006, 10:24 PM
Here is the SQL code for the inner joins of the specialty item view in Data Manager...

SELECT SPEC_ITM_A.KEYTAG, TAG_REG_B.TAG_NO, DOC_REG.DOC_NAME AS [PID DWG NO], SPEC_ITM_A.DESCRIPT, SPEC_ITM_A.LONG_DESC, TAG_REG_C.TAG_NO AS [CONNECTED TO], TAG_REG_C.LAST_MOD, TAG_REG_B.DISPSTAT
FROM ((((TAG_REG AS TAG_REG_B RIGHT JOIN (SPEC_ITM AS SPEC_ITM_A LEFT JOIN TAG_REG AS TAG_REG_C ON SPEC_ITM_A.ASSOC_KEY = TAG_REG_C.KEYTAG) ON TAG_REG_B.KEYTAG = SPEC_ITM_A.KEYTAG) LEFT JOIN PROCESS ON TAG_REG_C.KEYTAG = PROCESS.KEYTAG) LEFT JOIN KEY_LINK ON TAG_REG_B.KEYTAG = KEY_LINK.KEYTAG) LEFT JOIN PID_LNK ON KEY_LINK.LINK_ID = PID_LNK.LINK_ID) LEFT JOIN DOC_REG ON PID_LNK.DWG_NAME = DOC_REG.DOC_ID
WHERE (((TAG_REG_B.TAG_TYPE)='AT_SPEC_ITEM'))
ORDER BY TAG_REG_B.TAG_NO;

dave
03-29-2006, 07:47 AM
SELECT TAG_REG.TAG_NO AS SPECIALTY_TAG, First(TAG_REG_1.TAG_NO) AS [LINE TAG], SPEC_ITM.LONG_DESC, DOC_REG.DOC_NAME AS PID_DRAWING_NO, PIPE_RUN.PSZ, PIPE_RUN.PSPEC, SPEC_ITM.DESCRIPT, [PSZ] & " " & [LINE TAG] & "-" & [PSPEC] AS LINENUMBER
FROM ((((((SPEC_ITM LEFT JOIN PIPE_RUN ON SPEC_ITM.ASSOC_KEY = PIPE_RUN.KEYTAG) LEFT JOIN TAG_REG ON SPEC_ITM.KEYTAG = TAG_REG.KEYTAG) LEFT JOIN PROCESS ON PIPE_RUN.LINE_ID = PROCESS.KEYTAG) LEFT JOIN TAG_REG AS TAG_REG_1 ON PROCESS.KEYTAG = TAG_REG_1.KEYTAG) LEFT JOIN KEY_LINK ON SPEC_ITM.KEYTAG = KEY_LINK.KEYTAG) LEFT JOIN PID_LNK ON KEY_LINK.LINK_ID = PID_LNK.LINK_ID) LEFT JOIN DOC_REG ON PID_LNK.DWG_NAME = DOC_REG.DOC_ID
GROUP BY TAG_REG.TAG_NO, SPEC_ITM.LONG_DESC, DOC_REG.DOC_NAME, PIPE_RUN.PSZ, PIPE_RUN.PSPEC, SPEC_ITM.DESCRIPT;

dave
10-13-2006, 09:31 PM
has anyone used this?