View Full Version : Auto Assigned Valve Tagging
HybridAWD
06-12-2006, 11:10 AM
I swear I get so many new ideas to do each day to make my job that much easier... not like it's hard now or anything :wink:
So when placing a valve on my P&ID's it automatically tells me the next number. The problem is that it needs to be modified to have the P&ID number in there. Now before someone tells me to go into project administrator and just add in the P&ID drawing number field, the P&ID number itself is also modified. Ok now it's time to explain since im sure some of you are scratching your heads so let me explain.
How it is currently setup is I have V as the prefix (this stands for valve ;)) and then I use the P&ID number minus the 3rd digit. I have attached 2 picture below showing the original and the modified valve number.
Basically it's: (V) + (P&ID number minus 3rd digit) + (next higher number)
What I was wondering is if it would be possible to have the program simply make it show V23151 instead of V51.
With the P&ID number being modified, I would assume it's not since it would draw the value from the P&ID name or DWg number. Therefore the only way it would work is if the P&ID name or DWG number was 231 and not 2301.
Original
http://thumb15.webshots.com/t/59/59/0/78/78/2643078780092493215UYzgoy_th.jpg (http://community.webshots.com/photo/2643078780092493215UYzgoy)
Modified
http://thumb15.webshots.com/t/63/63/6/29/64/2218629640092493215qEskRs_th.jpg (http://community.webshots.com/photo/2218629640092493215qEskRs)
1st non confused person get the satisfaction that they can understand all of my rambling :D
how would you discern between a valve on 2301, 2311, or 2321?
HybridAWD
06-12-2006, 12:43 PM
how would you discern between a valve on 2301, 2311, or 2321?
We don't have any P&ID's that can have duplicate valve numbers for example this is how some of our are listed:
P&ID -- Valve #
2101 -- V21101
2201 -- V22101
2301 -- V23101
3101 -- V31101
3102 -- V31201
3103 -- V31301
OK, I have an idea in my head about how to make your system work. Just have to find time to try it. Hopefully tommorrow. ;)
PlantWorker
06-14-2006, 06:05 AM
Hi HybridAWD
following code should do what you want, it's slightly based on existing code I have
(defun getvalveprefix ( / )
(setq ThisDocName (car (cadr (at_asi_read_tab "DOC_REG" (list (list "DOC_ID" (at_asi_get_docid)) )(list "DOC_NAME")) )))
(setq vprefix (strcat "V" (substr ThisDocName 1 2) (substr ThisDocName 4 ) ))
)
(getvalveprefix )
(defun nxthnd (/ ValvePrefix currcount Passtag)
(print "looking for next valve tag........")
(setq PassTag (nexttag vprefix "" 2))
(if CheckTagForDup
(setq PassTag (CheckForTagDuplicate (if (and schema (/= schema "")) schema "AT_HVALVE") PassTag))
)
PassTag
)
(DEFUN NextTAG (TTyp sep nrChar / )
(Progn
(SETQ NewNr (formatOn nrChar "1"))
(setq exInst nil)
(WHILE (NOT exinst)
(setq usednr newnr)
(SETQ NewTag (strcat TTYP sep NewNr))
(IF (eq (caadr (at_asi_read_tab "TAG_REG" (list(list "TAG_NO" NewTag)) '("KEYTAG"))) NIL)
(progn
(PRINt NEWTAG)
(princ " bestond niet")
(setq exInst T) ;bestaat niet
)
)
(SETQ NewNr (rtos (1+ (atoi NewNr))))
(setq newnr (formatOn nrChar newnr))
)
);end progn
newtag
)
(defun formaton (slen ctr)
(if (= slen 0)
(setq ctr ctr)
(if (> (strlen ctr ) slen)(setq ctr "#B#")
(PROGN
(setq Ctr (strcat "000000000" Ctr))
(setq Ctr (substr Ctr (- (strlen ctr) (- slen 1))))
)
)
)
ctr
)
you can put this code in your pid-sup.lsp, or -better- in a separate file that gets loaded from pid-sup.lsp
I have this in my pid-sup.lsp that loads additional lisp-files. this allows to keep them separate from the original and is easier when installing patches and upgrades. It does assume you are using a custom directory (which you should). look for the existing ;; AutoCAD 2000 -part and add it after that
;; AutoCAD 2000
(if (= (at_Sys_getAcadVer) 15)
(setvar "ACADLSPASDOC" 1)
)
good luck with it
;;************************************************ ****************************
(LOADER 4)
;load the custom lisp files.lsp
(defun loadUserLisp ( / supnam csupnam )
(setq userlispfiles (list "user" ))
(foreach supnam userlispfiles
(progn
; (setq supnam "user")
(if
(and (at_Env_getSes "APCUSTDIR")
(setq csupnam (at_fi_custname supnam 1))
(/= csupnam "")
(findfile (strcat csupnam ".lsp"))
)
(progn
(print (strcat "----------------loading " supnam ".lsp"))
(load csupnam nil)
)
)
)
)
)
(loadUserLisp)
:shock: excellent! Thanks PlantWorker!
Hybrid - let us know if this worked for you, thanks!
Hybrid, have you had a chance to test out his lisp routine?
HybridAWD
06-28-2006, 08:20 AM
No I sure havent. I've been so busy around here and then of course the last couple of days our ISP was retarded and accidently cut off our service. -_- I'll get around to it today or something this week.
HybridAWD
06-30-2006, 11:43 AM
Do I need to insert it in a specific location in the lisp file? I dropped it in at the bottom but nothing changed. Sorry for being such a nOOb ,I still have a ton to learn about the lisp.
PlantWorker
07-03-2006, 03:23 AM
:shock: It should work at the end of the file. For testing, you can put the code in a separate file, fe. valvecoding.lsp and drag/drop that file into an open p&id, it will be loaded automatically. Check the command window for any error messages. Then place a valve and check the numbering.
shaneo
06-03-2010, 11:41 PM
is anybody doing anything similar to this with V8i? this is quite an old thread, so i was wondering if there is a better way to do this now?
Rijkwerd
06-04-2010, 01:26 AM
Yes this works fine with V8i and I don't think there is a better solution than this.
shaneo
06-06-2010, 02:45 PM
thanks
you might be able to help me then, my LISP skills are a little rusty. our valve tags look like this
xxxVyy
xxx is the last three digits of the drawing number
V is just a deliminator
yy is the sequencial number
i changed the code fine, but for numbers 1-9 it does not add a leading 0, ie i get 001V1 rather than 001V01. is there a way to force it? my code is below.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Valve Tag Creation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;Toggle used with the building of Valve Tags. If T the Drawing name is not used in
;;the Valve tag.
;(setq NoDwgNameInValveTag T) ;<- Do not use Drawing name in Valve Tag
(setq NoDwgNameInValveTag ()) ;<- Use Drawing name in Valve Tag
;; If below variable is set the Valve Tag will use the set variable in the building
;; of the Valve tag.
(setq UsePredefinedValveTag "")
(defun nxthnd (/ ValvePrefix currcount Passtag)
(setq ValvePrefix "v") ;; Valve Prefix
(setq currcount (strcat ValvePrefix (itoa (setvar "useri5" (1+ (getvar "useri5")))))) ;;; Counter
(if (CheckPredefinetag UsePredefinedValveTag)
(setq currcount UsePredefinedValveTag) ;; Check if Predefined Tag is Set
)
(if (not NoDwgNameInValveTag)
(setq PassTag (strcat (substr dwgnam 14 3) currcount)) ;; Create Tag ;; modified by S Abell
(setq PassTag currcount)
)
(setq PassTag (CheckNumOfSchemaFields (if (and schema (/= schema "")) schema "AT_HVALVE") PassTag ValvePrefix))
(if CheckTagForDup
(setq PassTag (CheckForTagDuplicate (if (and schema (/= schema "")) schema "AT_HVALVE") PassTag))
)
PassTag
)
Rijkwerd
06-07-2010, 01:36 AM
@ line
(setq PassTag (strcat (substr dwgnam 14 3) currcount)) ;; Create Tag ;;
to
(setq PassTag (strcat (substr dwgnam 14 3) (substr (strcat "00" currcount) (strlen curcount))))) ;; Create Tag ;;
awerning
06-07-2010, 05:58 PM
Hmmm...not sure if that will work (maybe).
If not, try this one:
@ line
(setq currcount (strcat ValvePrefix (itoa (setvar "useri5" (1+ (getvar "useri5")))))) ;;; Counter
Replace with:
(if (= 1 (strlen (setq currcount (itoa (setvar "useri5" (1+ (getvar "useri5")))))))
(setq currcount (strcat ValvePrefix "0" currcount))
(setq currcount (strcat ValvePrefix currcount))
)
That will definitely do it.
HTH
shaneo
06-07-2010, 06:01 PM
correct, it didn't work. i was going to work out what i needed to do over lunch but i'll give your code a go first. thanks Aaron.
shaneo
06-07-2010, 08:20 PM
that did the trick, thank Aaron!!
Shihan Jedi
12-10-2010, 07:49 AM
This thread is full of awesomeness.
bfullenkamp
01-10-2011, 02:18 PM
Hmmm...not sure if that will work (maybe).
If not, try this one:
@ line
(setq currcount (strcat ValvePrefix (itoa (setvar "useri5" (1+ (getvar "useri5")))))) ;;; Counter
Replace with:
(if (= 1 (strlen (setq currcount (itoa (setvar "useri5" (1+ (getvar "useri5")))))))
(setq currcount (strcat ValvePrefix "0" currcount))
(setq currcount (strcat ValvePrefix currcount))
)
That will definitely do it.
HTH
This worked for me as well to get my 4 digit numbers so my valves are MV0001, MV0002, etc... I just had to nest the If statements to account for string lenghts of 1,2,3 or 4 for the currcount.
bfullenkamp
01-11-2011, 04:21 AM
Now I need to get the valve number not to restart on each P&ID because we want to give each manual valve on the entire project it's own sequential number, but each new P&ID I start it is starting over at MV0001 instead of it picking up on MV0018 on the next P&ID I am trying to create. I'll get the "this tag already exists, create new link" dialog, but I really need it to by default go to the next available number across all P&ID's. Here is my code as it is now:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Valve Tag Creation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun nxthnd (/ ValvePrefix currcount Passtag)
(setq ValvePrefix "MV")
(if (= 1 (strlen (setq currcount (itoa (setvar "useri5" (1+ (getvar "useri5")))))))
(setq currcount (strcat ValvePrefix "000" currcount))
(if (= 2 (strlen (setq currcount (itoa (setvar "useri5" (1+ (getvar "useri5")))))))
(setq currcount (strcat ValvePrefix "00" currcount))
(if (= 3 (strlen (setq currcount (itoa (setvar "useri5" (1+ (getvar "useri5")))))))
(setq currcount (strcat ValvePrefix "0" currcount))
(if (= 4 (strlen (setq currcount (itoa (setvar "useri5" (1+ (getvar "useri5")))))))
(setq currcount (strcat ValvePrefix "" currcount))
(setq currcount (strcat ValvePrefix currcount))
)
)
)
)
(if (CheckPredefinetag UsePredefinedValveTag)
(setq currcount UsePredefinedValveTag)
)
(if (not NoDwgNameInValveTag)
(setq PassTag currcount)
)
(setq PassTag (CheckNumOfSchemaFields (if (and schema (/= schema "")) schema "AT_HVALVE") PassTag ValvePrefix))
(if CheckTagForDup
(setq PassTag (CheckForTagDuplicate (if (and schema (/= schema "")) schema "AT_HVALVE") PassTag))
)
PassTag
)
PeterJ
01-11-2011, 11:24 AM
I have code that does just what you need (and a lot of other stuff I collected in 16 years of supporting this software), but I can't distribute it for free since other companies have paid for it. I'm working as freelance consultant and can deliver these customizations to your company's flavour.
Contact me in private if you need more info.
ps: from any $ I make through this site, a part will go back to the site.
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.