Billy Ray Posted July 18, 2018 Author Posted July 18, 2018 (Defun c:FromLispToTblock ( / acadDocument dwgname breaker) Come to think of it, there's no point in using fields if one is using a lisp code to generate the value [/color] pBe, As an individual command and lisp this works however not for running batches or the Macatteditor. The command would have to be entered in every drawing to pull up the field insertion. I am trying to put your code or LM's in this section of code like the others (pic attached) so I can have the "DWG. No." as a selectable field name but I cannot get it to work. I'll keep trying. Thanks Thus far I've gotten the field name to appear but it doesn't work, lol. Quote
Billy Ray Posted July 19, 2018 Author Posted July 19, 2018 I'll get back to you in a few.... stay tuned... Thank you very much for any help. I'm terrible at reverse coding these things but getting better. seems silly I know to Lisp the custom field but it saves SO MUCH time here this way. Quote
pBe Posted July 20, 2018 Posted July 20, 2018 (edited) (Defun c:updatetitleblock2018 ( / acadObject acadDocument dwgname dProps dPropsnum breaker DrawingNoFromFilename RevisionFromFilename CP_data ) (setq acadObject (vlax-get-acad-object) acadDocument (vla-get-ActiveDocument acadObject) dwgname (vl-filename-base (vla-get-name acadDocument)) dProps (vlax-get-Property acadDocument 'SummaryInfo) dPropsnum (vla-NumCustomInfo dProps) KeyNames '("File name before underscore" "DRAWING No. (from file name)" "REV (from file name)" ) ) (setq dash (vl-string-position 45 dwgname nil t) breaker (cond ((= dash 26)'((1 2) (3 5) (8 6) (14 3) (17 3) (20 5))) ((= dash 28)'((1 2) (3 7) (10 6) (16 3) (19 3) (22 5))) ) ) (cond ( (not (and (or (= dash 26) (= dash 28)) (setq DrawingNoFromFilename (substr (apply 'strcat (mapcar '(lambda (n) (strcat "-" (substr (getvar 'dwgname) (car n) (cadr n))) ) breaker ) ) 2 ) RevisionFromFilename (substr dwgname (+ 2 dash))) (ssget "_X" '((0 . "INSERT")(66 . 1)(2 . "PLC_Anadarko_D_Bord_2017")(410 . "~Model"))) ) ) ) ( (zerop dPropsnum) (mapcar (function (lambda (customPropertyName customPropertyValue) (vla-addcustominfo dProps customPropertyName customPropertyValue) customPropertyValue)) KeyNames (list dwgname DrawingNoFromFilename RevisionFromFilename) ) ) ( (and (setq CP_data nil KeyCount 0)) (while (< KeyCount dPropsnum) (vla-GetCustomByIndex dProps KeyCount 'TempKeyName 'TempKeyValue) (setq CP_data (cons (list (strcase TempKeyName) TempKeyValue) CP_data) KeyCount (setq KeyCount (1+ KeyCount)) ) ) (mapcar (function (lambda (customPropertyName customPropertyValue) (if (setq KeyValue (assoc (strcase customPropertyName) CP_data)) (vla-SetCustomByKey dProps customPropertyName customPropertyValue) (vla-addcustominfo dProps customPropertyName customPropertyValue)) ) ) KeyNames (list dwgname DrawingNoFromFilename RevisionFromFilename)) ) ) (princ) ) (C:UPDATETITLEBLOCK2018) (princ) BUT wait: what if the revision number on the filename is 2 digits? "SA2144283FA2006PLCE020103101-12" then its 29 or 31. Will there still be an 18 to 24 character file name? SA2144283FA2006PLCE020103101-2.dwg Edited July 20, 2018 by pBe Quote
Billy Ray Posted July 20, 2018 Author Posted July 20, 2018 BUT wait: what if the revision number on the filename is 2 digits? "SA2144283FA2006PLCE020103101-12" then its 29 or 31. Will there still be an 18 to 24 character file name? The revision number will always be one digit and the characters will never change from 18 or 24 that is correct. Quote
pBe Posted July 20, 2018 Posted July 20, 2018 You mean there will always be only 2 formats. either 28 or 30 characters? if YES , then you're all set. Quote
Billy Ray Posted July 20, 2018 Author Posted July 20, 2018 Also,this routine seems to be the same as the last one. The insertion is only available after the command is entered. Also, the insertion goes away after saving and closing the file. Once reopened it removes the dashes some how. But I do thank you for your efforts. Quote
Billy Ray Posted July 20, 2018 Author Posted July 20, 2018 You mean there will always be only 2 formats. either 28 or 30 characters? if YES , then you're all set. Yes thank you Quote
pBe Posted July 20, 2018 Posted July 20, 2018 Also,this routine seems to be the same as the last one. The insertion is only available after the command is entered. Also, the insertion goes away after saving and closing the file. Once reopened it removes the dashes some how. But I do thank you for your efforts. Curious, perhaps you may need to replace your original code with the one at post#24. I included this line at the very end of the routine, (C:UPDATETITLEBLOCK2018) That is assuming the program is loaded at startup. Quote
Billy Ray Posted July 20, 2018 Author Posted July 20, 2018 That is assuming the program is loaded at startup. Updated the code and restarted CAD It is loaded at startup and now works right away without the command, however it still removes he dashes after saving and reopening the file, lol. I have no idea why. Quote
pBe Posted July 20, 2018 Posted July 20, 2018 (edited) Updated the code and restarted CAD It is loaded at startup and now works right away without the command, however it still removes he dashes after saving and reopening the file, lol. I have no idea why. Thats odd, Make sure the title block on my last post is the one inserted on your drawing. And the original "updateblock" code was removed at startup. Edited July 21, 2018 by pBe Quote
Billy Ray Posted July 20, 2018 Author Posted July 20, 2018 I got it! Just realized that insertion name is identical to the current one I had. After removing the other lisp it is good to go! Having the same name affected it is all. Very sorry I missed that and thank you again for your help pBe! I will find a way to change the insertion name to DWG. No. as I intended and then should be able to still use both. Thanks again!! I really appreciate it. Quote
pBe Posted July 21, 2018 Posted July 21, 2018 I got it!....and thank you again for your help pBe! Good for you, and you are welcome. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.