AutoCAD Electrical Forum
Welcome to Autodesk’s AutoCAD Electrical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Electrical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Last wire number help - Nate Holt

4 REPLIES 4
Reply
Message 1 of 5
Fdna49
333 Views, 4 Replies

Last wire number help - Nate Holt

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
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Fdna49

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
Message 3 of 5
Fdna49
in reply to: Fdna49

Hello Pat,
After trying it on another project, it is running, just returning a "blank" value.

The following are copied from the AutoCAD text window

From 2008

Interpreting as AutoLisp: (IF (BOUNDP 'C:LASTWNUM_PROJ)(C:LASTWNUM_PROJ)"")
reading project database file...

Updated LASTWIRENUM: 3 --> 6

From 2009

Interpreting as AutoLisp: (IF (BOUNDP 'C:LASTWNUM_PROJ)(C:LASTWNUM_PROJ)"")
LASTWIRENUM (no change)

So it appears that 2009 is not reading the project database?
Message 4 of 5
Anonymous
in reply to: Fdna49

It seemed to read it fine at my end. Can you send me the project and the
.wdt file if you are using one? My direct email is pat.murnen@autodesk.com.

Pat Murnen

wrote in message news:6023034@discussion.autodesk.com...
Hello Pat,
After trying it on another project, it is running, just returning a "blank"
value.

The following are copied from the AutoCAD text window

From 2008

Interpreting as AutoLisp: (IF (BOUNDP 'C:LASTWNUM_PROJ)(C:LASTWNUM_PROJ)"")
reading project database file...

Updated LASTWIRENUM: 3 --> 6

From 2009

Interpreting as AutoLisp: (IF (BOUNDP 'C:LASTWNUM_PROJ)(C:LASTWNUM_PROJ)"")
LASTWIRENUM (no change)

So it appears that 2009 is not reading the project database?
Message 5 of 5
Anonymous
in reply to: Fdna49

Turns out the file just wasn't getting loaded when each drawing was opened.
This needs set up for 2009. Follow this to have a .lsp file loaded each time
a drawing is opened.

1. in AutoCAD type APPLOAD

2. down at the bottom there is a Startup Suite section. Click Contents.

3. Click Add and navigate to where the .lsp file is to add it

4. Close and Close

5. Exit AutoCAD and then restart



Pat Murnen





wrote in message news:6023034@discussion.autodesk.com...
Hello Pat,
After trying it on another project, it is running, just returning a "blank"
value.

The following are copied from the AutoCAD text window

From 2008

Interpreting as AutoLisp: (IF (BOUNDP 'C:LASTWNUM_PROJ)(C:LASTWNUM_PROJ)"")
reading project database file...

Updated LASTWIRENUM: 3 --> 6

From 2009

Interpreting as AutoLisp: (IF (BOUNDP 'C:LASTWNUM_PROJ)(C:LASTWNUM_PROJ)"")
LASTWIRENUM (no change)

So it appears that 2009 is not reading the project database?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost