Automate drawing number x of y

Automate drawing number x of y

Anonymous
Not applicable
412 Views
2 Replies
Message 1 of 3

Automate drawing number x of y

Anonymous
Not applicable

We have several sets of drawings that the client is asking to be numbered x of y

The number of drawings in each set keeps varying & drawing(s) inserted so I am attempting to automate the whole process. We do not use the AutoCAD drawing sets facility & each drawing is separate within one folder at each issue.

The drawing number part was fairly straight forward (the x part of 'x of y'), the following diesel expression used within a field:

$(if,$(=,$(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),6),1),0),$(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),5),1),$(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),6),2))

i.e. if the filename ends in "01A", it returns "1", if the filename ends in "94A", it returns "94"

 

It's the y part of 'x of y' that is giving me difficulties.

 

(length (car(list (vl-directory-files (getvar"dwgprefix") "*.dwg"))))

And

 

(length (car(list (acet-file-dir "*.dwg")))); unreliable, depends on Express Tools

Both return the number of AutoCAD files with the same folder as the drawing from which the functions are called & would be ideal if I could get them into a field or attribute.

Please does anybody know how to put one of these into a field, attribute or even a diesel expression ?

0 Likes
413 Views
2 Replies
Replies (2)
Message 2 of 3

marko_ribar
Advisor
Advisor

Put into your acaddoc.lsp :

(setq *dwgs* (length (vl-directory-files (getvar "dwgprefix") "*.dwg")))


Create field in your drawing like so :

%<\AcVar.17.0 Lisp.*dwgs*>%


(to connect variable *dwgs* stored in atoms-family when you open DWG with FIELD)
It should update whenever you open DWG and if there are new DWGs in current directory it should display new value when you invoke REGEN command...

 

HTH, M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thank you Marko, it does indeed work well.

 

However if the files were to be opened by anyone else but myself it would probably appear as ####

 

Short of going round changing everyone's  ACADDOC I don't think it would be successful.

 

Reluctantly I think the only solution is an XREF with the field for sheet number (above) in the parent directory of each folder of drawings, at least it means I/we only have to change one file any time a sheet is added or deleted

 

Reluctantly because we're generally not in favour with XREFs because they can be deleted or moved

0 Likes