Jump to content

Assistance updating Lisp routine for Field Insertion


Billy Ray

Recommended Posts

(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 :D[/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.

new code.jpg

Link to comment
Share on other sites

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • Billy Ray

    18

  • pBe

    11

  • Lee Mac

    2

  • ronjonp

    2

Top Posters In This Topic

Posted Images

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.

Link to comment
Share on other sites

(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 by pBe
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

You mean there will always be only 2 formats. either 28 or 30 characters? if YES , then you're all set.

 

Yes thank you

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Capture.PNG

 

And the original "updateblock" code was removed at startup.

Edited by pBe
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...