Chad, this seems to work ok for me in 2009. Do you see any errors? Does it
return anything?
Pat Murnen
wrote in message news:6022564@discussion.autodesk.com...
Hello,
I use the following file to automatically populate a last wire number
attribute in my tileblock. Although it has worked fine for years, I recently
upgraded to 2009 and it doesn't work anymore. Can anyone advise as to why it
dosent work anymore?
; 22-Feb-05 NEHolt created
(defun c:lastwnum_proj ( / ss exclude_num_lst ix slen rtrn wireno maxnum en
val)
; Scan active project and find "last wire number" used. Drawings needs to
have been processed
; by AcadE's AUTO WNUMS command or wire numbers manually inserted using
AcadE's EDIT WNUM
; command. This routine can be encoded into AcadE's title block update
mapping file to
; automatically populate a target attribute in the title block with the
last wire number
; used on the entire project.
; Note, issue a (command "_.QSAVE") prior to calling this routine if the
current drawing
; has had its wire numbers updated and the project database not
freshened.
(setq rtrn "") ; default to return a blank space if no wire numbers found
(if (not GBL_wd_m) (wd_cfg_read_dwg_params)) ; read WD_M block if
necessary
; Step 1 - get list of all wire numbers found on DESTINATION signal
arrows. These numbers
; will be excluded from the calculation because the wire number was
assigned on some
; other drawing.
(setq exclude_num_lst nil)
(setq maxnum 0)
; Get list of all project's wire number, 1=freshen database, nil=don't
exclude active dwg
(setq lst (wd_mdb2_get_proj_wnums 1 nil))
(if lst
(progn
(foreach wireno lst
(if (AND wireno (/= wireno "")) ; wire number is not blank
(progn
(setq val (atoi wireno)) ; convert wire number to integer value
(if (> val maxnum)
(progn ; this wire number is biggest so far. Save it.
(setq rtrn wireno) ; return highest wire number so far
(setq maxnum val) ; save highest value so far
) ) ) )
) ) )
rtrn ; return "" or highest wire number found on this dwg
)
Thanks
Chad