Jump to content

Recommended Posts

Posted

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

Posted

Perhaps post a drawing that shows expected results .. this is something that should NEVER have to be done manually.

Posted

Quick test and the code works here .. you have something strange going on with the visibility of the attributes in your block though?

2017-10-18_08-45-04.png

Posted

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

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...