bnmosier Posted October 18, 2017 Posted October 18, 2017 Hello, new user here! I have an old LSP that I've always run with a VBE that takes a portion of the file name and inserts it into an attributed block inside all the drawings in a directory that are named accordingly. Example file name: DCA-ABC-123456789-E001 R0 (drawing number).dwg Each set of characters in the file name will change from project to project as they are project based. We have a DCA block that is called "dca_stmp" that we use in order to create change paper for clients which they then incorporate into their drawings of record. Many times, we have hundreds of these and there are times that we have to re-number them if someone adds a drawing to the package because they're supposed to be in Alpha-Numeric order by drawing number. It is TERRIBLE to have to re-number them all manually by file name AND inside the drawing stamp, so we try to leave them as "DCA-WEH-112177115-EXXX R0 (drawing number).dwg" until the latest possible point in the project. It worked great until we jumped from AutoCAD 2012 to 2016 and now it runs as if it is making the changes, saves the drawings, but doesn't change the block. I have attached the LSP, but it will not allow me to upload the VBE... can anyone help me figure out what I need to do to make this work again?? It has been MANY years since I took classes on LSP and my knowledge is so basic that I can't figure out what is wrong much less how to fix it. FileNameToDCA.lsp Quote
bnmosier Posted October 18, 2017 Author Posted October 18, 2017 Sorry, I forgot to include the block! It is inside the attached file that is named appropriately DCA-ABC-123456789-EXXX R0 (drawing number).dwg Quote
ronjonp Posted October 18, 2017 Posted October 18, 2017 Perhaps post a drawing that shows expected results .. this is something that should NEVER have to be done manually. Quote
bnmosier Posted October 18, 2017 Author Posted October 18, 2017 We have been so used to using the LSP that we had for 2012 and prior that we clearly took it for granted. Here is a dwg that includes the block filled in. DCA-WEH-112177115-E002 R0(45B799s205r2).dwg Quote
ronjonp Posted October 18, 2017 Posted October 18, 2017 Quick test and the code works here .. you have something strange going on with the visibility of the attributes in your block though? Quote
ronjonp Posted October 18, 2017 Posted October 18, 2017 Here's a more consolidated version of the code. Have you ever thought of using fields for this ( %% )? (defun c:foo (/ i n s) (cond ((null (setq s (ssget "_X" '((0 . "insert") (2 . "dca_stmp") (66 . 1))))) (print "Block 'dca_stmp' not found...") ) ((null (setq i (vl-string-position (ascii "-") (setq n (getvar 'dwgname)) 0 t))) (print "'-' not found in drawing name...") ) ((foreach b (mapcar 'cadr (ssnamex s)) (vl-some '(lambda (x) (and (= "DCA_NO." (vla-get-tagstring x)) (vla-put-textstring x (substr n 1 i))) ) (vlax-invoke (vlax-ename->vla-object b) 'getattributes) ) ) ) ) (princ) ) (vl-load-com) Attached is your block with the default set to drawing name. DCA-ABC-123456789-EXXX R0 (drawing number).dwg 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.